From e15430b941eb234c2fee35d3ba9ea51a7df14abe Mon Sep 17 00:00:00 2001 From: Amlal EL Mahrouss Date: Thu, 1 Aug 2024 22:10:58 +0200 Subject: [META] BUMP. Signed-off-by: Amlal EL Mahrouss --- SCIKit/ErrorTypes.cxx | 9 ---- SCIKit/ErrorTypes.hxx | 49 ------------------ SCIKit/SCI.hxx | 117 ----------------------------------------- SCIKit/SCIBase.hxx | 135 ++++++++++++++++++++++++++++++++++++++++++++++++ SCIKit/SCIErr.cxx | 9 ++++ SCIKit/SCIErr.hxx | 49 ++++++++++++++++++ SCIKit/SCIObjRt.cxx | 8 +++ SCIKit/rtl.internal.inl | 30 ++++++++++- 8 files changed, 229 insertions(+), 177 deletions(-) delete mode 100644 SCIKit/ErrorTypes.cxx delete mode 100644 SCIKit/ErrorTypes.hxx delete mode 100644 SCIKit/SCI.hxx create mode 100644 SCIKit/SCIBase.hxx create mode 100644 SCIKit/SCIErr.cxx create mode 100644 SCIKit/SCIErr.hxx create mode 100644 SCIKit/SCIObjRt.cxx diff --git a/SCIKit/ErrorTypes.cxx b/SCIKit/ErrorTypes.cxx deleted file mode 100644 index 7bd4146a..00000000 --- a/SCIKit/ErrorTypes.cxx +++ /dev/null @@ -1,9 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#include - -HError kLastError = 0; \ No newline at end of file diff --git a/SCIKit/ErrorTypes.hxx b/SCIKit/ErrorTypes.hxx deleted file mode 100644 index 35af4d64..00000000 --- a/SCIKit/ErrorTypes.hxx +++ /dev/null @@ -1,49 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies - -------------------------------------------- */ - -#pragma once - -#include - -#define ErrLocalIsOk() (kLastError == kErrorSuccess) -#define ErrLocalFailed() (kLastError != kErrorSuccess) -#define ErrLocal() (kLastError) - -typedef SInt32 HError; - -inline constexpr HError kErrorSuccess = 0; -inline constexpr HError kErrorExecutable = 33; -inline constexpr HError kErrorExecutableLib = 34; -inline constexpr HError kErrorFileNotFound = 35; -inline constexpr HError kErrorDirectoryNotFound = 36; -inline constexpr HError kErrorDiskReadOnly = 37; -inline constexpr HError kErrorDiskIsFull = 38; -inline constexpr HError kErrorProcessFault = 39; -inline constexpr HError kErrorSocketHangUp = 40; -inline constexpr HError kErrorThreadLocalStorage = 41; -inline constexpr HError kErrorMath = 42; -inline constexpr HError kErrorNoNetwork = 43; -inline constexpr HError kErrorHeapOutOfMemory = 44; -inline constexpr HError kErrorNoSuchDisk = 45; -inline constexpr HError kErrorFileExists = 46; -inline constexpr HError kErrorFormatFailed = 47; -inline constexpr HError kErrorNetworkTimeout = 48; -inline constexpr HError kErrorInternal = 49; -inline constexpr HError kErrorForkAlreadyExists = 50; -inline constexpr HError kErrorOutOfTeamSlot = 51; -inline constexpr HError kErrorHeapNotPresent = 52; -inline constexpr HError kErrorNoEntrypoint = 53; -inline constexpr HError kErrorDiskIsCorrupted = 54; -inline constexpr HError kErrorDisk = 55; -inline constexpr HError kErrorInvalidData = 56; -inline constexpr HError kErrorAsync = 57; -inline constexpr HError kErrorNonBlocking = 58; -inline constexpr HError kErrorIPC = 59; -inline constexpr HError kErrorSign = 60; -inline constexpr HError kErrorInvalidCreds = 61; -inline constexpr HError kErrorUnimplemented = 0; - -IMPORT_C HError kLastError; diff --git a/SCIKit/SCI.hxx b/SCIKit/SCI.hxx deleted file mode 100644 index 5f819ba1..00000000 --- a/SCIKit/SCI.hxx +++ /dev/null @@ -1,117 +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 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/SCIBase.hxx b/SCIKit/SCIBase.hxx new file mode 100644 index 00000000..6e389390 --- /dev/null +++ b/SCIKit/SCIBase.hxx @@ -0,0 +1,135 @@ +/* ------------------------------------------- + +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; + +inline constexpr auto cSerialAlertSyscall = 0x10; +inline constexpr auto cTlsSyscall = 0x11; +inline constexpr auto cTlsInstallSyscall = 0x12; +inline constexpr auto cNewSyscall = 0x13; +inline constexpr auto cDeleteSyscall = 0x14; +inline constexpr auto cExitSyscall = 0x15; +inline constexpr auto cLastExitSyscall = 0x16; +inline constexpr auto cCatalogOpenSyscall = 0x17; +inline constexpr auto cForkReadSyscall = 0x18; +inline constexpr auto cForkWriteSyscall = 0x19; +inline constexpr auto cCatalogCloseSyscall = 0x20; +inline constexpr auto cCatalogRemoveSyscall = 0x21; +inline constexpr auto cCatalogCreateSyscall = 0x22; +inline constexpr auto cRebootSyscallSyscall = 0x23; +inline constexpr auto cShutdownSyscall = 0x24; +inline constexpr auto cLPCSendMsgSyscall = 0x25; +inline constexpr auto cLPCOpenMsgSyscall = 0x26; +inline constexpr auto cLPCCloseMsgSyscall = 0x27; +inline constexpr auto cLPCSanitizeMsgSyscall = 0x28; + +#ifdef __NEWOS_SYMS__ +#include +#else +class UnknownInterface; // Refrenced from an IDB entry. +class UnknownUCLSID; // From the IDB, the constructor of the object, e.g: WordUCLSID. +class UUID; + +/// @brief Allocate new SCM class. +/// @tparam TCLS +/// @tparam UCLSID +/// @param uclsidOfCls +/// @return +template +TCLS* RtlQueryInterface(UCLSID uclsidOfCls, Args... args); + +/// @brief Release SCM class. +/// @tparam TCLS +/// @param cls +/// @return +template +SInt32 RtlReleaseClass(TCLS* cls); + +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; + + virtual SInt32 Release() = 0; + virtual void DecrementRef() = 0; + virtual UnknownInterface* IncrementRef() = 0; + virtual VoidPtr QueryInterface(UUID* p_uuid) = 0; +}; + +#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); + +IMPORT_C VoidPtr RtlGetDLLProcedure(const char* symbol, VoidPtr dll_handle); +IMPORT_C VoidPtr RtOpenDLL(const char* path); +IMPORT_C void RtCloseDLL(VoidPtr dll_handle); \ No newline at end of file diff --git a/SCIKit/SCIErr.cxx b/SCIKit/SCIErr.cxx new file mode 100644 index 00000000..4b145697 --- /dev/null +++ b/SCIKit/SCIErr.cxx @@ -0,0 +1,9 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#include + +NEW_ERROR_TYPE kLastError = 0; \ No newline at end of file diff --git a/SCIKit/SCIErr.hxx b/SCIKit/SCIErr.hxx new file mode 100644 index 00000000..3e9619fa --- /dev/null +++ b/SCIKit/SCIErr.hxx @@ -0,0 +1,49 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#pragma once + +#include + +#define ErrLocalIsOk() (kLastError == kErrorSuccess) +#define ErrLocalFailed() (kLastError != kErrorSuccess) +#define ErrLocal() (kLastError) + +typedef SInt32 NEW_ERROR_TYPE; + +inline constexpr NEW_ERROR_TYPE kErrorSuccess = 0; +inline constexpr NEW_ERROR_TYPE kErrorExecutable = 33; +inline constexpr NEW_ERROR_TYPE kErrorExecutableLib = 34; +inline constexpr NEW_ERROR_TYPE kErrorFileNotFound = 35; +inline constexpr NEW_ERROR_TYPE kErrorDirectoryNotFound = 36; +inline constexpr NEW_ERROR_TYPE kErrorDiskReadOnly = 37; +inline constexpr NEW_ERROR_TYPE kErrorDiskIsFull = 38; +inline constexpr NEW_ERROR_TYPE kErrorProcessFault = 39; +inline constexpr NEW_ERROR_TYPE kErrorSocketHangUp = 40; +inline constexpr NEW_ERROR_TYPE kErrorThreadLocalStorage = 41; +inline constexpr NEW_ERROR_TYPE kErrorMath = 42; +inline constexpr NEW_ERROR_TYPE kErrorNoNetwork = 43; +inline constexpr NEW_ERROR_TYPE kErrorHeapOutOfMemory = 44; +inline constexpr NEW_ERROR_TYPE kErrorNoSuchDisk = 45; +inline constexpr NEW_ERROR_TYPE kErrorFileExists = 46; +inline constexpr NEW_ERROR_TYPE kErrorFormatFailed = 47; +inline constexpr NEW_ERROR_TYPE kErrorNetworkTimeout = 48; +inline constexpr NEW_ERROR_TYPE kErrorInternal = 49; +inline constexpr NEW_ERROR_TYPE kErrorForkAlreadyExists = 50; +inline constexpr NEW_ERROR_TYPE kErrorOutOfTeamSlot = 51; +inline constexpr NEW_ERROR_TYPE kErrorHeapNotPresent = 52; +inline constexpr NEW_ERROR_TYPE kErrorNoEntrypoint = 53; +inline constexpr NEW_ERROR_TYPE kErrorDiskIsCorrupted = 54; +inline constexpr NEW_ERROR_TYPE kErrorDisk = 55; +inline constexpr NEW_ERROR_TYPE kErrorInvalidData = 56; +inline constexpr NEW_ERROR_TYPE kErrorAsync = 57; +inline constexpr NEW_ERROR_TYPE kErrorNonBlocking = 58; +inline constexpr NEW_ERROR_TYPE kErrorIPC = 59; +inline constexpr NEW_ERROR_TYPE kErrorSign = 60; +inline constexpr NEW_ERROR_TYPE kErrorInvalidCreds = 61; +inline constexpr NEW_ERROR_TYPE kErrorUnimplemented = 0; + +IMPORT_C NEW_ERROR_TYPE kLastError; diff --git a/SCIKit/SCIObjRt.cxx b/SCIKit/SCIObjRt.cxx new file mode 100644 index 00000000..c8c7300e --- /dev/null +++ b/SCIKit/SCIObjRt.cxx @@ -0,0 +1,8 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies + +------------------------------------------- */ + +#include +//#include \ No newline at end of file diff --git a/SCIKit/rtl.internal.inl b/SCIKit/rtl.internal.inl index b0b011cc..f22bc834 100644 --- a/SCIKit/rtl.internal.inl +++ b/SCIKit/rtl.internal.inl @@ -7,15 +7,38 @@ Purpose: Internal file for SCM. ------------------------------------------- */ + +// 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: TextUCLSID. +class UUID; + +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; + + virtual SInt32 Release() = 0; + virtual void DecrementRef() = 0; + virtual UnknownInterface* IncrementRef() = 0; + virtual VoidPtr QueryInterface(UUID* p_uuid) = 0; +}; + /// @brief Allocate new SCM class. /// @tparam TCLS /// @tparam UCLSID /// @param uclsidOfCls /// @return template -inline TCLS* RtlGetClassFromCLSID(UCLSID* uclsidOfCls, Args&&... args) +inline TCLS* RtlQueryInterface(UCLSID* uclsidOfCls, Args&&... args) { - return uclsidOfCls->QueryObjectWithArgs(args...); + return uclsidOfCls->QueryInterfaceWithArgs(args...); } /// @brief Release SCM class. @@ -25,6 +48,9 @@ inline TCLS* RtlGetClassFromCLSID(UCLSID* uclsidOfCls, Args&&... args) template inline SInt32 RtlReleaseClass(TCLS* cls) { + if (!cls) + return -1; + cls->DecrementRef(); cls->Release(); -- cgit v1.2.3