From 4cb07be1f525b15692a3362fe1e63f9ed54f6c01 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Mon, 11 Dec 2017 20:50:32 +0100 Subject: [PATCH] fix INVALID_HANDLE_VALUE exception on attach See: * https://github.com/x64dbg/x64dbg/issues/1777 * https://github.com/x64dbg/x64dbg/issues/1759 --- GleeBug/Debugger.Loop.Dll.cpp | 3 ++- GleeBug/Debugger.Loop.Process.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/GleeBug/Debugger.Loop.Dll.cpp b/GleeBug/Debugger.Loop.Dll.cpp index 7585cdd..1603180 100644 --- a/GleeBug/Debugger.Loop.Dll.cpp +++ b/GleeBug/Debugger.Loop.Dll.cpp @@ -18,7 +18,8 @@ namespace GleeBug cbLoadDllEvent(loadDll, dll); //close the file handle - CloseHandle(loadDll.hFile); + if(loadDll.hFile) + CloseHandle(loadDll.hFile); } void Debugger::unloadDllEvent(const UNLOAD_DLL_DEBUG_INFO & unloadDll) diff --git a/GleeBug/Debugger.Loop.Process.cpp b/GleeBug/Debugger.Loop.Process.cpp index 5690828..cb37192 100644 --- a/GleeBug/Debugger.Loop.Process.cpp +++ b/GleeBug/Debugger.Loop.Process.cpp @@ -39,7 +39,8 @@ namespace GleeBug cbCreateProcessEvent(createProcess, *mProcess); //close the file handle - CloseHandle(createProcess.hFile); + if(createProcess.hFile) + CloseHandle(createProcess.hFile); } void Debugger::exitProcessEvent(const EXIT_PROCESS_DEBUG_INFO & exitProcess)