[Memory] Added check to prevent crashes when title tries to get access to unavailable range

This commit is contained in:
Gliniak 2023-10-21 10:12:48 +02:00
parent d532d8eb61
commit d84df6e47f
1 changed files with 7 additions and 0 deletions

View File

@ -108,6 +108,13 @@ dword_result_t NtAllocateVirtualMemory_entry(lpdword_t base_addr_ptr,
if (*base_addr_ptr != 0) { if (*base_addr_ptr != 0) {
// ignore specified page size when base address is specified. // ignore specified page size when base address is specified.
auto heap = kernel_memory()->LookupHeap(*base_addr_ptr); auto heap = kernel_memory()->LookupHeap(*base_addr_ptr);
// Edge case when title can check for XPS/MMIO range and will receive
// nullptr.
if (!heap) {
// Code returned in this case is unknown but probably this one.
return X_STATUS_INVALID_PARAMETER;
}
if (heap->heap_type() != HeapType::kGuestVirtual) { if (heap->heap_type() != HeapType::kGuestVirtual) {
return X_STATUS_INVALID_PARAMETER; return X_STATUS_INVALID_PARAMETER;
} }