mirror of https://github.com/x64dbg/GleeBug
Improve detaching
This commit is contained in:
parent
821234ae37
commit
ddfa81366e
|
|
@ -28,8 +28,31 @@ namespace GleeBug
|
||||||
{
|
{
|
||||||
//wait for a debug event
|
//wait for a debug event
|
||||||
mIsRunning = true;
|
mIsRunning = true;
|
||||||
if (!MyWaitForDebugEvent(&mDebugEvent, INFINITE))
|
if (!MyWaitForDebugEvent(&mDebugEvent, 100))
|
||||||
|
{
|
||||||
|
if (mDetach)
|
||||||
|
{
|
||||||
|
if (!UnsafeDetach())
|
||||||
|
cbInternalError("Debugger::Detach failed!");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
|
// Fix based on work by https://github.com/number201724
|
||||||
|
if (WaitForSingleObject(mMainProcess.hProcess, 0) == WAIT_OBJECT_0)
|
||||||
|
{
|
||||||
|
mDebugEvent.dwDebugEventCode = EXIT_PROCESS_DEBUG_EVENT;
|
||||||
|
mDebugEvent.dwProcessId = mMainProcess.dwProcessId;
|
||||||
|
mDebugEvent.dwThreadId = mMainProcess.dwThreadId;
|
||||||
|
if (!GetExitCodeProcess(mMainProcess.hProcess, &mDebugEvent.u.ExitProcess.dwExitCode))
|
||||||
|
mDebugEvent.u.ExitProcess.dwExitCode = 0xFFFFFFFF;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Regular timeout, wait again
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
mIsRunning = false;
|
mIsRunning = false;
|
||||||
|
|
||||||
//set default continue status
|
//set default continue status
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ namespace GleeBug
|
||||||
|
|
||||||
bool Debugger::UnsafeDetach()
|
bool Debugger::UnsafeDetach()
|
||||||
{
|
{
|
||||||
|
// TODO: remove from all threads?
|
||||||
Registers(mThread->hThread, CONTEXT_CONTROL).TrapFlag = false;
|
Registers(mThread->hThread, CONTEXT_CONTROL).TrapFlag = false;
|
||||||
return !!DebugActiveProcessStop(mMainProcess.dwProcessId);
|
return !!DebugActiveProcessStop(mMainProcess.dwProcessId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue