大家好,我是 C++ 的初学者,我编写了代码来尝试关闭列出的进程(即):
char* chos[3] = {"launcher.exe","cheat.exe","lol.exe"};
问题是我的代码只工作一次(第一次加载时),而不是像我想要的那样连续工作。如果可能的话,我希望这段代码能够监控当前正在运行的进程列表,并在它生成时关闭我预定义的 exe 名称。
#include "StdInc.h"
#include <windows.h>
#include <tlhelp32.h>
#include <tchar.h>
#include <stdio.h>
void find_Proc() {
HANDLE proc_Snap;
HANDLE proc_iw4;
HANDLE proc_iw4term;
PROCESSENTRY32 pe32;
PROCESSENTRY32 pe32iw4;
int i;
char* chos[3] = {"launcher.exe","cheat.exe","lol.exe"};
char* iw4m = "iw4m.exe";
proc_iw4 = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
proc_Snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
pe32.dwSize = sizeof(PROCESSENTRY32);
pe32iw4.dwSize = sizeof(PROCESSENTRY32);
for(i = 0; i < 3 ; i++) {
Process32First(proc_Snap , &pe32);
do {
if(!strcmp(chos[i],pe32.szExeFile)) {
MessageBox(NULL,"CHEAT DETECTED","ERROR",NULL);
Process32First(proc_iw4,&pe32iw4);
do {
if (!strcmp(iw4m,pe32iw4.szExeFile)) {
proc_iw4term = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pe32iw4.th32ProcessID);
if (proc_iw4term != NULL)
TerminateProcess(proc_iw4term, 0);
CloseHandle(proc_iw4term);
}
} while(Process32Next(proc_iw4, &pe32iw4));
}
} while(Process32Next(proc_Snap, &pe32));
}
CloseHandle(proc_Snap);
CloseHandle(proc_iw4);
//scanf("sadas",&i);
}