From fe91cd08b47c916e8ab5861bb54e721ca2d7ed61 Mon Sep 17 00:00:00 2001 From: "Mr. eXoDia" Date: Fri, 15 Aug 2014 22:21:22 +0200 Subject: [PATCH] remove singleshoot breakpoints before the breakpoint callback --- .../TitanEngine.Debugger.DebugLoop.cpp | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/TitanEngine/TitanEngine.Debugger.DebugLoop.cpp b/TitanEngine/TitanEngine.Debugger.DebugLoop.cpp index 89467c4..8565fcf 100644 --- a/TitanEngine/TitanEngine.Debugger.DebugLoop.cpp +++ b/TitanEngine/TitanEngine.Debugger.DebugLoop.cpp @@ -558,8 +558,17 @@ __declspec(dllexport) void TITCALL DebugLoop() char* DisassembledString = (char*)StaticDisassembleEx(ueCurrentPosition, (LPVOID)instr); if(strstr(DisassembledString, "PUSHF")) PushfBPX = true; - myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)FoundBreakPoint.ExecuteCallBack); + + if(FoundBreakPoint.BreakPointType == UE_SINGLESHOOT) + { + DeleteBPX((ULONG_PTR)FoundBreakPoint.BreakPointAddress); + ResetBPXSize = FoundBreakPoint.BreakPointSize - 1; + ResetBPXAddressTo = NULL; + ResetBPX = false; + } + //execute callback + myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)FoundBreakPoint.ExecuteCallBack); __try { myCustomBreakPoint(); @@ -568,6 +577,7 @@ __declspec(dllexport) void TITCALL DebugLoop() { } + if(FoundBreakPoint.BreakPointType != UE_SINGLESHOOT) { DisableBPX((ULONG_PTR)FoundBreakPoint.BreakPointAddress); @@ -575,13 +585,6 @@ __declspec(dllexport) void TITCALL DebugLoop() ResetBPXAddressTo = (ULONG_PTR)FoundBreakPoint.BreakPointAddress; ResetBPX = true; } - else - { - DeleteBPX((ULONG_PTR)FoundBreakPoint.BreakPointAddress); - ResetBPXSize = FoundBreakPoint.BreakPointSize - 1; - ResetBPXAddressTo = NULL; - ResetBPX = false; - } } else VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)FoundBreakPoint.BreakPointAddress, FoundBreakPoint.BreakPointSize, OldProtect, &OldProtect); @@ -1180,8 +1183,17 @@ __declspec(dllexport) void TITCALL DebugLoop() SetThreadContext(hActiveThread, &myDBGContext); EngineCloseHandle(hActiveThread); VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)FoundBreakPoint.BreakPointAddress, FoundBreakPoint.BreakPointSize, OldProtect, &OldProtect); - myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)FoundBreakPoint.ExecuteCallBack); + + if(FoundBreakPoint.BreakPointType == UE_SINGLESHOOT) + { + DeleteBPX((ULONG_PTR)FoundBreakPoint.BreakPointAddress); + ResetBPXSize = FoundBreakPoint.BreakPointSize - 1; + ResetBPXAddressTo = NULL; + ResetBPX = false; + } + //execute callback + myCustomBreakPoint = (fCustomBreakPoint)((LPVOID)FoundBreakPoint.ExecuteCallBack); __try { myCustomBreakPoint(); @@ -1190,6 +1202,7 @@ __declspec(dllexport) void TITCALL DebugLoop() { } + if(FoundBreakPoint.BreakPointType != UE_SINGLESHOOT) { DisableBPX((ULONG_PTR)FoundBreakPoint.BreakPointAddress); @@ -1197,13 +1210,6 @@ __declspec(dllexport) void TITCALL DebugLoop() ResetBPXAddressTo = (ULONG_PTR)FoundBreakPoint.BreakPointAddress; ResetBPX = true; } - else - { - DeleteBPX((ULONG_PTR)FoundBreakPoint.BreakPointAddress); - ResetBPXSize = FoundBreakPoint.BreakPointSize - 1; - ResetBPXAddressTo = NULL; - ResetBPX = false; - } } else VirtualProtectEx(dbgProcessInformation.hProcess, (LPVOID)FoundBreakPoint.BreakPointAddress, FoundBreakPoint.BreakPointSize, OldProtect, &OldProtect);