void CBOINCClientManager::KillClient() { ULONG cbBuffer = 128*1024; // 128k initial buffer PVOID pBuffer = NULL; PSYSTEM_PROCESSES pProcesses = NULL; if (m_hBOINCCoreProcess != NULL) { kill_program(m_hBOINCCoreProcess); return; } // Get a snapshot of the process and thread information. diagnostics_get_process_information(&pBuffer, &cbBuffer); // Lets start walking the structures to find the good stuff. pProcesses = (PSYSTEM_PROCESSES)pBuffer; do { if (pProcesses->ProcessId) { tstring strProcessName = pProcesses->ProcessName.Buffer; if (downcase_string(strProcessName) == tstring(_T("boinc.exe"))) { TerminateProcessById(pProcesses->ProcessId); break; } } // Move to the next structure if one exists if (!pProcesses->NextEntryDelta) { break; } pProcesses = (PSYSTEM_PROCESSES)(((LPBYTE)pProcesses) + pProcesses->NextEntryDelta); } while (pProcesses); // Release resources if (pBuffer) HeapFree(GetProcessHeap(), NULL, pBuffer); }
int diagnostics_update_process_list( std::vector<BOINC_PROCESS>& ps ) { ULONG cbBuffer = 128*1024; // 128k initial buffer PVOID pBuffer = NULL; PSYSTEM_PROCESSES pProcesses = NULL; // Clear out the vector ps.clear(); // Get a snapshot of the process and thread information. diagnostics_get_process_information(&pBuffer, &cbBuffer); // Lets start walking the structures to find the good stuff. pProcesses = (PSYSTEM_PROCESSES)pBuffer; do { if (pProcesses->ProcessId) { BOINC_PROCESS pi; pi.dwProcessId = pProcesses->ProcessId; pi.dwParentProcessId = pProcesses->InheritedFromProcessId; pi.strProcessName = pProcesses->ProcessName.Buffer; ps.push_back(pi); } // Move to the next structure if one exists if (!pProcesses->NextEntryDelta) { break; } pProcesses = (PSYSTEM_PROCESSES)(((LPBYTE)pProcesses) + pProcesses->NextEntryDelta); } while (pProcesses); // Release resources if (pBuffer) HeapFree(GetProcessHeap(), NULL, pBuffer); return 0; }