feat(libkernel): accept MAP_NO_OVERWRITE fixed mappings on Windows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bn7CrhG7pTPR6DT13tN6Me
This commit is contained in:
SP4C3B4R-8
2026-10-01 23:44:31 +02:00
parent 3fc3b993da
commit 4099ffb7d3
2 changed files with 5 additions and 6 deletions
@@ -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);
+5 -2
View File
@@ -69,13 +69,16 @@ static void CheckNamedAndHintedMappings() {
Require(sceKernelMapFlexibleMemory(&hinted, length, 3, 0) == 0);
Require(hinted > first && (reinterpret_cast<std::uintptr_t>(hinted) & 0x3fff) == 0);
static_cast<volatile unsigned char*>(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<volatile unsigned char*>(exclusive)[0] = 1;
Require(sceKernelMunmap(exclusive, length) == 0);
Require(sceKernelMunmap(first, length) == 0);
}