Do not clear range if it was previously commited
This commit is contained in:
parent
be3fa2fc16
commit
1513a81a30
|
@ -140,6 +140,8 @@ dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
|
|||
uint32_t protect = FromXdkProtectFlags(protect_bits);
|
||||
uint32_t address = 0;
|
||||
BaseHeap* heap;
|
||||
HeapAllocationInfo prev_alloc_info = {};
|
||||
bool was_commited = false;
|
||||
|
||||
if (adjusted_base != 0) {
|
||||
heap = kernel_memory()->LookupHeap(adjusted_base);
|
||||
|
@ -147,6 +149,8 @@ dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
|
|||
// Specified the wrong page size for the wrong heap.
|
||||
return X_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
was_commited = heap->QueryRegionInfo(adjusted_base, &prev_alloc_info) &&
|
||||
(prev_alloc_info.state & kMemoryAllocationCommit) != 0;
|
||||
|
||||
if (heap->AllocFixed(adjusted_base, adjusted_size, page_size,
|
||||
allocation_type, protect)) {
|
||||
|
@ -171,7 +175,9 @@ dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
|
|||
kMemoryProtectRead | kMemoryProtectWrite);
|
||||
}
|
||||
|
||||
if (!was_commited) {
|
||||
kernel_memory()->Zero(address, adjusted_size);
|
||||
}
|
||||
|
||||
if (!(protect & kMemoryProtectWrite)) {
|
||||
heap->Protect(address, adjusted_size, protect);
|
||||
|
|
Loading…
Reference in New Issue