don't close process and file handles in ForceClose

This commit is contained in:
Duncan Ogilvie 2018-03-04 21:11:25 +01:00
parent ef020ed39d
commit ab037ef1c5
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
2 changed files with 16 additions and 15 deletions

View File

@ -9,17 +9,8 @@
__declspec(dllexport) void TITCALL ForceClose()
{
//manage process list
int processcount = (int)hListProcess.size();
for(int i = 0; i < processcount; i++)
{
EngineCloseHandle(hListProcess.at(i).hFile);
EngineCloseHandle(hListProcess.at(i).hProcess);
}
ClearProcessList();
//manage thread list
int threadcount = (int)hListThread.size();
for(int i = 0; i < threadcount; i++)
EngineCloseHandle(hListThread.at(i).hThread);
ClearThreadList();
//manage library list
int libcount = (int)hListLibrary.size();

View File

@ -517,14 +517,24 @@ __declspec(dllexport) void* TITCALL InitDLLDebugW(wchar_t* szFileName, bool Rese
__declspec(dllexport) bool TITCALL StopDebug()
{
if(dbgProcessInformation.hProcess != NULL)
bool result = false;
HANDLE hProcess = TitanOpenProcess(PROCESS_TERMINATE, FALSE, dbgProcessInformation.dwProcessId);
if(hProcess)
{
TerminateThread(dbgProcessInformation.hThread, NULL);
TerminateProcess(dbgProcessInformation.hProcess, NULL);
Sleep(10); //allow thread switching
return true;
TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
result = true;
}
return false;
HANDLE hThread = TitanOpenThread(THREAD_TERMINATE, FALSE, dbgProcessInformation.dwThreadId);
if(hThread)
{
TerminateThread(hThread, 0);
CloseHandle(hThread);
Sleep(10); //allow thread switching
result = true;
}
return result;
}
__declspec(dllexport) bool TITCALL AttachDebugger(DWORD ProcessId, bool KillOnExit, LPVOID DebugInfo, LPVOID CallBack)