Restrict NtVirtualMemory only to virtual memory range
This commit is contained in:
parent
801f4c2232
commit
ed3512177c
|
@ -109,6 +109,9 @@ dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
|
|||
if (*base_addr_ptr != 0) {
|
||||
// ignore specified page size when base address is specified.
|
||||
auto heap = kernel_memory()->LookupHeap(*base_addr_ptr);
|
||||
if (heap->heap_type() != HeapType::kGuestVirtual) {
|
||||
return X_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
page_size = heap->page_size();
|
||||
} else {
|
||||
// Adjust size.
|
||||
|
@ -204,7 +207,9 @@ dword_result_t NtProtectVirtualMemory(lpdword_t base_addr_ptr,
|
|||
}
|
||||
|
||||
auto heap = kernel_memory()->LookupHeap(*base_addr_ptr);
|
||||
|
||||
if (heap->heap_type() != HeapType::kGuestVirtual) {
|
||||
return X_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
// Adjust the base downwards to the nearest page boundary.
|
||||
uint32_t adjusted_base =
|
||||
*base_addr_ptr - (*base_addr_ptr % heap->page_size());
|
||||
|
@ -256,6 +261,9 @@ dword_result_t NtFreeVirtualMemory(lpdword_t base_addr_ptr,
|
|||
}
|
||||
|
||||
auto heap = kernel_state()->memory()->LookupHeap(base_addr_value);
|
||||
if (heap->heap_type() != HeapType::kGuestVirtual) {
|
||||
return X_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
bool result = false;
|
||||
if (free_type == X_MEM_DECOMMIT) {
|
||||
// If zero, we may need to query size (free whole region).
|
||||
|
|
Loading…
Reference in New Issue