BOOL SafeTerminateProcess( HANDLE hProcess, // handle to the process UINT uExitCode // exit code for the process ) { DWORD ProcessId = GetProcessId(hProcess); //SendToProcessThreads(ProcessId); DWORD dwRet; dwRet = TerminateApp(ProcessId, 1000); TCHAR tmpbuf[128]; _stprintf(tmpbuf, _T("SafeTerminateProcess Id %.8X (%d) TerminateApp %d"), ProcessId, ProcessId, dwRet); WriteLogToFile(tmpbuf, _T("ExecProcess")); return TRUE; // BOOL fOk; // // PROCESSENTRY32 pe = { sizeof(pe) }; // // HANDLE hSnapshot= CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0 ); // // if(hSnapshot == INVALID_HANDLE_VALUE) // return FALSE; // // int iCount = 0; // for ( fOk = Process32First(hSnapshot,&pe); fOk ; fOk = Process32Next(hSnapshot,&pe) ) // { // iCount++; // // if (ProcessId == pe.th32ProcessID) // { // SendToProcessThreads(ProcessId); // } // } // // CloseHandle(hSnapshot); // /* LRESULT SendMessage( HWND hWnd, // handle to destination window UINT Msg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ); BOOL PostThreadMessage( DWORD idThread, // thread identifier UINT Msg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter ); */ }
void LogManager::OutputToDebugLogs(const string& output) { if(mFlags & LOGFLAG_WRITE_TO_FILE) { WriteLogToFile(output); } if(mFlags & LOGFLAG_WRITE_TO_DEBUGGER) { cout << output.c_str(); } }