#include "server_palpit.h" #include "Mapping.h" namespace server_palpit { DWORD WINAPI palpit_thread(LPVOID parmar) { while (true) { auto mapping_data = reinterpret_cast(parmar); if (!mapping_data->server_pid) mapping_data->server_pid = GetCurrentProcessId(); // //尝试打开客户端进程 // static int fail_index = 0; static HANDLE hProcess = 0; auto client_pid = mapping_data->client_pid; if (hProcess == NULL) { if (fail_index > 3) exit(0); hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, client_pid); fail_index++; Sleep(1000); continue; } // //监控客户端进程是否退出 // DWORD exitCode; if (GetExitCodeProcess(hProcess, &exitCode)) { if (exitCode != STILL_ACTIVE) { exit(0); } } Sleep(1000); } return 0; } auto create_palpit_thread(LPVOID parmar) -> void { CreateThread(nullptr, 0, palpit_thread, parmar, 0, nullptr); } }