diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-19 22:50:16 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-03-19 22:50:16 +0100 |
| commit | a0f82d57976648c5bfcf165b2e304d2a4c8fb0c7 (patch) | |
| tree | c24cd3e850a9fc47b352ac8efa50a93b28388925 /Public/Kits/System.Core/HeapImpl.cxx | |
| parent | de413aa50bac1342e4ac8c7a66697ea3b551c2e4 (diff) | |
Kernel:Secret: Fix String class.
Improve kernel APIs.
Diffstat (limited to 'Public/Kits/System.Core/HeapImpl.cxx')
| -rw-r--r-- | Public/Kits/System.Core/HeapImpl.cxx | 68 |
1 files changed, 37 insertions, 31 deletions
diff --git a/Public/Kits/System.Core/HeapImpl.cxx b/Public/Kits/System.Core/HeapImpl.cxx index f41c868f..2980a3de 100644 --- a/Public/Kits/System.Core/HeapImpl.cxx +++ b/Public/Kits/System.Core/HeapImpl.cxx @@ -1,41 +1,47 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ #include <System.Core/Heap.hxx> -#include <System.Core/System.Core.hxx> -using namespace System; - -/// @brief Shared instance of the heap. +/// @brief Allocate from the user's heap. +/// @param refObj Process object. +/// @param sz size of object. +/// @param flags flags. /// @return -Heap* Heap::Shared() noexcept { - static Heap* heap = nullptr; - - if (!heap) { - heap = new Heap(); - } - - return heap; +CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, DWORD flags) +{ + CA_MUST_PASS(sz); + CA_MUST_PASS(flags); + + return (PVOID)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags); } -Heap::~Heap() { delete this; } - -void Heap::Delete(HeapPtr me) noexcept { - CA_MUST_PASS(me); - HcFreeProcessHeap(kInstanceObject, me); +/// @brief Free pointer from the user's heap. +/// @param refObj Process object. +/// @param ptr the pointer to free. +CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr) +{ + CA_MUST_PASS(ptr); + CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr)); } -SizeT Heap::Size(HeapPtr me) noexcept { - CA_MUST_PASS(me); - return HcProcessHeapSize(kInstanceObject, me); +/// @brief Get pointer size. +/// @param refObj Process object. +/// @param ptr the pointer to find. +/// @return the size. +CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr) +{ + CA_MUST_PASS(ptr); + return refObj->Invoke(refObj, kProcessCallSizePtr, ptr); } -HeapPtr Heap::New(const SizeT& sz, const Int32 flags) { - SizeT _sz = sz; - if (!_sz) ++_sz; - - return HcAllocateProcessHeap(kInstanceObject, _sz, flags); -}
\ No newline at end of file +/// @brief Check if the pointer exists. +/// @param refObj Process object. +/// @param ptr the pointer to check. +/// @return if it exists +CA_EXTERN_C BOOL HcProcessHeapExists(ObjectPtr refObj, PVOID ptr) +{ + CA_MUST_PASS(ptr); + return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr); +} |
