I run an event loop in a thread that is created when connected to the target process. What I did before to disconnect simply called a function that would clear the debug and call DebugSetProcessKillOnExit etc., but getting bad return values, I decided that they should be called from the thread I created. So I made, no mistakes now, but the target process just quits when I exit / disconnect.
I'm currently checking bool in an event loop to check if I need to disconnect (any better solutions?) And then do the following:
pEng->ClearHardwareBreakpoints();
DebugSetProcessKillOnExit(FALSE);
ContinueDebugEvent(pEng->pId, pEng->tId, DBG_CONTINUE);
DebugActiveProcessStop(pEng->pId);
return 0;
ClearHardwareBreakpoints pauses the target thread, calls GetThreadContext with CONTEXT_DEBUG_REGISTERS, and deletes debug registers using SetThreadContext and resumes the thread.
So, as I said, the problem is that the debugged process ends also with my process, as if the shutdown did not work.
Any help is appreciated.
source
share