Gameprocesswatcher.cpp › [SAFE]

struct ProcessInfo DWORD processId; std::string processName; DWORD threadCount; DWORD parentProcessId; ;

void GameProcessWatcher::closeProcessHandle() if (m_hProcess != nullptr) CloseHandle(m_hProcess); m_hProcess = nullptr; m_processId = 0;

void GameProcessWatcher::setOnProcessExit(std::function<void(DWORD)> callback) std::lock_guard<std::mutex> lock(m_mutex); m_onProcessExit = callback; gameprocesswatcher.cpp

bool GameProcessWatcher::openProcessById(DWORD processId) closeProcessHandle(); m_hProcess = OpenProcess(PROCESS_VM_READ

bool GameProcessWatcher::terminateProcess() if (m_hProcess == nullptr) return false; if (!TerminateProcess(m_hProcess, 0)) m_lastError = "Failed to terminate process. Error: " + std::to_string(GetLastError()); return false; closeProcessHandle(); return true; struct ProcessInfo DWORD processId

void GameProcessWatcher::stopWatching() m_isWatching = false; if (m_watchThread.joinable()) m_watchThread.join();

// Callbacks void setOnProcessExit(std::function<void(DWORD)> callback); m_hProcess = nullptr

bool GameProcessWatcher::isProcessRunning() const PROCESS_TERMINATE, FALSE, m_processId); if (hProcess == nullptr) return false; DWORD exitCode; bool isRunning = (GetExitCodeProcess(hProcess, &exitCode) && exitCode == STILL_ACTIVE); CloseHandle(hProcess); return isRunning;