memoryblock - don't actually call VirtualProtect() if Protect() is called while !Active

This commit is contained in:
nattthebear 2016-03-26 11:38:08 -04:00
parent 12d802c03a
commit 948e75c59e
1 changed files with 8 additions and 3 deletions

View File

@ -270,9 +270,14 @@ namespace BizHawk.Emulation.Cores
for (int i = pstart; i <= pend; i++)
_pageData[i] = prot; // also store the value for later use
Kernel32.MemoryProtection old;
if (!Kernel32.VirtualProtect(Z.UU(start), Z.UU(length), p, out old))
throw new InvalidOperationException("VirtualProtect() returned FALSE!");
if (Active) // it's legal to Protect() if we're not active; the information is just saved for the next activation
{
// TODO: if using another OS's memory protection calls, they must give the same non-aligned behavior
// as VirtualProtect, or this must be changed
Kernel32.MemoryProtection old;
if (!Kernel32.VirtualProtect(Z.UU(start), Z.UU(length), p, out old))
throw new InvalidOperationException("VirtualProtect() returned FALSE!");
}
}
public void Dispose()