Memory: Fix virtualProtect protecting too much memory.

This commit is contained in:
vlj 2015-07-02 19:05:54 +02:00
parent 4a7f6af8d9
commit 972515938c
1 changed files with 2 additions and 2 deletions

View File

@ -425,10 +425,10 @@ namespace vm
DWORD old;
auto protection = f2 & page_writable ? PAGE_READWRITE : (f2 & page_readable ? PAGE_READONLY : PAGE_NOACCESS);
if (!VirtualProtect(real_addr, size, protection, &old))
if (!VirtualProtect(real_addr, 4096, protection, &old))
#else
auto protection = f2 & page_writable ? PROT_WRITE | PROT_READ : (f2 & page_readable ? PROT_READ : PROT_NONE);
if (mprotect(real_addr, size, protection))
if (mprotect(real_addr, 4096, protection))
#endif
{
throw fmt::format("vm::page_protect(addr=0x%x, size=0x%x, flags_test=0x%x, flags_set=0x%x, flags_clear=0x%x) failed (API)", addr, size, flags_test, flags_set, flags_clear);