Set PEB64/32 HeapSegmentReserve & HeapSegmentCommit from Executable. (#682)

This commit is contained in:
Maurice Heumann
2026-01-04 22:33:35 +01:00
committed by GitHub
2 changed files with 8 additions and 8 deletions

View File

@@ -586,10 +586,10 @@ typedef struct _PEB64
ULONG NtGlobalFlag; ULONG NtGlobalFlag;
ULARGE_INTEGER CriticalSectionTimeout; ULARGE_INTEGER CriticalSectionTimeout;
EMULATOR_CAST(std::int64_t, SIZE_T) HeapSegmentReserve; EMULATOR_CAST(std::uint64_t, SIZE_T) HeapSegmentReserve;
EMULATOR_CAST(std::int64_t, SIZE_T) HeapSegmentCommit; EMULATOR_CAST(std::uint64_t, SIZE_T) HeapSegmentCommit;
EMULATOR_CAST(std::int64_t, SIZE_T) HeapDeCommitTotalFreeThreshold; EMULATOR_CAST(std::uint64_t, SIZE_T) HeapDeCommitTotalFreeThreshold;
EMULATOR_CAST(std::int64_t, SIZE_T) HeapDeCommitFreeBlockThreshold; EMULATOR_CAST(std::uint64_t, SIZE_T) HeapDeCommitFreeBlockThreshold;
ULONG NumberOfHeaps; ULONG NumberOfHeaps;
ULONG MaximumNumberOfHeaps; ULONG MaximumNumberOfHeaps;

View File

@@ -266,8 +266,8 @@ void process_context::setup(x86_64_emulator& emu, memory_manager& memory, regist
p.ProcessHeap = 0; p.ProcessHeap = 0;
p.ProcessHeaps = 0; p.ProcessHeaps = 0;
p.HeapSegmentReserve = 0x0000000000100000; // TODO: Read from executable p.HeapSegmentReserve = executable.size_of_heap_reserve;
p.HeapSegmentCommit = 0x0000000000002000; p.HeapSegmentCommit = executable.size_of_heap_commit;
p.HeapDeCommitTotalFreeThreshold = 0x0000000000010000; p.HeapDeCommitTotalFreeThreshold = 0x0000000000010000;
p.HeapDeCommitFreeBlockThreshold = 0x0000000000001000; p.HeapDeCommitFreeBlockThreshold = 0x0000000000001000;
p.NumberOfHeaps = 0x00000000; p.NumberOfHeaps = 0x00000000;
@@ -357,8 +357,8 @@ void process_context::setup(x86_64_emulator& emu, memory_manager& memory, regist
// Copy similar settings from PEB64 // Copy similar settings from PEB64
p32.ProcessHeap = 0; p32.ProcessHeap = 0;
p32.ProcessHeaps = 0; p32.ProcessHeaps = 0;
p32.HeapSegmentReserve = 0x00100000; p32.HeapSegmentReserve = static_cast<uint32_t>(executable.size_of_heap_reserve);
p32.HeapSegmentCommit = 0x00002000; p32.HeapSegmentCommit = static_cast<uint32_t>(executable.size_of_heap_commit);
p32.HeapDeCommitTotalFreeThreshold = 0x00010000; p32.HeapDeCommitTotalFreeThreshold = 0x00010000;
p32.HeapDeCommitFreeBlockThreshold = 0x00001000; p32.HeapDeCommitFreeBlockThreshold = 0x00001000;
p32.NumberOfHeaps = 0; p32.NumberOfHeaps = 0;