mirror of https://github.com/x64dbg/GleeBug
track deleted breakpoints to handle stale events safely
This commit is contained in:
parent
552aa92637
commit
1533cc3e84
|
|
@ -21,17 +21,14 @@ namespace GleeBug
|
|||
}
|
||||
else
|
||||
{
|
||||
//check if this was a deleted breakpoint
|
||||
//if the byte at the exception address is not 0xCC, our breakpoint was deleted
|
||||
//and we should set IP back and continue execution
|
||||
uint8 currentByte = 0xCC;
|
||||
if(mThread && mProcess->MemReadUnsafe(exceptionAddress, ¤tByte, 1) && currentByte != 0xCC)
|
||||
//check if this address had a breakpoint that was recently deleted
|
||||
auto& deletedBps = mProcess->recentlyDeletedSwbp;
|
||||
auto foundIt = std::find(deletedBps.begin(), deletedBps.end(), exceptionAddress);
|
||||
if(foundIt != deletedBps.end() && mThread)
|
||||
{
|
||||
//this was our deleted breakpoint, set IP back and continue
|
||||
Registers(mThread->hThread, CONTEXT_CONTROL).Gip = exceptionAddress;
|
||||
mContinueStatus = DBG_CONTINUE;
|
||||
}
|
||||
//else: byte is 0xCC, this is a real int3 in original code, let debuggee handle it
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ namespace GleeBug
|
|||
IsDbgReplyLaterSupported = mSafeStep;
|
||||
}
|
||||
|
||||
uint32 consecutiveTimeouts = 0;
|
||||
|
||||
while(!mBreakDebugger)
|
||||
{
|
||||
//wait for a debug event
|
||||
|
|
@ -65,11 +67,18 @@ namespace GleeBug
|
|||
#endif
|
||||
else
|
||||
{
|
||||
// Regular timeout, wait again
|
||||
//after 2 consecutive timeouts, clear recently deleted breakpoints
|
||||
//any stale events would have been delivered by now
|
||||
consecutiveTimeouts++;
|
||||
if(consecutiveTimeouts >= 2 && mProcess)
|
||||
mProcess->recentlyDeletedSwbp.clear();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//event received, reset timeout counter
|
||||
consecutiveTimeouts = 0;
|
||||
|
||||
// Handle safe stepping
|
||||
if(IsDbgReplyLaterSupported)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ namespace GleeBug
|
|||
return false;
|
||||
FlushInstructionCache(hProcess, nullptr, 0);
|
||||
|
||||
recentlyDeletedSwbp.push_back(address);
|
||||
|
||||
//remove the breakpoint from the maps
|
||||
softwareBreakpointReferences.erase(info.address);
|
||||
breakpoints.erase(found);
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ namespace GleeBug
|
|||
MemoryBreakpointSet memoryBreakpointRanges;
|
||||
MemoryBreakpointMap memoryBreakpointPages;
|
||||
|
||||
std::vector<ptr> recentlyDeletedSwbp;
|
||||
|
||||
/**
|
||||
\brief Constructor.
|
||||
\param hProcess Process handle.
|
||||
|
|
|
|||
Loading…
Reference in New Issue