#include <windows.h>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include "tlhelp32.h"
#include <string>
#include <time.h>
#include <tchar.h>
int mod;//0全杀 1极域 2锐捷云课堂教学管理软件
using namespace std;
BOOL KillProcessByName(const TCHAR *lpszProcessName)
{
unsigned int pid = -1;
BOOL retval = TRUE;
if (lpszProcessName == NULL)
return -1;
DWORD dwRet = 0;
HANDLE hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS,0 );
PROCESSENTRY32 processInfo;
processInfo.dwSize = sizeof( PROCESSENTRY32 );
int flag = Process32First( hSnapshot, &processInfo );
// Find the process with name as same as lpszProcessName
while (flag != 0)
{
if (_tcscmp(processInfo.szExeFile, lpszProcessName) == 0) {
// Terminate the process.
pid = processInfo.th32ProcessID;
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
if (TerminateProcess(hProcess, 0) != TRUE) { // Failed to terminate it.
retval = FALSE;
break;
}
}
flag = Process32Next(hSnapshot, &processInfo);
} // while (flag != 0)
CloseHandle(hSnapshot);
if (pid == -1)
return FALSE;
return retval;
}
void kill()
{
if(mod == 0 || mod == 1)
KillProcessByName("StudentMain.exe");
if(mod == 0 || mod == 2)
{
KillProcessByName("cmdaemon.exe");
KillProcessByName("vdservice.exe");
KillProcessByName("ClassManagerCmd.exe");
KillProcessByName("ClassManagerApp.exe");
KillProcessByName("RjUsbController.exe");
KillProcessByName("PlayerOptimize.exe");
KillProcessByName("TrayTool.exe");
KillProcessByName("vMsgDisp.exe");
KillProcessByName("DevHook.exe");
KillProcessByName("rccservice.exe");
KillProcessByName("\"FileZilla Server.exe\"");
KillProcessByName("IdvAgent.exe");
KillProcessByName("RJRemoteserver.exe");
}
}
HHOOK keyboardHook = 0; // 钩子句柄
unsigned long need[10], now[10];
int lll;
int nowtime = time(NULL);
int char2vkcode(char c)
{
if('a' <= c && c <= 'z')
c += 'A' - 'a';
return 0x41 + c - 'A';
}
LRESULT CALLBACK LowLevelKeyboardProc(
_In_ int nCode, // 规定钩子如何处理消息,小于 0 则直接 CallNextHookEx
_In_ WPARAM wParam, // 消息类型
_In_ LPARAM lParam // 指向某个结构体的指针,这里是 KBDLLHOOKSTRUCT(低级键盘输入事件)
)
{
KBDLLHOOKSTRUCT *ks = (KBDLLHOOKSTRUCT *)lParam; // 包含低级键盘输入事件信息
/*
typedef struct tagKBDLLHOOKSTRUCT {
DWORD vkCode; // 按键代号
DWORD scanCode; // 硬件扫描代号,同 vkCode 也可以作为按键的代号。
DWORD flags; // 事件类型,一般按键按下为 0 抬起为 128。
DWORD time; // 消息时间戳
ULONG_PTR dwExtraInfo; // 消息附加信息,一般为 0。
}KBDLLHOOKSTRUCT,*LPKBDLLHOOKSTRUCT,*PKBDLLHOOKSTRUCT;
*/
/*vkcode:0x30~0x39:1~9 0x41~0x5A:A~Z 0x6A:* B:+ 0x6D:- 0x6E:. 0x6F:/
*/
//监控Alt+K或Shift+K
//CTRL按下了吗?
BOOL bControlKeyDown = GetAsyncKeyState (VK_CONTROL) >> ((sizeof(SHORT) * 8) - 1);
if(ks -> vkCode == char2vkcode('K') && ks->flags & LLKHF_ALTDOWN)
kill();
if(ks -> vkCode == char2vkcode('K') && ks -> vkCode == VK_SHIFT)
kill();
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
void readconfig()
{
printf("如果有改进建议,欢迎提出,私发\n0全杀(目前以收录,如果你有新的控制软件,请将大致情况私法给我,luogu.com.cn:Kali_linux)\n1极域\n2锐捷云课堂教学管理软件\n输入:");
scanf("%d", &mod);
}
int main(void)
{
readconfig();
MSG msg;
int tt = time(0);
keyboardHook = SetWindowsHookEx(
WH_KEYBOARD_LL, // 钩子类型,WH_KEYBOARD_LL 为键盘钩子
LowLevelKeyboardProc, // 指向钩子函数的指针
GetModuleHandleA(NULL), // Dll 句柄
NULL);
while (1)
{
if(time(0) - tt >= 1)
{
tt = time(0);
UnhookWindowsHookEx(keyboardHook);
keyboardHook = SetWindowsHookEx(
WH_KEYBOARD_LL, // 钩子类型,WH_KEYBOARD_LL 为键盘钩子
LowLevelKeyboardProc, // 指向钩子函数的指针
GetModuleHandleA(NULL), // Dll 句柄
NULL);
}
if (keyboardHook == 0)
{
cout << "挂钩键盘失败" << endl;
return -1;
}
// 如果消息队列中有消息
if (PeekMessageA(
&msg, // MSG 接收这个消息
NULL, // 检测消息的窗口句柄,NULL:检索当前线程所有窗口消息
NULL, // 检查消息范围中第一个消息的值,NULL:检查所有消息(必须和下面的同时为NULL)
NULL, // 检查消息范围中最后一个消息的值,NULL:检查所有消息(必须和上面的同时为NULL)
PM_REMOVE // 处理消息的方式,PM_REMOVE:处理后将消息从队列中删除
))
{
// 把按键消息传递给字符消息
TranslateMessage(&msg);
// 将消息分派给窗口程序
DispatchMessageW(&msg);
}
else
Sleep(0); // 避免CPU全负载运行
}
// 删除钩子
UnhookWindowsHookEx(keyboardHook);
return 0;
}