1
0
Fork 0

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:
Mattiwatti 2017-11-27 19:27:44 +01:00 committed by Duncan Ogilvie
parent c8e8b692f0
commit 629a6022e4
1 changed files with 8 additions and 0 deletions

View File

@ -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();
}