From 95f66412b6ed64c411ecf2b55f55e3cf63d2c2f4 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 13 Apr 2026 15:11:09 +0200 Subject: [PATCH] Fix cross-page memory breakpoint page tracking --- GleeBug/Debugger.Process.Breakpoint.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/GleeBug/Debugger.Process.Breakpoint.cpp b/GleeBug/Debugger.Process.Breakpoint.cpp index c04e328..bb11f5c 100644 --- a/GleeBug/Debugger.Process.Breakpoint.cpp +++ b/GleeBug/Debugger.Process.Breakpoint.cpp @@ -298,12 +298,13 @@ namespace GleeBug }; std::vector breakpointData; { - breakpointData.reserve(size / PAGE_SIZE); + breakpointData.reserve(BYTES_TO_PAGES((address - PAGE_ALIGN(address)) + size)); TempMemoryBreakpointData tempData; MemoryBreakpointData data; data.Type = uint32(type); auto alignedAddress = PAGE_ALIGN(address); - for(auto page = alignedAddress; page < alignedAddress + ROUND_TO_PAGES(size); page += PAGE_SIZE) + auto alignedEnd = PAGE_ALIGN(address + size - 1); + for(auto page = alignedAddress; page <= alignedEnd; page += PAGE_SIZE) { MEMORY_BASIC_INFORMATION mbi; if(!VirtualQueryEx(hProcess, LPCVOID(page), &mbi, sizeof(mbi))) @@ -382,7 +383,8 @@ namespace GleeBug //delete the memory breakpoint from the pages bool success = true; auto alignedAddress = PAGE_ALIGN(info.address); - for(auto page = alignedAddress; page < alignedAddress + ROUND_TO_PAGES(info.internal.memory.size); page += PAGE_SIZE) + auto alignedEnd = PAGE_ALIGN(info.address + info.internal.memory.size - 1); + for(auto page = alignedAddress; page <= alignedEnd; page += PAGE_SIZE) { auto foundData = memoryBreakpointPages.find(page); if(foundData == memoryBreakpointPages.end())