[Kernel] Ignore page size with base addr allocs.

Changes NtAllocateVirtualMemory so that it ignores specified page size when a
base address is specified.

Fixes a crash seen in N3 demo boot.
This commit is contained in:
gibbed 2019-08-24 09:48:27 -05:00 committed by Rick Gibbed
parent 96a7908c28
commit 74c95c64d2
1 changed files with 11 additions and 4 deletions

View File

@ -96,10 +96,17 @@ dword_result_t NtAllocateVirtualMemory(lpdword_t base_addr_ptr,
XELOGW("Game setting EXECUTE bit on allocation"); XELOGW("Game setting EXECUTE bit on allocation");
} }
// Adjust size. uint32_t page_size;
uint32_t page_size = 4096; if (*base_addr_ptr != 0) {
if (alloc_type & X_MEM_LARGE_PAGES) { // ignore specified page size when base address is specified.
page_size = 64 * 1024; auto heap = kernel_memory()->LookupHeap(*base_addr_ptr);
page_size = heap->page_size();
} else {
// Adjust size.
page_size = 4 * 1024;
if (alloc_type & X_MEM_LARGE_PAGES) {
page_size = 64 * 1024;
}
} }
// Round the base address down to the nearest page boundary. // Round the base address down to the nearest page boundary.