MapViewOfFile3 fails on PAGE_NOACCESS (#4392)

This commit is contained in:
Sam Kenny 2026-05-11 14:26:53 +10:00 committed by GitHub
parent 1409b26e50
commit 201aaf232b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -257,9 +257,20 @@ struct AddressSpace::Impl {
ret = VirtualProtect(ptr, size, prot, &resultvar); ret = VirtualProtect(ptr, size, prot, &resultvar);
ASSERT_MSG(ret, "VirtualProtect failed. {}", Common::GetLastErrorMsg()); ASSERT_MSG(ret, "VirtualProtect failed. {}", Common::GetLastErrorMsg());
} else { } else {
ptr = MapViewOfFile3(backing, process, reinterpret_cast<PVOID>(virtual_addr), if (prot == PAGE_NOACCESS) {
phys_addr, size, MEM_REPLACE_PLACEHOLDER, prot, nullptr, 0); DWORD resultvar;
ASSERT_MSG(ptr, "MapViewOfFile3 failed. {}", Common::GetLastErrorMsg()); ptr = MapViewOfFile3(backing, process, reinterpret_cast<PVOID>(virtual_addr),
phys_addr, size, MEM_REPLACE_PLACEHOLDER, PAGE_READWRITE,
nullptr, 0);
ASSERT_MSG(ptr, "MapViewOfFile3 failed. {}", Common::GetLastErrorMsg());
bool ret = VirtualProtect(ptr, size, prot, &resultvar);
ASSERT_MSG(ret, "VirtualProtect failed. {}", Common::GetLastErrorMsg());
} else {
ptr =
MapViewOfFile3(backing, process, reinterpret_cast<PVOID>(virtual_addr),
phys_addr, size, MEM_REPLACE_PLACEHOLDER, prot, nullptr, 0);
ASSERT_MSG(ptr, "MapViewOfFile3 failed. {}", Common::GetLastErrorMsg());
}
} }
} else { } else {
ptr = ptr =