mirror of https://github.com/x64dbg/GleeBug
Fix a dumb bug when setting memory breakpoints
This commit is contained in:
parent
2ee4dc0f83
commit
85846e4ed1
|
|
@ -225,6 +225,7 @@ namespace GleeBug
|
||||||
|
|
||||||
bool Process::SetNewPageProtection(ptr page, MemoryBreakpointData & data, MemoryType type)
|
bool Process::SetNewPageProtection(ptr page, MemoryBreakpointData & data, MemoryType type)
|
||||||
{
|
{
|
||||||
|
DPRINTF();
|
||||||
//TODO: handle PAGE_NOACCESS and such correctly (since it cannot be combined with PAGE_GUARD)
|
//TODO: handle PAGE_NOACCESS and such correctly (since it cannot be combined with PAGE_GUARD)
|
||||||
|
|
||||||
auto found = memoryBreakpointPages.find(page);
|
auto found = memoryBreakpointPages.find(page);
|
||||||
|
|
@ -261,11 +262,14 @@ namespace GleeBug
|
||||||
data.NewProtect = permanentDep ? RemoveExecuteAccess(RemoveWriteAccess(data.OldProtect)) : data.OldProtect | PAGE_GUARD;
|
data.NewProtect = permanentDep ? RemoveExecuteAccess(RemoveWriteAccess(data.OldProtect)) : data.OldProtect | PAGE_GUARD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dprintf("SetNewPageProtection(%p, %X)\n", page, data.NewProtect);
|
||||||
return MemProtect(page, PAGE_SIZE, data.NewProtect);
|
return MemProtect(page, PAGE_SIZE, data.NewProtect);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Process::SetMemoryBreakpoint(ptr address, ptr size, MemoryType type, bool singleshoot)
|
bool Process::SetMemoryBreakpoint(ptr address, ptr size, MemoryType type, bool singleshoot)
|
||||||
{
|
{
|
||||||
|
DPRINTF();
|
||||||
|
dprintf("SetMemoryBreakpoint(%p, %p, %d, %d)\n", address, size, type, singleshoot);
|
||||||
//TODO: error reporting
|
//TODO: error reporting
|
||||||
|
|
||||||
//basic checks
|
//basic checks
|
||||||
|
|
@ -292,18 +296,20 @@ namespace GleeBug
|
||||||
MemoryBreakpointData data;
|
MemoryBreakpointData data;
|
||||||
data.Type = uint32(type);
|
data.Type = uint32(type);
|
||||||
auto alignedAddress = PAGE_ALIGN(address);
|
auto alignedAddress = PAGE_ALIGN(address);
|
||||||
for (auto page = alignedAddress; page < alignedAddress + BYTES_TO_PAGES(size); page += PAGE_SIZE)
|
for (auto page = alignedAddress; page < alignedAddress + ROUND_TO_PAGES(size); page += PAGE_SIZE)
|
||||||
{
|
{
|
||||||
MEMORY_BASIC_INFORMATION mbi;
|
MEMORY_BASIC_INFORMATION mbi;
|
||||||
if (!VirtualQueryEx(hProcess, LPCVOID(page), &mbi, sizeof(mbi)))
|
if (!VirtualQueryEx(hProcess, LPCVOID(page), &mbi, sizeof(mbi)))
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
|
dprintf("!VirtualQueryEx\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
data.OldProtect = mbi.Protect;
|
data.OldProtect = mbi.Protect;
|
||||||
if (!SetNewPageProtection(page, data, type))
|
if (!SetNewPageProtection(page, data, type))
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
|
dprintf("!SetNewPageProtection\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tempData.addr = page;
|
tempData.addr = page;
|
||||||
|
|
@ -369,7 +375,7 @@ namespace GleeBug
|
||||||
//delete the memory breakpoint from the pages
|
//delete the memory breakpoint from the pages
|
||||||
bool success = true;
|
bool success = true;
|
||||||
auto alignedAddress = PAGE_ALIGN(info.address);
|
auto alignedAddress = PAGE_ALIGN(info.address);
|
||||||
for (auto page = alignedAddress; page < alignedAddress + BYTES_TO_PAGES(info.internal.memory.size); page += PAGE_SIZE)
|
for (auto page = alignedAddress; page < alignedAddress + ROUND_TO_PAGES(info.internal.memory.size); page += PAGE_SIZE)
|
||||||
{
|
{
|
||||||
auto foundData = memoryBreakpointPages.find(page);
|
auto foundData = memoryBreakpointPages.find(page);
|
||||||
if (foundData == memoryBreakpointPages.end())
|
if (foundData == memoryBreakpointPages.end())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue