Merge pull request #323 from shadps4-emu/win-fix

address_space: Fix windows placeholder mapping
This commit is contained in:
georgemoralis 2024-07-25 12:15:25 +03:00 committed by GitHub
commit bc28ed66e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 8 deletions

View File

@ -59,11 +59,11 @@ struct AddressSpace::Impl {
static constexpr size_t MaxReductions = 10; static constexpr size_t MaxReductions = 10;
size_t reduction = 0; size_t reduction = 0;
size_t virtual_size = SystemManagedSize + SystemReservedSize + UserSize;
for (u32 i = 0; i < MaxReductions; i++) { for (u32 i = 0; i < MaxReductions; i++) {
req.LowestStartingAddress = reinterpret_cast<PVOID>(SYSTEM_MANAGED_MIN + reduction); virtual_base = static_cast<u8*>(VirtualAlloc2(process, NULL, virtual_size - reduction,
virtual_base = static_cast<u8*>(VirtualAlloc2( MEM_RESERVE | MEM_RESERVE_PLACEHOLDER,
process, NULL, SystemManagedSize + SystemReservedSize + UserSize - reduction, PAGE_NOACCESS, &param, 1));
MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, PAGE_NOACCESS, &param, 1));
if (virtual_base) { if (virtual_base) {
break; break;
} }
@ -92,9 +92,7 @@ struct AddressSpace::Impl {
const uintptr_t system_managed_addr = reinterpret_cast<uintptr_t>(system_managed_base); const uintptr_t system_managed_addr = reinterpret_cast<uintptr_t>(system_managed_base);
const uintptr_t system_reserved_addr = reinterpret_cast<uintptr_t>(system_reserved_base); const uintptr_t system_reserved_addr = reinterpret_cast<uintptr_t>(system_reserved_base);
const uintptr_t user_addr = reinterpret_cast<uintptr_t>(user_base); const uintptr_t user_addr = reinterpret_cast<uintptr_t>(user_base);
placeholders.insert({system_managed_addr, system_managed_addr + system_managed_size}); placeholders.insert({system_managed_addr, virtual_size - reduction});
placeholders.insert({system_reserved_addr, system_reserved_addr + system_reserved_size});
placeholders.insert({user_addr, user_addr + user_size});
// Allocate backing file that represents the total physical memory. // Allocate backing file that represents the total physical memory.
backing_handle = backing_handle =

View File

@ -22,7 +22,7 @@ constexpr VAddr CODE_BASE_OFFSET = 0x100000000ULL;
constexpr VAddr SYSTEM_MANAGED_MIN = 0x00000400000ULL; constexpr VAddr SYSTEM_MANAGED_MIN = 0x00000400000ULL;
constexpr VAddr SYSTEM_MANAGED_MAX = 0x07FFFFBFFFULL; constexpr VAddr SYSTEM_MANAGED_MAX = 0x07FFFFBFFFULL;
constexpr VAddr SYSTEM_RESERVED_MIN = 0x800000000ULL; constexpr VAddr SYSTEM_RESERVED_MIN = 0x07FFFFC000ULL;
#ifdef __APPLE__ #ifdef __APPLE__
// Can only comfortably reserve the first 0x7C0000000 of system reserved space. // Can only comfortably reserve the first 0x7C0000000 of system reserved space.
constexpr VAddr SYSTEM_RESERVED_MAX = 0xFBFFFFFFFULL; constexpr VAddr SYSTEM_RESERVED_MAX = 0xFBFFFFFFFULL;