This commit is contained in:
Antonio 2024-08-20 14:33:59 -04:00
parent 25d8f5e264
commit d768714a4a
1 changed files with 3 additions and 10 deletions

View File

@ -232,16 +232,9 @@ struct AddressSpace::Impl {
LOG_CRITICAL(Common_Memory, "Unsupported protection flag combination"); LOG_CRITICAL(Common_Memory, "Unsupported protection flag combination");
} }
const VAddr virtual_end = virtual_addr + size; DWORD old_flags{};
auto [it, end] = placeholders.equal_range({virtual_addr, virtual_end}); if (!VirtualProtect(reinterpret_cast<void*>(virtual_addr), size, new_flags, &old_flags)) {
while (it != end) { LOG_CRITICAL(Common_Memory, "Failed to change virtual memory protection");
const size_t offset = std::max(it->lower(), virtual_addr);
const size_t protect_length = std::min(it->upper(), virtual_end) - offset;
DWORD old_flags{};
if (!VirtualProtect(virtual_base + offset, protect_length, new_flags, &old_flags)) {
LOG_CRITICAL(Common_Memory, "Failed to change virtual memory protect rules");
}
++it;
} }
} }