diff options
Diffstat (limited to 'Public')
| -rw-r--r-- | Public/Kits/System.Core/Defs.hxx | 20 | ||||
| -rw-r--r-- | Public/Kits/System.Core/HCoreHeap+Impl.cxx | 44 | ||||
| -rw-r--r-- | Public/Kits/System.Core/HCoreHeap_ObjectAPI.cxx | 27 | ||||
| -rw-r--r-- | Public/Kits/System.Core/Heap+Impl.cxx (renamed from Public/Kits/System.Core/Heap.cxx) | 1 | ||||
| -rw-r--r-- | Public/Kits/System.Core/ReadMe.md | 10 | ||||
| -rw-r--r-- | Public/Kits/System.Core/RuntimeInit.cxx | 12 | ||||
| -rw-r--r-- | Public/Kits/System.Core/Threading.hxx | 9 |
7 files changed, 80 insertions, 43 deletions
diff --git a/Public/Kits/System.Core/Defs.hxx b/Public/Kits/System.Core/Defs.hxx index d1e5d483..bcb3585c 100644 --- a/Public/Kits/System.Core/Defs.hxx +++ b/Public/Kits/System.Core/Defs.hxx @@ -14,7 +14,7 @@ #undef CA_MUST_PASS #endif -#include <ObjectKit/Object.hxx> +#include <ObjectKit/ObjectKit.hxx> #ifdef _DEBUG #define CA_MUST_PASS(e) { if (!e) { __assert_chk_fail() } } @@ -97,15 +97,15 @@ typedef bool BOOL; CA_INLINE ObjectPtr kInstanceObject; -enum { - kProcessHeapCallAlloc = 1, - kProcessHeapCallFree, - kProcessHeapCallSize, - kProcessHeapCallCheck, - kProcessHeapCallAllocStack, - kProcessHeapCallOpenHandle, - kProcessHeapCallCloseHandle, - kProcessHeapCallsCnt, +enum HcProcessCall { + kProcessCallAllocPtr = 1, + kProcessCallFreePtr, + kProcessCallSizePtr, + kProcessCallCheckPtr, + kProcessCallAllocStack, + kProcessCallOpenHandle, + kProcessCallCloseHandle, + kProcessCallsCount = 7, }; #include <System.Core/HintBase.hxx> diff --git a/Public/Kits/System.Core/HCoreHeap+Impl.cxx b/Public/Kits/System.Core/HCoreHeap+Impl.cxx new file mode 100644 index 00000000..0e1b1732 --- /dev/null +++ b/Public/Kits/System.Core/HCoreHeap+Impl.cxx @@ -0,0 +1,44 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#include <System.Core/HCoreHeap.hxx> + +/// @brief Allocate from the user's heap. +/// @param refObj +/// @param sz +/// @param flags +/// @return +CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, DWORD flags) +{ + return (PVOID)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags); +} + +/// @brief Free pointer from the user's heap. +/// @param refObj +/// @param ptr +/// @return +CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr) +{ + CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr)); +} + +/// @brief Get pointer size. +/// @param refObj +/// @param ptr +/// @return +CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr) +{ + return refObj->Invoke(refObj, kProcessCallSizePtr, ptr); +} + +/// @brief Check if the pointer exists. +/// @param refObj Process object. +/// @param ptr +/// @return +CA_EXTERN_C QWORD HcProcessHeapExists(ObjectPtr refObj, PVOID ptr) +{ + return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr); +} + +// EOF. diff --git a/Public/Kits/System.Core/HCoreHeap_ObjectAPI.cxx b/Public/Kits/System.Core/HCoreHeap_ObjectAPI.cxx deleted file mode 100644 index 86b2bf47..00000000 --- a/Public/Kits/System.Core/HCoreHeap_ObjectAPI.cxx +++ /dev/null @@ -1,27 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#include <System.Core/HCoreHeap.hxx> - -CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, DWORD flags) -{ - return (PVOID)refObj->Invoke(refObj, kProcessHeapCallAlloc, sz, flags); -} - -CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr) -{ - CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessHeapCallFree, ptr)); -} - -CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr) -{ - return refObj->Invoke(refObj, kProcessHeapCallSize, ptr); -} - -CA_EXTERN_C QWORD HcProcessHeapExists(ObjectPtr refObj, PVOID ptr) -{ - return refObj->Invoke(refObj, kProcessHeapCallCheck, ptr); -} - -// eof. diff --git a/Public/Kits/System.Core/Heap.cxx b/Public/Kits/System.Core/Heap+Impl.cxx index aaac37a8..e3dcb11c 100644 --- a/Public/Kits/System.Core/Heap.cxx +++ b/Public/Kits/System.Core/Heap+Impl.cxx @@ -14,7 +14,6 @@ Heap* Heap::Shared() noexcept { if (!heap) { heap = new Heap(); - kInstanceObject = HcGetProcessObject(); } return heap; diff --git a/Public/Kits/System.Core/ReadMe.md b/Public/Kits/System.Core/ReadMe.md new file mode 100644 index 00000000..92bfca25 --- /dev/null +++ b/Public/Kits/System.Core/ReadMe.md @@ -0,0 +1,10 @@ +# System.Core +## Core System API. + +Currently contains: +- System Call Interface. +- Heap API. +- System Heap API. +- File API. +- Core functions and data types. +- System Threading API.
\ No newline at end of file diff --git a/Public/Kits/System.Core/RuntimeInit.cxx b/Public/Kits/System.Core/RuntimeInit.cxx new file mode 100644 index 00000000..b6022bef --- /dev/null +++ b/Public/Kits/System.Core/RuntimeInit.cxx @@ -0,0 +1,12 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#include <System.Core/HCoreHeap.hxx> + +/// @brief Inits the C runtime +/// @return if it was succesful or not. +DWORD HcInitRuntime(VOID) { + kInstanceObject = HcGetProcessObject(); + return 0; +}
\ No newline at end of file diff --git a/Public/Kits/System.Core/Threading.hxx b/Public/Kits/System.Core/Threading.hxx index 5d5ed0a6..bddbbf3f 100644 --- a/Public/Kits/System.Core/Threading.hxx +++ b/Public/Kits/System.Core/Threading.hxx @@ -14,17 +14,16 @@ #include <System.Core/Defs.hxx> /// @brief Thread Information Block variant for scheduling. -struct ThreadInformationBlock final { - const CHAR Name[255]; // Module Name +struct PACKED ThreadInformationBlock final { const UINT_PTR StartAddress; // Start Address const UINT_PTR StartHeap; // Allocation Heap const UINT_PTR StartStack; // Stack Pointer. - const DWORD Arch; // Architecture and/or platform. - const WORD TID; // Execution Thread ID. + const WORD ThreadID; // Execution Thread ID. }; ThreadInformationBlock* HcCreateThread(_Input PVOID Start, - _Optional _InOut PVOID HeapOpt, _Optional _InOut PVOID StackOpt); + _Optional _InOut PVOID HeapOpt, + _Optional _InOut PVOID StackOpt); BOOL HcDestroyThread(_Input ThreadInformationBlock* TIB); |
