Bug 1201205 part 2: Restore protection on the nop space separately from the function. r=m_kato

This commit is contained in:
David Major 2015-09-04 14:24:05 -04:00
parent ec23b6de3f
commit 0187e37a6b

View File

@ -169,9 +169,10 @@ public:
// Ensure we can read and write starting at fn - 5 (for the long jmp we're
// going to write) and ending at fn + 2 (for the short jmp up to the long
// jmp).
AutoVirtualProtect protect(fn - 5, 7, PAGE_EXECUTE_READWRITE);
if (!protect.Protect()) {
// jmp). These bytes may span two pages with different protection.
AutoVirtualProtect protectBefore(fn - 5, 5, PAGE_EXECUTE_READWRITE);
AutoVirtualProtect protectAfter(fn, 2, PAGE_EXECUTE_READWRITE);
if (!protectBefore.Protect() || !protectAfter.Protect()) {
//printf ("VirtualProtectEx failed! %d\n", GetLastError());
return false;
}