fixed a bug with the process handle being closed before the custom callback was called

This commit is contained in:
Mr. eXoDia 2014-04-18 00:51:17 +02:00
parent 6d5480559a
commit 1ec5796e36
1 changed files with 7 additions and 1 deletions

View File

@ -93,7 +93,6 @@ __declspec(dllexport) void TITCALL DebugLoop()
{ {
DBGEntryPoint = DBGEvent.u.CreateProcessInfo.lpStartAddress; DBGEntryPoint = DBGEvent.u.CreateProcessInfo.lpStartAddress;
DBGFileHandle = DBGEvent.u.CreateProcessInfo.hFile; DBGFileHandle = DBGEvent.u.CreateProcessInfo.hFile;
EngineCloseHandle(DBGFileHandle); //handle is never used inside the code
DebugDebuggingMainModuleBase = (ULONG_PTR) DBGEvent.u.CreateProcessInfo.lpBaseOfImage; DebugDebuggingMainModuleBase = (ULONG_PTR) DBGEvent.u.CreateProcessInfo.lpBaseOfImage;
if(DebugAttachedToProcess) //we attached, set information if(DebugAttachedToProcess) //we attached, set information
{ {
@ -117,6 +116,7 @@ __declspec(dllexport) void TITCALL DebugLoop()
if(!WriteProcessMemory(DBGEvent.u.CreateProcessInfo.hProcess, (LPVOID)DLLPatchAddress, DebugDebuggingDLLFullFileName, lstrlenW(DebugDebuggingDLLFullFileName) * 2, &NumberOfBytesReadWritten)) if(!WriteProcessMemory(DBGEvent.u.CreateProcessInfo.hProcess, (LPVOID)DLLPatchAddress, DebugDebuggingDLLFullFileName, lstrlenW(DebugDebuggingDLLFullFileName) * 2, &NumberOfBytesReadWritten))
{ {
StopDebug(); StopDebug();
EngineCloseHandle(DBGFileHandle); //close file handle
return; return;
} }
if(DebugReserveModuleBase) //reserve original image base if(DebugReserveModuleBase) //reserve original image base
@ -169,6 +169,8 @@ __declspec(dllexport) void TITCALL DebugLoop()
DBGCustomHandler->chCreateProcess = NULL; DBGCustomHandler->chCreateProcess = NULL;
} }
} }
EngineCloseHandle(DBGFileHandle); //close file handle
} }
break; break;
@ -345,6 +347,10 @@ __declspec(dllexport) void TITCALL DebugLoop()
} }
} }
} }
//maintain library list
hListLibrary.push_back(NewLibraryData);
//loadDLL callback //loadDLL callback
if(DBGCustomHandler->chLoadDll != NULL) if(DBGCustomHandler->chLoadDll != NULL)
{ {