Merge pull request #30 from rafaelrfreitas/fix-writeonly-mem-bps

fix: ensure write-only breakpoints trigger on Copy-on-Write pages
This commit is contained in:
Duncan Ogilvie 2026-03-28 14:35:33 +01:00 committed by GitHub
commit 1232bce7f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -251,13 +251,17 @@ DWORD GetPageProtectionForMemoryBreakpoint(const MemoryBreakpointPageDetail & pa
if(page.writeBps > 0) if(page.writeBps > 0)
{ {
// Remove write access e.g. PAGE_EXECUTE_READWRITE => PAGE_EXECUTE // Remove write access (and copy-on-write) e.g. PAGE_EXECUTE_READWRITE => PAGE_EXECUTE
DWORD dwBase = newProtect & 0xFF; DWORD dwBase = newProtect & 0xFF;
switch(dwBase) switch(dwBase)
{ {
case PAGE_READWRITE: case PAGE_READWRITE:
case PAGE_WRITECOPY:
newProtect = (newProtect & 0xFFFFFF00) | PAGE_READONLY;
break;
case PAGE_EXECUTE_READWRITE: case PAGE_EXECUTE_READWRITE:
newProtect = (newProtect & 0xFFFFFF00) | (dwBase >> 1); case PAGE_EXECUTE_WRITECOPY:
newProtect = (newProtect & 0xFFFFFF00) | PAGE_EXECUTE_READ;
break; break;
} }
} }