[Kernel/Memory] Restrict NtVirtualMemory only to virtual memory range
This commit is contained in:
@@ -101,6 +101,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.
|
||||
@@ -192,7 +195,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());
|
||||
@@ -240,6 +245,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).
|
||||
|
||||
Reference in New Issue
Block a user