From 274cba18b8f1c255ddcff2f5c14aab4d0c846820 Mon Sep 17 00:00:00 2001 From: Amlal Date: Tue, 23 Jul 2024 12:02:10 +0200 Subject: [IMP] User class and current user global. [REMOVE] ApplicationInterface struct. [IMP] DDK_STATUS_STRUCT data structure for driver events. Signed-off-by: Amlal --- Kernel/KernelKit/PermissionSelector.hxx | 57 ----------------------------- Kernel/KernelKit/ProcessScheduler.hxx | 2 +- Kernel/KernelKit/User.hxx | 65 +++++++++++++++++++++++++++++++++ Kernel/NewKit/ApplicationInterface.hxx | 31 ---------------- Kernel/Sources/Main.cxx | 6 ++- Kernel/Sources/PermissionSelector.cxx | 47 ------------------------ Kernel/Sources/User.cxx | 54 +++++++++++++++++++++++++++ 7 files changed, 125 insertions(+), 137 deletions(-) delete mode 100644 Kernel/KernelKit/PermissionSelector.hxx create mode 100644 Kernel/KernelKit/User.hxx delete mode 100644 Kernel/NewKit/ApplicationInterface.hxx delete mode 100644 Kernel/Sources/PermissionSelector.cxx create mode 100644 Kernel/Sources/User.cxx (limited to 'Kernel') diff --git a/Kernel/KernelKit/PermissionSelector.hxx b/Kernel/KernelKit/PermissionSelector.hxx deleted file mode 100644 index 309e260a..00000000 --- a/Kernel/KernelKit/PermissionSelector.hxx +++ /dev/null @@ -1,57 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#ifndef _INC_PERMISSION_SEL_HXX_ -#define _INC_PERMISSION_SEL_HXX_ - -#include -#include - -// super admin mode user. -#define kMachineUser "Machine" - -// user mode users. -#define kSuperUser "Admin" -#define kGuestUser "Guest" - -// hash 'user@host:password' -> base64 encoded data -// use this data to then fetch specific data. - -namespace Kernel -{ - enum class RingKind - { - kRingUser = 3, - kRingDriver = 2, - kRingKernel = 0, - kRingUnknown = -1, - kRingCount = 4, - }; - - class PermissionSelector final - { - private: - explicit PermissionSelector(const Int32& sel); - explicit PermissionSelector(const RingKind& kind); - - ~PermissionSelector(); - - public: - NEWOS_COPY_DEFAULT(PermissionSelector) - - public: - bool operator==(const PermissionSelector& lhs); - bool operator!=(const PermissionSelector& lhs); - - public: - const RingKind& Ring() noexcept; - - private: - RingKind fRing; - }; -} // namespace Kernel - -#endif /* ifndef _INC_PERMISSION_SEL_HXX_ */ diff --git a/Kernel/KernelKit/ProcessScheduler.hxx b/Kernel/KernelKit/ProcessScheduler.hxx index e5368201..4f9f99f6 100644 --- a/Kernel/KernelKit/ProcessScheduler.hxx +++ b/Kernel/KernelKit/ProcessScheduler.hxx @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/Kernel/KernelKit/User.hxx b/Kernel/KernelKit/User.hxx new file mode 100644 index 00000000..aa0901ac --- /dev/null +++ b/Kernel/KernelKit/User.hxx @@ -0,0 +1,65 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#ifndef _INC_PERMISSION_SEL_HXX_ +#define _INC_PERMISSION_SEL_HXX_ + +#include +#include +#include + +// user mode users. +#define kSuperUser "Admin" +#define kGuestUser "Guest" + +#define kUsersDir "\\Users\\Store\\" + +#define kMaxUserNameLen (255) + +// hash 'password' -> base64+md5 encoded data +// use this data to then fetch specific data of the user.. + +namespace Kernel +{ + enum class RingKind + { + kRingStdUser = 1, + kRingSuperUser = 2, + kRingGuestUser = 5, + kRingCount = 5, + }; + + class User final + { + public: + explicit User() = default; + + User(const Int32& sel, const Char* userName); + User(const RingKind& kind, const Char* userName); + + ~User(); + + public: + NEWOS_COPY_DEFAULT(User) + + public: + bool operator==(const User& lhs); + bool operator!=(const User& lhs); + + public: + const RingKind& Ring() noexcept; + const StringView Name() noexcept; + + private: + RingKind fRing{RingKind::kRingStdUser}; + StringView fUserName{kMaxUserNameLen}; + + }; + + inline User* cRootUser = nullptr; +} // namespace Kernel + +#endif /* ifndef _INC_PERMISSION_SEL_HXX_ */ diff --git a/Kernel/NewKit/ApplicationInterface.hxx b/Kernel/NewKit/ApplicationInterface.hxx deleted file mode 100644 index 31da9aa3..00000000 --- a/Kernel/NewKit/ApplicationInterface.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#pragma once - -/// -/// @brief Application object, given by the OS to the process. interact with the OS. -/// @file ApplicationInterface.hxx -/// @author Amlal EL Mahrouss -/// - -#include -#include - -/// \brief Application Interface. -/// \author Amlal El Mahrouss -typedef struct _ApplicationInterface final -{ - /// @brief Releases the object exit the process on main object. - Kernel::Void (*Release)(struct _Application* Self, Kernel::Int32 ExitCode); - /// @brief Invoke a function from the application object. - Kernel::IntPtr (*Invoke)(struct _Application* Self, Kernel::Int32 Sel, ...); - /// @brief Query a new application object from a GUID. - /// @note this doesn't query a process, it query a registered object withtin that app. - Kernel::Void (*Query)(struct _Application* Self, Kernel::VoidPtr* Dst, Kernel::SizeT SzDst, Kernel::XRN::GUIDSequence GuidOf); -} ApplicationInterface, *ApplicationInterfaceRef; - -#define app_cast reinterpret_cast diff --git a/Kernel/Sources/Main.cxx b/Kernel/Sources/Main.cxx index 92dac251..b0083730 100644 --- a/Kernel/Sources/Main.cxx +++ b/Kernel/Sources/Main.cxx @@ -63,7 +63,7 @@ namespace Kernel::Detail const auto cDirCount = 9; const char* cDirStr[cDirCount] = { "\\Boot\\", "\\System\\", "\\Support\\", "\\Applications\\", - "\\Users\\", "\\Library\\", "\\Mounted\\", "\\DCIM\\", "\\Applications\\Storage\\"}; + "\\Users\\", "\\Library\\", "\\Mounted\\", "\\DCIM\\", "\\Applications\\Store\\"}; for (Kernel::SizeT dirIndx = 0UL; dirIndx < cDirCount; ++dirIndx) { @@ -188,6 +188,10 @@ namespace Kernel::Detail /// @return void no return value. STATIC Kernel::Void ke_user_switch(Kernel::Void) { + + Kernel::cRootUser = new User(RingKind::kRingSuperUser, kSuperUser); + Kernel::kcout << "newoskrnl: logged in as: " << Kernel::cRootUser->Name().CData() << Kernel::endl; + Kernel::kcout << "newoskrnl: " << cKernelVersion.GetKey().CData() << ": " << Kernel::number(cKernelVersion.GetValue()) << Kernel::endl; } } // namespace Kernel::Detail diff --git a/Kernel/Sources/PermissionSelector.cxx b/Kernel/Sources/PermissionSelector.cxx deleted file mode 100644 index 726f34e1..00000000 --- a/Kernel/Sources/PermissionSelector.cxx +++ /dev/null @@ -1,47 +0,0 @@ -/* - * ======================================================== - * - * Kernel - * Copyright ZKA Technologies, all rights reserved. - * - * File: PermissionSelector.cpp - * Purpose: Permission selectors. - * - * ======================================================== - */ - -#include -#include - -/// bugs 0 - -namespace Kernel -{ - PermissionSelector::PermissionSelector(const Int32& sel) - : fRing((RingKind)sel) - { - MUST_PASS(sel > 0); - } - - PermissionSelector::PermissionSelector(const RingKind& ringKind) - : fRing(ringKind) - { - } - - PermissionSelector::~PermissionSelector() = default; - - bool PermissionSelector::operator==(const PermissionSelector& lhs) - { - return lhs.fRing == this->fRing; - } - - bool PermissionSelector::operator!=(const PermissionSelector& lhs) - { - return lhs.fRing != this->fRing; - } - - const RingKind& PermissionSelector::Ring() noexcept - { - return this->fRing; - } -} // namespace Kernel diff --git a/Kernel/Sources/User.cxx b/Kernel/Sources/User.cxx new file mode 100644 index 00000000..1deac5be --- /dev/null +++ b/Kernel/Sources/User.cxx @@ -0,0 +1,54 @@ +/* + * ======================================================== + * + * Kernel + * Copyright ZKA Technologies, all rights reserved. + * + * File: User.cpp + * Purpose: Permission selectors. + * + * ======================================================== + */ + +#include +#include + +/// bugs 0 + +namespace Kernel +{ + User::User(const Int32& sel, const Char* userName) + : fRing((RingKind)sel) + { + MUST_PASS(sel >= 0); + this->fUserName += userName; + } + + User::User(const RingKind& ringKind, const Char* userName) + : fRing(ringKind) + { + this->fUserName += userName; + } + + User::~User() = default; + + bool User::operator==(const User& lhs) + { + return lhs.fRing == this->fRing; + } + + bool User::operator!=(const User& lhs) + { + return lhs.fRing != this->fRing; + } + + const StringView User::Name() noexcept + { + return this->fUserName; + } + + const RingKind& User::Ring() noexcept + { + return this->fRing; + } +} // namespace Kernel -- cgit v1.2.3