From a1847472ba8f28a349d33d3f51bbd3274948b51e Mon Sep 17 00:00:00 2001 From: strongbit Date: Wed, 25 Mar 2015 13:26:21 +0000 Subject: [PATCH] I wonder how do you send the debugger a singlestepping exception. Added only two functions --- GleeBug/Debugger.Loop.cpp | 12 +++++++++++- GleeBug/Debugger.h | 14 ++++++++++++++ MyDebugger/MyDebugger.h | 10 ++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/GleeBug/Debugger.Loop.cpp b/GleeBug/Debugger.Loop.cpp index a87df81..781a0cd 100644 --- a/GleeBug/Debugger.Loop.cpp +++ b/GleeBug/Debugger.Loop.cpp @@ -38,7 +38,17 @@ namespace GleeBug void Debugger::exceptionEvent(EXCEPTION_DEBUG_INFO* exceptionInfo) { - cbExceptionEvent(exceptionInfo); + switch (exceptionInfo->ExceptionRecord.ExceptionCode){ + case EXCEPTION_SINGLE_STEP: + cbException_single_spep(&exceptionInfo->ExceptionRecord); + break; + case EXCEPTION_BREAKPOINT: + cbExcpetion_breakpoint(&exceptionInfo->ExceptionRecord); + break; + default: + cbExceptionEvent(exceptionInfo); + break; + } } void Debugger::debugStringEvent(OUTPUT_DEBUG_STRING_INFO* debugString) diff --git a/GleeBug/Debugger.h b/GleeBug/Debugger.h index a876c0e..bfb3ad5 100644 --- a/GleeBug/Debugger.h +++ b/GleeBug/Debugger.h @@ -94,6 +94,18 @@ namespace GleeBug */ virtual void cbExceptionEvent(const EXCEPTION_DEBUG_INFO* exceptionInfo) {}; + /* + single step event + these will execute instead of cbExceptionEvent. + */ + virtual void cbException_single_spep(EXCEPTION_RECORD* except_inf) {}; + + /* + breakpoint event + Will also execute instead of cbExceptionEvent. + */ + virtual void cbExcpetion_breakpoint(EXCEPTION_RECORD* except_inf) {}; + /** \brief Debug string debug event callback. Provide an implementation to use this callback. \param debugString Information about the debug string. @@ -117,6 +129,8 @@ namespace GleeBug virtual void debugStringEvent(OUTPUT_DEBUG_STRING_INFO* debugString); virtual void ripEvent(RIP_INFO* rip); + + ProcessInfo _mainProcess; DWORD _continueStatus; bool _breakDebugger; diff --git a/MyDebugger/MyDebugger.h b/MyDebugger/MyDebugger.h index b7a141a..ca1dd6c 100644 --- a/MyDebugger/MyDebugger.h +++ b/MyDebugger/MyDebugger.h @@ -21,6 +21,16 @@ protected: printf("Thread %d created with entry 0x%p\n", _debugEvent.dwThreadId, createThread->lpStartAddress); }; + virtual void cbException_single_spep(EXCEPTION_RECORD* except_inf) + { + printf("a single step occurred at location 0x%X", except_inf->ExceptionAddress); + }; + + virtual void cbExcpetion_breakpoint(EXCEPTION_RECORD* except_inf) + { + printf("a breakpoint occurred at location 0x%X", except_inf->ExceptionAddress); + }; + virtual void cbExitThreadEvent(const EXIT_THREAD_DEBUG_INFO* exitThread) { printf("Thread %d terminated with exit code 0x%08X\n", _debugEvent.dwThreadId, exitThread->dwExitCode);