mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user