diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-01 18:25:14 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-01 18:25:14 +0200 |
| commit | 86e291120d124dec7244202b1766901a59dfb2e6 (patch) | |
| tree | 1aa92d3b8a05216941986cf2724ff20ad01b3884 /Kernel/Sources/ProcessHeap.cxx | |
| parent | f9579f444b1791d2b73d4d841569728fb203cb29 (diff) | |
[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 <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/Sources/ProcessHeap.cxx')
| -rw-r--r-- | Kernel/Sources/ProcessHeap.cxx | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Kernel/Sources/ProcessHeap.cxx b/Kernel/Sources/ProcessHeap.cxx index 414cd934..fe54be4b 100644 --- a/Kernel/Sources/ProcessHeap.cxx +++ b/Kernel/Sources/ProcessHeap.cxx @@ -92,19 +92,35 @@ namespace Kernel /// @return VoidPtr the heap pointer. STATIC VoidPtr ke_find_unused_heap(Int32 flags) { - for (SizeT index = 0; index < kUserHeapMaxSz; ++index) + SizeT index = 0UL; + + while (true) { + /* ************************************ */ + /* allocate if it doesnt exist. */ + /* ************************************ */ + if (!ProcessHeapHelper::The()[index]) + { + ProcessHeapHelper::The().Add(Kernel::Ref<Kernel::PTEWrapper>()); + } + if (ProcessHeapHelper::The()[index] && !ProcessHeapHelper::The()[index].Leak().Leak().Present()) { ProcessHeapHelper::Leak().Leak().TogglePresent( ProcessHeapHelper::The()[index].Leak().Leak(), true); + + ProcessHeapHelper::Leak().Leak().ToggleUser( + ProcessHeapHelper::The()[index].Leak().Leak(), true); + kcout << "[ke_find_unused_heap] Done, trying to make a pool now...\r"; return ke_make_heap_internal( (VoidPtr)ProcessHeapHelper::The()[index].Leak().Leak().VirtualAddress(), flags); } + + ++index; } return nullptr; @@ -131,7 +147,8 @@ namespace Kernel poolHdr->fMagic = kUserHeapMag; poolHdr->fFree = false; - kcout << "[ke_make_heap_internal] New allocation has been done.\n"; + kcout << "[ke_make_heap_internal] New allocation has been done, returning new chunk.\n"; + return reinterpret_cast<VoidPtr>( (reinterpret_cast<UIntPtr>(virtualAddress) + sizeof(PROCESS_HEAP_HEADER))); } @@ -204,9 +221,6 @@ namespace Kernel if (!ProcessHeapHelper::IsEnabled()) return nullptr; - if (ProcessHeapHelper::Count() > kUserHeapMaxSz) - return nullptr; - if (VoidPtr ret = ke_find_unused_heap(flags)) return ret; @@ -245,7 +259,7 @@ namespace Kernel if (ke_check_and_free_heap(base, ptr)) return 0; - for (SizeT index = 0; index < kUserHeapMaxSz; ++index) + for (SizeT index = 0; index < ProcessHeapHelper::The().Count(); ++index) { if (ke_check_and_free_heap(index, ptr)) return 0; |
