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
|
else
|
||||||
{
|
{
|
||||||
//check if this was a deleted breakpoint
|
//check if this address had a breakpoint that was recently deleted
|
||||||
//if the byte at the exception address is not 0xCC, our breakpoint was deleted
|
auto& deletedBps = mProcess->recentlyDeletedSwbp;
|
||||||
//and we should set IP back and continue execution
|
auto foundIt = std::find(deletedBps.begin(), deletedBps.end(), exceptionAddress);
|
||||||
uint8 currentByte = 0xCC;
|
if(foundIt != deletedBps.end() && mThread)
|
||||||
if(mThread && mProcess->MemReadUnsafe(exceptionAddress, ¤tByte, 1) && currentByte != 0xCC)
|
|
||||||
{
|
{
|
||||||
//this was our deleted breakpoint, set IP back and continue
|
|
||||||
Registers(mThread->hThread, CONTEXT_CONTROL).Gip = exceptionAddress;
|
Registers(mThread->hThread, CONTEXT_CONTROL).Gip = exceptionAddress;
|
||||||
mContinueStatus = DBG_CONTINUE;
|
mContinueStatus = DBG_CONTINUE;
|
||||||
}
|
}
|
||||||
//else: byte is 0xCC, this is a real int3 in original code, let debuggee handle it
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ namespace GleeBug
|
||||||
IsDbgReplyLaterSupported = mSafeStep;
|
IsDbgReplyLaterSupported = mSafeStep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32 consecutiveTimeouts = 0;
|
||||||
|
|
||||||
while(!mBreakDebugger)
|
while(!mBreakDebugger)
|
||||||
{
|
{
|
||||||
//wait for a debug event
|
//wait for a debug event
|
||||||
|
|
@ -65,11 +67,18 @@ namespace GleeBug
|
||||||
#endif
|
#endif
|
||||||
else
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//event received, reset timeout counter
|
||||||
|
consecutiveTimeouts = 0;
|
||||||
|
|
||||||
// Handle safe stepping
|
// Handle safe stepping
|
||||||
if(IsDbgReplyLaterSupported)
|
if(IsDbgReplyLaterSupported)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,8 @@ namespace GleeBug
|
||||||
return false;
|
return false;
|
||||||
FlushInstructionCache(hProcess, nullptr, 0);
|
FlushInstructionCache(hProcess, nullptr, 0);
|
||||||
|
|
||||||
|
recentlyDeletedSwbp.push_back(address);
|
||||||
|
|
||||||
//remove the breakpoint from the maps
|
//remove the breakpoint from the maps
|
||||||
softwareBreakpointReferences.erase(info.address);
|
softwareBreakpointReferences.erase(info.address);
|
||||||
breakpoints.erase(found);
|
breakpoints.erase(found);
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,8 @@ namespace GleeBug
|
||||||
MemoryBreakpointSet memoryBreakpointRanges;
|
MemoryBreakpointSet memoryBreakpointRanges;
|
||||||
MemoryBreakpointMap memoryBreakpointPages;
|
MemoryBreakpointMap memoryBreakpointPages;
|
||||||
|
|
||||||
|
std::vector<ptr> recentlyDeletedSwbp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Constructor.
|
\brief Constructor.
|
||||||
\param hProcess Process handle.
|
\param hProcess Process handle.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue