1
0
Fork 0

DBG: added the detach command (should be working now)

PROJECT: updated help
This commit is contained in:
Mr. eXoDia 2014-04-16 20:30:15 +02:00
parent e8664e2749
commit 920fedc9ad
4 changed files with 357 additions and 314 deletions

View File

@ -0,0 +1,22 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>DetachDebugger/detach</title>
<meta name="GENERATOR" content="WinCHM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
html,body {
/* Default Font */
font-family: Courier New;
font-size: 11pt;
}
</style>
</head>
<body>
<P><STRONG>DetachDebugger[,detach]<BR></STRONG>Detach the debugger from the currently-debugged
process.</P>
<P><U>arguments</U><BR>This command has no arguments.</P>
<P><U>result</U> <BR>This command does not set any result
variables.</P></body>

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,7 @@ static uint pDebuggedBase=0;
static uint pDebuggedEntry=0;
static bool isStepping=false;
static bool isPausedByUser=false;
static bool isDetachedByUser=false;
static bool bScyllaLoaded=false;
static bool bIsAttached=false;
static bool bSkipExceptions=false;
@ -818,7 +819,18 @@ static void cbException(EXCEPTION_DEBUG_INFO* ExceptionData)
uint addr=(uint)ExceptionData->ExceptionRecord.ExceptionAddress;
if(ExceptionData->ExceptionRecord.ExceptionCode==EXCEPTION_BREAKPOINT)
{
if(isPausedByUser)
if(isDetachedByUser)
{
PLUG_CB_DETACH detachInfo;
detachInfo.fdProcessInfo=fdProcessInfo;
plugincbcall(CB_DETACH, &detachInfo);
if(!DetachDebuggerEx(fdProcessInfo->dwProcessId))
dputs("DetachDebuggerEx failed...");
else
dputs("detached!");
return;
}
else if(isPausedByUser)
{
dputs("paused!");
SetNextDbgContinueStatus(DBG_CONTINUE);
@ -932,6 +944,7 @@ static DWORD WINAPI threadDebugLoop(void* lpParameter)
plugincbcall(CB_INITDEBUG, &initInfo);
//run debug loop (returns when process debugging is stopped)
DebugLoop();
isDetachedByUser=false;
//call plugin callback
PLUG_CB_STOPDEBUG stopInfo;
stopInfo.reserved=0;
@ -1843,7 +1856,7 @@ static DWORD WINAPI threadAttachLoop(void* lpParameter)
fdProcessInfo=&pi_attached;
//do some init stuff
bFileIsDll=IsFileDLL(szFileName, 0);
BridgeSettingSet("Recent Files", "path", szFileName);
GuiAddRecentFile(szFileName);
ecount=0;
//NOTE: set custom handlers
SetCustomHandler(UE_CH_CREATEPROCESS, (void*)cbCreateProcess);
@ -1875,12 +1888,12 @@ static DWORD WINAPI threadAttachLoop(void* lpParameter)
plugincbcall(CB_ATTACH, &attachInfo);
//run debug loop (returns when process debugging is stopped)
AttachDebugger(pid, true, fdProcessInfo, (void*)cbAttachDebugger);
isDetachedByUser=false;
//call plugin callback
PLUG_CB_STOPDEBUG stopInfo;
stopInfo.reserved=0;
plugincbcall(CB_STOPDEBUG, &stopInfo);
//message the user/do final stuff
DeleteFileA("DLLLoader.exe");
RemoveAllBreakPoints(UE_OPTION_REMOVEALL); //remove all breakpoints
dbclose();
modclear();
@ -1948,11 +1961,9 @@ CMDRESULT cbDebugAttach(int argc, char* argv[])
CMDRESULT cbDebugDetach(int argc, char* argv[])
{
PLUG_CB_DETACH detachInfo;
detachInfo.fdProcessInfo=fdProcessInfo;
plugincbcall(CB_DETACH, &detachInfo);
DetachDebugger(fdProcessInfo->dwProcessId);
unlock(WAITID_RUN);
unlock(WAITID_RUN); //run
isDetachedByUser=true; //detach when paused
DebugBreakProcess(fdProcessInfo->hProcess);
return STATUS_CONTINUE;
}

View File

@ -52,7 +52,7 @@ static void registercommands()
cmdnew(cmd, "InitDebug\1init\1initdbg", cbDebugInit, false); //init debugger arg1:exefile,[arg2:commandline]
cmdnew(cmd, "StopDebug\1stop\1dbgstop", cbStopDebug, true); //stop debugger
cmdnew(cmd, "AttachDebugger\1attach", cbDebugAttach, false); //attach
//cmdnew(cmd, "DetachDebugger\1detach", cbDebugDetach, true); //detach
cmdnew(cmd, "DetachDebugger\1detach", cbDebugDetach, true); //detach
cmdnew(cmd, "run\1go\1r\1g", cbDebugRun, true); //unlock WAITID_RUN
cmdnew(cmd, "erun\1egun\1er\1eg", cbDebugErun, true); //run + skip first chance exceptions
cmdnew(cmd, "pause", cbDebugPause, true); //pause debugger