From e64ec7d2f44feb37b421fc1eda2fd430b1d882cb Mon Sep 17 00:00:00 2001 From: yellowsparkles584 <154008927+yellowsparkles584@users.noreply.github.com> Date: Sun, 26 Apr 2026 08:26:52 +0000 Subject: [PATCH] Dynamically detect 39-bit address space --- src/core/address_space.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/core/address_space.cpp b/src/core/address_space.cpp index 722761f6b..b34b3e10b 100644 --- a/src/core/address_space.cpp +++ b/src/core/address_space.cpp @@ -124,7 +124,8 @@ struct AddressSpace::Impl { RTL_OSVERSIONINFOW os_version_info{}; RtlGetVersion(&os_version_info); - u64 supported_user_max = USER_MAX; + const VAddr va_size = reinterpret_cast(sys_info.lpMaximumApplicationAddress); + u64 supported_user_max = va_size; // This is the build number for Windows 11 22H2 static constexpr s32 AffectedBuildNumber = 22621; @@ -144,7 +145,17 @@ struct AddressSpace::Impl { } // Determine the free address ranges we can access. + const bool is_39bit = va_size <= 0x7FFFFFFFFFULL; + VAddr next_addr = SYSTEM_MANAGED_MIN; + if (is_39bit) { + supported_user_max = 0x7000000000ULL; + LOG_WARNING( + Core, "39-bit address space detected, reducing user max to {:#x} to avoid problems", + supported_user_max); + next_addr = 0x80000000ULL; + } + MEMORY_BASIC_INFORMATION info{}; while (next_addr <= supported_user_max) { ASSERT_MSG(VirtualQuery(reinterpret_cast(next_addr), &info, sizeof(info)),