Fix duplicate debuggee process and initial thread handles being kept around in the case that x64dbg is not attaching:
- CloseHandle() the fdProcessInfo->hProcess and fdProcessInfo->hThread handles and set them to NULL if CreateProcess was called (i.e. we are not attaching) just before entering the debug loop
- cbCreateProcess(): set fdProcessInfo->hProcess, fdProcessInfo->hThread and varset("$hp") to the correct handles prior to doing anything else
This commit is contained in:
parent
c8e8b692f0
commit
629a6022e4
|
|
@ -1315,6 +1315,10 @@ void cbTraceOverIntoTraceRecordStep()
|
|||
|
||||
static void cbCreateProcess(CREATE_PROCESS_DEBUG_INFO* CreateProcessInfo)
|
||||
{
|
||||
fdProcessInfo->hProcess = CreateProcessInfo->hProcess;
|
||||
fdProcessInfo->hThread = CreateProcessInfo->hThread;
|
||||
varset("$hp", (duint)fdProcessInfo->hProcess, true);
|
||||
|
||||
void* base = CreateProcessInfo->lpBaseOfImage;
|
||||
|
||||
char DebugFileName[deflen] = "";
|
||||
|
|
@ -2720,6 +2724,10 @@ static void debugLoopFunction(void* lpParameter, bool attach)
|
|||
}
|
||||
else
|
||||
{
|
||||
//close the process and thread handles we got back from CreateProcess, to prevent duplicating the ones we will receive in cbCreateProcess
|
||||
CloseHandle(fdProcessInfo->hProcess);
|
||||
CloseHandle(fdProcessInfo->hThread);
|
||||
fdProcessInfo->hProcess = fdProcessInfo->hThread = nullptr;
|
||||
DebugLoop();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue