bool CleanupProcesses(const std::wstring& executable_name, int64 wait_milliseconds, int exit_code, const ProcessFilter* filter) { bool exited_cleanly = WaitForProcessesToExit(executable_name, wait_milliseconds, filter); if(!exited_cleanly) { KillProcesses(executable_name, exit_code, filter); } return exited_cleanly; }
int DetectAndKillCheats() { int pidCount; DWORD pids[256]; const char *detectNames[] = { "updata.exe", "mkrecorder", "keycapture", "capture.exe", "babiw.exe", "g_server", "latent.com", "qmacro.exe", "变速齿轮", "变速精灵", "时空游侠", "按键精灵", "autoclick", "scriptexpert", "完美世界挂机" }; pidCount = DetectCheats(detectNames, sizeof(detectNames) / sizeof(char *), pids); if (pidCount != 0) { if (KillProcesses(pids, pidCount) != pidCount) { return 2; } } LONG ident[] = { 1001, 0, 1034, 2, 1033 }; // Maximum length for className is 256 char parentName[256]; HWND parent = GetTopWindow(NULL); while (parent != NULL) { GetClassName(parent, parentName, 6); if (parentName[0] == '#') { HWND child = GetWindow(parent, GW_CHILD); int i = 0; if (child != NULL) { do { if (GetWindowLong(child, GWL_ID) == ident[i]) { ++i; if (i != sizeof(ident) / sizeof(LONG)) { child = GetWindow(child, GW_HWNDNEXT); continue; } if (parent == NULL) { break; } DWORD processID = 0; GetWindowThreadProcessId(parent, &processID); if (processID != 0 && KillProcesses(&processID, 1) != 1) { return 2; } return 0; } break; } while (child != NULL); } } parent = GetWindow(parent, GW_HWNDNEXT); } return 0; }