From e1e892782357a26f61ae4c28ec53963d495df70f Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 8 Aug 2024 18:03:22 -0400 Subject: [PATCH] '' --- src/core/address_space.cpp | 46 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/core/address_space.cpp b/src/core/address_space.cpp index 4ea9ca43..05aa6cbb 100644 --- a/src/core/address_space.cpp +++ b/src/core/address_space.cpp @@ -217,32 +217,32 @@ struct AddressSpace::Impl { } void Protect(VAddr virtual_addr, size_t size, bool read, bool write, bool execute) { - DWORD new_flags{}; - if (read && write && execute) { - new_flags = PAGE_EXECUTE_READWRITE; - } else if (read && write) { - new_flags = PAGE_READWRITE; - } else if (read && !write) { - new_flags = PAGE_READONLY; - } else if (execute && !read && !write) { - new_flags = PAGE_EXECUTE; - } else if (!read && !write && !execute) { - new_flags = PAGE_NOACCESS; - } else { - LOG_CRITICAL(Common_Memory, "Unsupported protection flag combination"); - } + DWORD new_flags{}; + if (read && write && execute) { + new_flags = PAGE_EXECUTE_READWRITE; + } else if (read && write) { + new_flags = PAGE_READWRITE; + } else if (read && !write) { + new_flags = PAGE_READONLY; + } else if (execute && !read && !write) { + new_flags = PAGE_EXECUTE; + } else if (!read && !write && !execute) { + new_flags = PAGE_NOACCESS; + } else { + LOG_CRITICAL(Common_Memory, "Unsupported protection flag combination"); + } const VAddr virtual_end = virtual_addr + size; - auto [it, end] = placeholders.equal_range({virtual_addr, virtual_end}); - while (it != end) { - 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"); + auto [it, end] = placeholders.equal_range({virtual_addr, virtual_end}); + while (it != end) { + 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; } - ++it; - } }