correctly handle breakpoints happening before the system breakpoint

This commit is contained in:
Duncan Ogilvie 2017-12-28 21:07:19 +01:00
parent 2dd2cb1e3d
commit 7dc011516d
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
1 changed files with 56 additions and 56 deletions

View File

@ -3,6 +3,10 @@
namespace GleeBug namespace GleeBug
{ {
void Debugger::exceptionBreakpoint(const EXCEPTION_RECORD & exceptionRecord, const bool firstChance) void Debugger::exceptionBreakpoint(const EXCEPTION_RECORD & exceptionRecord, const bool firstChance)
{
//check if the breakpoint exists
auto foundInfo = mProcess->breakpoints.find({ BreakpointType::Software, ptr(exceptionRecord.ExceptionAddress) });
if(foundInfo == mProcess->breakpoints.end())
{ {
if(!mProcess->systemBreakpoint) //handle system breakpoint if(!mProcess->systemBreakpoint) //handle system breakpoint
{ {
@ -10,7 +14,7 @@ namespace GleeBug
mProcess->systemBreakpoint = true; mProcess->systemBreakpoint = true;
mContinueStatus = DBG_CONTINUE; mContinueStatus = DBG_CONTINUE;
//get process DEP policy //get process DEP policy (TODO: what happens if a breakpoint is hit before the system breakpoint?)
#ifndef _WIN64 #ifndef _WIN64
typedef BOOL(WINAPI * GETPROCESSDEPPOLICY)( typedef BOOL(WINAPI * GETPROCESSDEPPOLICY)(
_In_ HANDLE /*hProcess*/, _In_ HANDLE /*hProcess*/,
@ -35,12 +39,9 @@ namespace GleeBug
//call the callback //call the callback
cbSystemBreakpoint(); cbSystemBreakpoint();
} }
else
{
//check if the breakpoint exists
auto foundInfo = mProcess->breakpoints.find({ BreakpointType::Software, ptr(exceptionRecord.ExceptionAddress) });
if (foundInfo == mProcess->breakpoints.end())
return; return;
}
const auto info = foundInfo->second; const auto info = foundInfo->second;
//set continue status //set continue status
@ -70,7 +71,6 @@ namespace GleeBug
if(info.singleshoot) if(info.singleshoot)
mProcess->DeleteGenericBreakpoint(info); mProcess->DeleteGenericBreakpoint(info);
} }
}
void Debugger::exceptionSingleStep(const EXCEPTION_RECORD & exceptionRecord, const bool firstChance) void Debugger::exceptionSingleStep(const EXCEPTION_RECORD & exceptionRecord, const bool firstChance)
{ {