From ba60b94c7df198a7eb991863cd3ee097abf89776 Mon Sep 17 00:00:00 2001 From: Gliniak Date: Tue, 8 Mar 2022 09:04:14 +0100 Subject: [PATCH] Round size to 64k for allocations without base address --- src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc b/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc index 6f535b050..c21d88517 100644 --- a/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc +++ b/src/xenia/kernel/xboxkrnl/xboxkrnl_memory.cc @@ -120,7 +120,8 @@ dword_result_t NtAllocateVirtualMemory_entry(lpdword_t base_addr_ptr, uint32_t adjusted_size = int32_t(*region_size_ptr) < 0 ? -int32_t(region_size_ptr.value()) : region_size_ptr.value(); - adjusted_size = xe::round_up(adjusted_size, page_size); + + adjusted_size = xe::round_up(adjusted_size, adjusted_base ? page_size : 64 * 1024); // Allocate. uint32_t allocation_type = 0; @@ -207,7 +208,7 @@ dword_result_t NtProtectVirtualMemory_entry(lpdword_t base_addr_ptr, if (protect_bits & (X_PAGE_EXECUTE | X_PAGE_EXECUTE_READ | X_PAGE_EXECUTE_READWRITE | X_PAGE_EXECUTE_WRITECOPY)) { XELOGW("Game setting EXECUTE bit on protect"); - return X_STATUS_ACCESS_DENIED; + return X_STATUS_INVALID_PAGE_PROTECTION; } auto heap = kernel_memory()->LookupHeap(*base_addr_ptr);