From 86e291120d124dec7244202b1766901a59dfb2e6 Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Thu, 1 Aug 2024 18:25:14 +0200 Subject: [IMP] newoskrnl: Add symbol for cred_construct_token, reworked ProcessHeap, new SCI.hxx for SCI and SCM. [IMP] newosldr: Loads the kernel correctly and can launch it, improved erorr handling. [META] newoskrnl, newosldr: Improved code and refactors. Signed-off-by: Amlal EL Mahrouss --- SCIKit/ErrorTypes.hxx | 2 +- SCIKit/SCI.hxx | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ SCIKit/Types.hxx | 73 ------------------------------- 3 files changed, 118 insertions(+), 74 deletions(-) create mode 100644 SCIKit/SCI.hxx delete mode 100644 SCIKit/Types.hxx (limited to 'SCIKit') diff --git a/SCIKit/ErrorTypes.hxx b/SCIKit/ErrorTypes.hxx index 4473722a..35af4d64 100644 --- a/SCIKit/ErrorTypes.hxx +++ b/SCIKit/ErrorTypes.hxx @@ -6,7 +6,7 @@ #pragma once -#include +#include #define ErrLocalIsOk() (kLastError == kErrorSuccess) #define ErrLocalFailed() (kLastError != kErrorSuccess) diff --git a/SCIKit/SCI.hxx b/SCIKit/SCI.hxx new file mode 100644 index 00000000..5f819ba1 --- /dev/null +++ b/SCIKit/SCI.hxx @@ -0,0 +1,117 @@ +/* ------------------------------------------- + +Copyright ZKA Technologies. + +File: Types.hxx. +Purpose: System Call types. + +------------------------------------------- */ + +#pragma once + +#define IMPORT_CXX extern "C++" +#define IMPORT_C extern "C" + +typedef bool Bool; +typedef void UInt0; + +typedef __UINT64_TYPE__ UInt64; +typedef __UINT32_TYPE__ UInt32; +typedef __UINT16_TYPE__ UInt16; +typedef __UINT8_TYPE__ UInt8; + +typedef __SIZE_TYPE__ SizeT; + +typedef __INT64_TYPE__ SInt64; +typedef __INT32_TYPE__ SInt32; +typedef __INT16_TYPE__ SInt16; +typedef __INT8_TYPE__ SInt8; + +typedef void* VoidPtr; +typedef __UINTPTR_TYPE__ UIntPtr; +typedef char Char; + +typedef Char UTFChar; + +// Interfaces are divided between classes. +// So that they aren't too big. + +class UnknownInterface; // Refrenced from an IDB entry. +class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: WordUCLSID. + +class __attribute__((uuid("d7c144b6-0792-44b8-b06b-02b227b547df"))) UnknownInterface +{ +public: + explicit UnknownInterface() = default; + virtual ~UnknownInterface() = default; + + UnknownInterface& operator=(const UnknownInterface&) = default; + UnknownInterface(const UnknownInterface&) = default; + + SInt32 Release() + { + delete this; + return 0; + } +}; + +#ifdef __NEWOS_SYMS__ +#include +#else + +/// @brief Allocate new SCM class. +/// @tparam TCLS +/// @tparam UCLSID +/// @param uclsidOfCls +/// @return +template +inline TCLS* RtlGetClassFromCLSID(UCLSID uclsidOfCls, Args... args); + +/// @brief Release SCM class. +/// @tparam TCLS +/// @param cls +/// @return +template +inline SInt32 RtlReleaseClass(TCLS* cls); + +#endif + +/* ================================================ */ +/* SCI structures */ +/* ================================================ */ + +struct HEAP_ALLOC_INFO final +{ + VoidPtr fThe; + SizeT fTheSz; +}; + +struct THREAD_INFORMATION_BLOCK final +{ + Char f_Cookie[3]; // Process cookie. + UIntPtr f_Code; // Start Address + UIntPtr f_Data; // Allocation Heap + UIntPtr f_BSS; // Stack Pointer. + SInt32 f_ID; // Thread execution ID. +}; + +struct PROCESS_BLOCK_INFO final +{ + THREAD_INFORMATION_BLOCK* fTIB; + THREAD_INFORMATION_BLOCK* fGIB; +}; + +struct PROCESS_EXIT_INFO final +{ + static constexpr auto cReasonLen = 512; + + SInt64 fCode; + Char fReason[cReasonLen]; +}; + +/// @brief Raise system call. +/// @param id the system call id could be 0x10 for example. +/// @param data the data associated with it. +/// @param data_sz the size of the data associated with it. +/// @return status code. +IMPORT_C SInt32 RtlRaiseSystemCall(const SInt32 id, VoidPtr data, SizeT data_sz); \ No newline at end of file diff --git a/SCIKit/Types.hxx b/SCIKit/Types.hxx deleted file mode 100644 index 2c7e204e..00000000 --- a/SCIKit/Types.hxx +++ /dev/null @@ -1,73 +0,0 @@ -/* ------------------------------------------- - -Copyright ZKA Technologies. - -File: Types.hxx. -Purpose: System Call types. - -------------------------------------------- */ - -#pragma once - -#define IMPORT_CXX extern "C++" -#define IMPORT_C extern "C" - -typedef bool Bool; -typedef void UInt0; - -typedef __UINT64_TYPE__ UInt64; -typedef __UINT32_TYPE__ UInt32; -typedef __UINT16_TYPE__ UInt16; -typedef __UINT8_TYPE__ UInt8; - -typedef __SIZE_TYPE__ SizeT; - -typedef __INT64_TYPE__ SInt64; -typedef __INT32_TYPE__ SInt32; -typedef __INT16_TYPE__ SInt16; -typedef __INT8_TYPE__ SInt8; - -typedef char UTFChar; - -// Interfaces are divided between classes. -// So that they aren't too big. - -class UnknownInterface; // Refrenced from an IDB entry. -class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: WordUCLSID. - -class __attribute__((uuid("d7c144b6-0792-44b8-b06b-02b227b547df"))) UnknownInterface -{ -public: - explicit UnknownInterface() = default; - virtual ~UnknownInterface() = default; - - UnknownInterface& operator=(const UnknownInterface&) = default; - UnknownInterface(const UnknownInterface&) = default; - - SInt32 Release() - { - delete this; - return 0; - } -}; - -#ifdef __NEWOS_SYMS__ -#include -#else - -/// @brief Allocate new SCM class. -/// @tparam TCLS -/// @tparam UCLSID -/// @param uclsidOfCls -/// @return -template -inline TCLS* RtlGetClassFromCLSID(UCLSID uclsidOfCls, Args... args); - -/// @brief Release SCM class. -/// @tparam TCLS -/// @param cls -/// @return -template -inline SInt32 RtlReleaseClass(TCLS* cls); - -#endif \ No newline at end of file -- cgit v1.2.3