From 0c81a126cacca633a3266a388ddaffabdf473fb4 Mon Sep 17 00:00:00 2001 From: Matthijs Lavrijsen Date: Thu, 4 Feb 2021 05:08:43 +0100 Subject: [PATCH] DBG: move NtTerminateProcess event from a bp to exit process callback --- src/dbg/debugger.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/dbg/debugger.cpp b/src/dbg/debugger.cpp index 84afb88f..749a2a81 100644 --- a/src/dbg/debugger.cpp +++ b/src/dbg/debugger.cpp @@ -1489,9 +1489,23 @@ static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo) static void cbExitProcess(EXIT_PROCESS_DEBUG_INFO* ExitProcess) { dprintf(QT_TRANSLATE_NOOP("DBG", "Process stopped with exit code 0x%X\n"), ExitProcess->dwExitCode); + const bool breakHere = settingboolget("Events", "NtTerminateProcess"); + if(breakHere) + { + // lock + DebugUpdateGuiSetStateAsync(GetContextDataEx(hActiveThread, UE_CIP), true); + lock(WAITID_RUN); + } + // plugin callback PLUG_CB_EXITPROCESS callbackInfo; callbackInfo.ExitProcess = ExitProcess; plugincbcall(CB_EXITPROCESS, &callbackInfo); + if(breakHere) + { + dbgsetforeground(); + dbgsetskipexceptions(false); + wait(WAITID_RUN); + } _dbg_animatestop(); // Stop animating //history dbgcleartracestate(); @@ -1756,8 +1770,6 @@ static void cbLoadDll(LOAD_DLL_DEBUG_INFO* LoadDll) cookie.HandleNtdllLoad(bIsAttached); if(settingboolget("Misc", "TransparentExceptionStepping")) exceptionDispatchAddr = DbgValFromString("ntdll:KiUserExceptionDispatcher"); - if(settingboolget("Events", "NtTerminateProcess")) // Break on NtTerminateProcess - cmddirectexec("bp ntdll.NtTerminateProcess, ss"); //set debug flags if(dwDebugFlags != 0) {