From 4099ffb7d3b9b7e39bf88601ddbbf9290c553b2f Mon Sep 17 00:00:00 2001 From: SP4C3B4R-8 <209078228+SP4C3B4R-8@users.noreply.github.com> Date: Thu, 1 Oct 2026 23:44:31 +0200 Subject: [PATCH] feat(libkernel): accept MAP_NO_OVERWRITE fixed mappings on Windows Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Bn7CrhG7pTPR6DT13tN6Me --- core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp | 4 ---- core/libs/tests/GuestMemory.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp b/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp index f788621df..6187e79d0 100644 --- a/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp +++ b/core/libs/prx/libkernel/DirectMemory/DirectMemory.cpp @@ -389,11 +389,7 @@ void* MapPlaced(void* addr, size_t len, int prot, int flags, size_t alignment) { constexpr int GuestMapFixed = 0x10; constexpr int GuestMapNoOverwrite = 0x80; constexpr int GuestMapNoCoalesce = 0x400000; -#if defined(__linux__) constexpr int SupportedFlags = GuestMapFixed | GuestMapNoOverwrite | GuestMapNoCoalesce; -#else - constexpr int SupportedFlags = GuestMapFixed | GuestMapNoCoalesce; -#endif if ((flags & ~SupportedFlags) != 0) { char message[64]; std::snprintf(message, sizeof(message), "Unsupported memory mapping flags 0x%x", flags); diff --git a/core/libs/tests/GuestMemory.cpp b/core/libs/tests/GuestMemory.cpp index bb7c811c8..b84537b50 100644 --- a/core/libs/tests/GuestMemory.cpp +++ b/core/libs/tests/GuestMemory.cpp @@ -69,13 +69,16 @@ static void CheckNamedAndHintedMappings() { Require(sceKernelMapFlexibleMemory(&hinted, length, 3, 0) == 0); Require(hinted > first && (reinterpret_cast(hinted) & 0x3fff) == 0); static_cast(hinted)[length - 1] = 1; -#if defined(__linux__) bool rejected = false; void* overwrite = first; try { sceKernelMapFlexibleMemory(&overwrite, 0x4000, 3, 0x90); } catch (const std::exception&) { rejected = true; } Require(rejected && overwrite == first); -#endif Require(sceKernelMunmap(hinted, length) == 0); + void* exclusive = hinted; + Require(sceKernelMapFlexibleMemory(&exclusive, length, 3, 0x90) == 0); + Require(exclusive == hinted); + static_cast(exclusive)[0] = 1; + Require(sceKernelMunmap(exclusive, length) == 0); Require(sceKernelMunmap(first, length) == 0); }