#include <windows.h>
#include <tchar.h>
#include <cstdio>
#include <tlhelp32.h>
#include <process.h>
#include <psapi.h>
#include <atomic>
#include <io.h>
#include <time.h>
#include <versionhelpers.h>
#include <shellscalingapi.h>
#include "ziyuan.h"
#define ThreadSafe __declspec(thread)
const int SUSPEND_BUTTON = 3301;
const int REBOOT_BUTTON = 3302;
const int NTSDKILL_BUTTON = 3303;
const int JC_BUTTON = 3305;
const int PASSWD_BUTTON = 3306;
const int KEYBOARDHOOK_BUTTON = 3307;
const int SETFIRST_BUTTON = 3308;
const int SETTOUM_BUTTON = 3309;
const int MOVESHUTDOWN_BUTTON = 3310;
const int HUIFU_BUTTON = 3311;
const int GETREGEDITPASSWD_BUTTON = 3312;
const int TASKILLKILLD_BUTTON = 3313;
const int DELETSHUTDOWN_BUTTON = 3314;
const int ID_ACCR_SHOW = 1001;
const int ID_ACCR_HIDE = 1002;
const int WM_MSG = RegisterWindowMessage("postmessage");
CRITICAL_SECTION CSPID;
LPCWSTR BroadcastTitle = L"屏幕广播";
LPCSTR MythwareFilename = "StudentMain.exe";
LPCWSTR MythwareTitle = L"StudentMain.exe";
LPCSTR TISHIYU = "请您认真阅读并充分理解以下内容\n本软件仅以学习交流为目的,请勿用于任何非法用途.本软件的所有功能均只可以用于课堂辅助,禁止用于干坏事.\n事先声明,因使用本软件造成的一切后果与作者无关,由直接使用者承担责任,如做不到请自行删除本软件.\n一旦您选择是即表示您已经阅读并且同意与此工具开发者达成上述协议";
char TempWorkPath[MAX_PATH + 1];
HANDLE ClassHandle = NULL, MythwareHandle = NULL, threadisstart = NULL, threadKeyboardHook = NULL, threadSetWindowName = NULL, KeyBoardHookEvent = NULL;
HWND mythwaretext = NULL, guangbotext = NULL, mythwareversiontext = NULL;
HWND SuspendB = NULL, HuifuB = NULL, RebootB = NULL, NtsdKillB = NULL, TaskillKillB = NULL, JcB = NULL, PassWdB = NULL, KeyboardHookB = NULL, SetFirstB = NULL, MoveShutdownB = NULL, GetRegeditPassWdB = NULL, DeleteShutdownB = NULL;
HWND Class = NULL, Mythware = NULL;
HFONT hFont = NULL;
DWORD pid;
NOTIFYICONDATA m_nid;
DWORD GetMainThreadFromId(const DWORD IdProcess) {
if (IdProcess <= 0) return 0;
DWORD IdMainThread = 0;
THREADENTRY32 te;
te.dwSize = sizeof(THREADENTRY32);
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (Thread32First(hSnapshot, &te)) {
do {
if (IdProcess == te.th32OwnerProcessID) {
IdMainThread = te.th32ThreadID;
break;
}
} while (Thread32Next(hSnapshot, &te));
}
CloseHandle(hSnapshot);
return IdMainThread;
}
struct Jiyu {
DWORD id;
char filepath[260];
BOOL flag;
} jiyu;
Jiyu ModuleIsAble(DWORD ProcessPid, LPCSTR Modulename) {
Jiyu tj;
if (Modulename[0] == '\0') {
tj.flag = FALSE;
return tj;
}
MODULEENTRY32 me;
me.dwSize = sizeof(MODULEENTRY32);
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessPid);
if (Module32First(hSnapshot, &me)) {
do {
if (!strcmp(Modulename, me.szModule)) {
CloseHandle(hSnapshot);
strcpy(tj.filepath, me.szExePath);
tj.id = ProcessPid;
tj.flag = TRUE;
return tj;
}
} while (Module32Next(hSnapshot, &me));
}
CloseHandle(hSnapshot);
tj.flag = FALSE;
return tj;
}
Jiyu GetProcessPidFromFilename(LPCSTR Filename) {
Jiyu tj;
if (Filename[0] == '\0') {
tj.flag = FALSE;
return tj;
}
PROCESSENTRY32 te;
te.dwSize = sizeof(PROCESSENTRY32);
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (Process32First(hSnapshot, &te)) {
do {
HANDLE temphandle = OpenProcess(PROCESS_ALL_ACCESS, false, te.th32ProcessID);
tj = ModuleIsAble(te.th32ProcessID, Filename);
if (tj.flag == TRUE) {
CloseHandle(hSnapshot);
return tj;
}
CloseHandle(temphandle);
} while (Process32Next(hSnapshot, &te));
}
tj.flag = FALSE;
return tj;
}
BOOL GetMythwarePasswordFromRegedit(char *str) {
HKEY retKey;
BYTE retKeyVal[MAX_PATH * 10] = { 0 };
DWORD nSize = MAX_PATH * 10;
LONG ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\TopDomain\\e-Learning Class\\Student", 0, KEY_QUERY_VALUE | KEY_WOW64_32KEY, &retKey);
if (ret != ERROR_SUCCESS) {
return FALSE;
}
ret = RegQueryValueExA(retKey, "knock1", NULL, NULL, (LPBYTE)retKeyVal, &nSize);
RegCloseKey(retKey);
if (ret != ERROR_SUCCESS) {
return FALSE;
}
for (int i = 0; i < int(nSize); i += 4) {
retKeyVal[i + 0] = (retKeyVal[i + 0] ^ 0x50 ^ 0x45);
retKeyVal[i + 1] = (retKeyVal[i + 1] ^ 0x43 ^ 0x4c);
retKeyVal[i + 2] = (retKeyVal[i + 2] ^ 0x4c ^ 0x43);
retKeyVal[i + 3] = (retKeyVal[i + 3] ^ 0x45 ^ 0x50);
}
for (int i = 0; i < int(nSize); i += 1) {
printf("%x ", retKeyVal[i]);
if (i % 8 == 0) puts("");
}
int sum = 0;
for (int i = 0; i < int(nSize); i += 1) {
if (retKeyVal[i + 1] == 0) {
*(str + sum) = retKeyVal[i];
sum++;
if (retKeyVal[i] == 0) break;
}
}
return TRUE;
}
BOOL SetRegedit(char *str, char *ValueName, char *Value) {
HKEY retKey;
char tstr[200] = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\";
strcat(tstr, str);
LONG ret = RegCreateKey(HKEY_LOCAL_MACHINE, tstr, &retKey);
if (ret != ERROR_SUCCESS) {
return FALSE;
}
ret = RegSetValueEx(retKey,
ValueName,
0,
REG_EXPAND_SZ,
(LPBYTE)Value,
strlen(Value) + 1);
if (ret != ERROR_SUCCESS) {
return FALSE;
}
RegCloseKey(retKey);
return TRUE;
}
BOOL IsRegeditHasSet(char *str, char *ValueName) {
HKEY retKey;
char tstr[200] = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\";
strcat(tstr, str);
DWORD dwDisposition = REG_OPENED_EXISTING_KEY;
LONG ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, tstr, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &retKey, &dwDisposition);
if (ret != ERROR_SUCCESS) {
return FALSE;
}
ret = RegQueryValueEx(retKey, ValueName, NULL, NULL, NULL, NULL);
if (ret == ERROR_SUCCESS) {
return TRUE;
}
return FALSE;
}
bool SetupTrayIcon(HWND m_hWnd) {
m_nid.cbSize = sizeof(NOTIFYICONDATA);
m_nid.hWnd = m_hWnd;
m_nid.uID = 1231;
m_nid.uFlags = NIF_MESSAGE;
m_nid.uCallbackMessage = WM_MSG;
m_nid.hIcon = ::LoadIcon(::GetModuleHandle(NULL), MAKEINTRESOURCE(1231));
strcpy(m_nid.szTip, "我的任务栏程序");
return 0 != Shell_NotifyIcon(NIM_ADD, &m_nid);
}
BOOL ShowBalloonTip(LPCTSTR szMsg, LPCTSTR szTitle, DWORD dwInfoFlags = NIIF_INFO, UINT uTimeout = 0) {
m_nid.cbSize = sizeof(NOTIFYICONDATA);
m_nid.uFlags = NIF_INFO;
m_nid.uVersion = NOTIFYICON_VERSION;
m_nid.uTimeout = uTimeout;
m_nid.dwInfoFlags = dwInfoFlags;
strcpy(m_nid.szInfo, szMsg ? szMsg : _T(""));
strcpy(m_nid.szInfoTitle, szTitle ? szTitle : _T(""));
return 0 != Shell_NotifyIcon(NIM_MODIFY, &m_nid);
}
UINT GetMythwarePathFromRegedit(char *str, BOOL FLAG = 1) {
HKEY retKey;
char tstr[200] = "SOFTWARE\\WOW6432Node\\TopDomain\\e-Learning Class Standard\\1.00";
DWORD dwDisposition = REG_OPENED_EXISTING_KEY;
LONG ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, tstr, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &retKey, &dwDisposition);
if (ret != ERROR_SUCCESS) {
ShowBalloonTip("打开注册表失败", "提示");
return FALSE;
}
BYTE tByte[MAX_PATH * 2 + 1];
DWORD nSize = MAX_PATH * 2 + 1;
int sum = 0;
ret = RegQueryValueEx(retKey, "TargetDirectory", NULL, NULL, tByte, &nSize);
if (ret == ERROR_SUCCESS) {
for (int i = 0; i < int(nSize); i += 1) {
*(str + sum) = tByte[i];
if (*(str + sum++) == '\\') {
*(str + sum++) = '\\';
}
}
if (FLAG) ShowBalloonTip("获取路径成功", "提示");
return TRUE;
}
if (FLAG) ShowBalloonTip("获取路径失败", "提示");
return FALSE;
}
void Buttonable(BOOL FLAG, WORD WEI) {
switch (WEI) {
case 1: {
EnableWindow(SuspendB, FLAG);
EnableWindow(RebootB, !FLAG);
EnableWindow(NtsdKillB, FLAG);
EnableWindow(TaskillKillB, FLAG);
EnableWindow(HuifuB, FLAG);
EnableWindow(SuspendB, FLAG);
break;
}
case 2: {
EnableWindow(JcB, FLAG);
break;
}
}
return;
}
BOOL CALLBACK EnumChildWindowsProc(HWND hwndChild, LPARAM lParam) {
HMENU hmenu = GetMenu(hwndChild);
if (LOWORD(hmenu) == 1004) {
if (!IsWindowEnabled(hwndChild)) {
EnableWindow(hwndChild, TRUE);
SetWindowText(JcB, "恢复全屏按钮限制");
} else {
EnableWindow(hwndChild, FALSE);
SetWindowText(JcB, "解除全屏按钮限制");
}
return FALSE;
}
return TRUE;
}
BOOL CALLBACK EnumChildWindowsTest(HWND hwndChild, LPARAM lParam) {
EnableWindow(hwndChild, FALSE);
HMENU hmenu = GetMenu(hwndChild);
char buf[20] = {'\0'};
_ultoa(LOWORD(hmenu), buf, 10);
MessageBoxA(0, buf, buf, 0);
return TRUE;
}
VOID CALLBACK SetWindowToTopT(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
LRESULT res = SendMessage(SetFirstB, BM_GETSTATE, 0, 0);
if (res == BST_CHECKED) {
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
} else {
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
return;
}
VOID CALLBACK SetHideorShowT(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
POINT tm;
GetCursorPos(&tm);
int tsx = GetSystemMetrics(SM_CXSCREEN);
int tsy = GetSystemMetrics(SM_CYSCREEN);
if (tm.x == tsx - 1 && tm.y == tsy - 1) {
ShowWindow(hwnd, SW_HIDE);
SetCursorPos(tsx / 2, tsy / 2);
} else if (tm.x == tsx - 1 && tm.y == 0) {
ShowWindow(hwnd, SW_RESTORE);
SetCursorPos(tsx / 2, tsy / 2);
}
return;
}
VOID SetClipboard(LPCSTR str) {
if (OpenClipboard(NULL)) {
HGLOBAL hmem = GlobalAlloc(GHND, strlen(str) + 1);
LPVOID pmem = GlobalLock(hmem);
EmptyClipboard();
memcpy(pmem, str, strlen(str) + 1);
SetClipboardData(CF_TEXT, hmem);
CloseClipboard();
GlobalFree(hmem);
}
return;
}
char TempNtsdPath[MAX_PATH + 1];
VOID UseNtsd() {
if (!(fopen("ntsd.exe", "r") == NULL)) {
return;
}
HRSRC hRsrc = FindResource(NULL, MAKEINTRESOURCEA(NTSDEXE), TEXT("EXETYPE"));
if (hRsrc == NULL) {
return;
}
DWORD dwSize = SizeofResource(NULL, hRsrc);
HGLOBAL hGlobal = LoadResource(NULL, hRsrc);
LPVOID pBuffer = LockResource(hGlobal);
FILE* fp = fopen("ntsd.exe", "wb");
if (fp != NULL) {
fwrite(pBuffer, sizeof(char), dwSize, fp);
}
fclose(fp);
return;
}
unsigned int __stdcall IsStart(LPVOID lParam) {
UseNtsd();
bool FlagSetToum = false, FlagMoveShutdown = false;
while (1) {
Class = FindWindowW(NULL, BroadcastTitle);
if (Class != NULL) {
GetWindowThreadProcessId(Class, &pid);
ClassHandle = OpenThread(THREAD_ALL_ACCESS, false, GetMainThreadFromId(pid));
Buttonable(TRUE, 2);
SetWindowText(guangbotext, "广播已开启");
} else {
Buttonable(FALSE, 2);
CloseHandle(ClassHandle);
SetWindowText(guangbotext, "广播未开启");
}
Jiyu tj = GetProcessPidFromFilename(MythwareFilename);
EnterCriticalSection(&CSPID);
jiyu = tj;
LeaveCriticalSection(&CSPID);
if (tj.flag == TRUE) {
GetWindowThreadProcessId(Mythware, &tj.id);
MythwareHandle = OpenProcess(THREAD_ALL_ACCESS, false, tj.id);
Buttonable(TRUE, 1);
SetWindowText(mythwaretext, "极域已开启");
} else {
jiyu.flag = FALSE;
Buttonable(FALSE, 1);
CloseHandle(MythwareHandle);
SetWindowText(mythwaretext, "极域未开启");
}
Sleep(0);
}
return 0;
}
unsigned int _stdcall SetWindowName(LPVOID lParam) {
while (1) {
HWND hwndsec = GetNextWindow(HWND(lParam), GW_HWNDNEXT);
char tempstr[100];
GetWindowText(hwndsec, tempstr, 100);
SetWindowText(HWND(lParam), tempstr);
Sleep(500);
}
return 0;
}
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
unsigned int __stdcall KeyboardHook(LPVOID lParam) {
HHOOK m_hHOOK1 = NULL, m_hHOOK2 = NULL, m_hHOOK3 = NULL, m_hHOOK4 = NULL;
m_hHOOK1 = (HHOOK)SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
m_hHOOK2 = (HHOOK)SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
m_hHOOK3 = (HHOOK)SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
m_hHOOK4 = (HHOOK)SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
while (true) {
WaitForSingleObject(KeyBoardHookEvent, INFINITE);
UnhookWindowsHookEx(m_hHOOK1);
UnhookWindowsHookEx(m_hHOOK3);
m_hHOOK1 = (HHOOK)SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
m_hHOOK3 = (HHOOK)SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
UnhookWindowsHookEx(m_hHOOK2);
UnhookWindowsHookEx(m_hHOOK4);
m_hHOOK2 = (HHOOK)SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
m_hHOOK4 = (HHOOK)SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)KeyboardProc, GetModuleHandle(NULL), 0);
Sleep(0);
}
return 0;
}
VOID SuspendProcess(DWORD dwProcessID, BOOL fSuspend) {
HANDLE hSnapshot = CreateToolhelp32Snapshot(
TH32CS_SNAPTHREAD, dwProcessID);
if (hSnapshot != INVALID_HANDLE_VALUE) {
THREADENTRY32 te = {sizeof(te)};
BOOL fOk = Thread32First(hSnapshot, &te);
for (; fOk; fOk = Thread32Next(hSnapshot, &te)) {
if (te.th32OwnerProcessID == dwProcessID) {
HANDLE hThread = OpenThread(THREAD_SUSPEND_RESUME, FALSE, te.th32ThreadID);
if (hThread != NULL) {
if (fSuspend) {
SuspendThread(hThread);
} else {
ResumeThread(hThread);
}
}
CloseHandle(hThread);
}
}
CloseHandle(hSnapshot);
}
}
BOOL CALLBACK SetWindowFont(HWND hwndChild, LPARAM lParam) {
SendMessage(hwndChild, WM_SETFONT, (WPARAM)hFont, NULL);
return TRUE;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
switch (Message) {
case WM_CLOSE: {
}
case WM_DESTROY: {
Shell_NotifyIcon(NIM_DELETE, &m_nid);
CloseHandle(threadisstart);
CloseHandle(threadKeyboardHook);
DeleteCriticalSection(&CSPID);
UnregisterHotKey(hwnd, ID_ACCR_SHOW);
UnregisterHotKey(hwnd, ID_ACCR_HIDE);
DeleteObject(hFont);
PostQuitMessage(0);
break;
}
case WM_CTLCOLORSTATIC: {
HDC hdcStatic = (HDC)wParam;
SetBkMode(hdcStatic, TRANSPARENT);
return (INT_PTR)GetStockObject(NULL_BRUSH);
}
case WM_CREATE: {
GetTempPath(MAX_PATH, TempWorkPath);
SetCurrentDirectory(TempWorkPath);
InitializeCriticalSection(&CSPID);
SetupTrayIcon(hwnd);
RegisterHotKey(hwnd, ID_ACCR_SHOW, MOD_WIN | MOD_CONTROL | MOD_ALT, 83);
RegisterHotKey(hwnd, ID_ACCR_HIDE, MOD_WIN | MOD_CONTROL | MOD_ALT, 72);
SetWindowLong(hwnd, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
mythwaretext = CreateWindow(TEXT("static"), TEXT(""), WS_VISIBLE | WS_CHILD | WS_DLGFRAME, 10, 10, 150, 30, hwnd, NULL, HINSTANCE(hwnd), NULL);
guangbotext = CreateWindow(TEXT("static"), TEXT(""), WS_VISIBLE | WS_CHILD | WS_DLGFRAME, 170, 10, 150, 30, hwnd, NULL, HINSTANCE(hwnd), NULL);
char tstr[MAX_PATH * 2 + 1] = {};
if (GetMythwarePathFromRegedit(tstr) == TRUE) {
mythwareversiontext = CreateWindow(TEXT("static"), TEXT(tstr), WS_VISIBLE | WS_CHILD | WS_DLGFRAME, 10, 250, 310, 60, hwnd, NULL, HINSTANCE(hwnd), NULL);
} else {
mythwareversiontext = CreateWindow(TEXT("static"), TEXT("获取极域路径失败"), WS_VISIBLE | WS_CHILD | WS_DLGFRAME, 10, 250, 310, 60, hwnd, NULL, HINSTANCE(hwnd), NULL);
}
CreateWindow(TEXT("static"), TEXT("from liu_zhou"), WS_VISIBLE | WS_CHILD, 10, 310, 300, 30, hwnd, NULL, HINSTANCE(hwnd), NULL);
SuspendB = CreateWindow(TEXT("button"), TEXT("挂起极域"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 170, 50, 150, 30, hwnd, HMENU(SUSPEND_BUTTON), HINSTANCE(hwnd), NULL);
NtsdKillB = CreateWindow(TEXT("button"), TEXT("ntsd杀极域"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 10, 130, 150, 30, hwnd, HMENU(NTSDKILL_BUTTON), HINSTANCE(hwnd), NULL);
TaskillKillB = CreateWindow(TEXT("button"), TEXT("taskill杀极域"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 170, 130, 150, 30, hwnd, HMENU(TASKILLKILLD_BUTTON), HINSTANCE(hwnd), NULL);
JcB = CreateWindow(TEXT("button"), TEXT("解除全屏按钮限制"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 170, 90, 150, 30, hwnd, HMENU(JC_BUTTON), HINSTANCE(hwnd), NULL);
GetRegeditPassWdB = CreateWindow(TEXT("button"), TEXT("复制密码(注册表)"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 10, 170, 150, 30, hwnd, HMENU(GETREGEDITPASSWD_BUTTON), HINSTANCE(hwnd), NULL);
PassWdB = CreateWindow(TEXT("button"), TEXT("复制万能密码"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 170, 170, 150, 30, hwnd, HMENU(PASSWD_BUTTON), HINSTANCE(hwnd), NULL);
HuifuB = CreateWindow(TEXT("button"), TEXT("恢复极域"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 10, 90, 150, 30, hwnd, HMENU(HUIFU_BUTTON), HINSTANCE(hwnd), NULL);
RebootB = CreateWindow(TEXT("button"), TEXT("启动极域"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 10, 50, 150, 30, hwnd, HMENU(REBOOT_BUTTON), HINSTANCE(hwnd), NULL);
DeleteShutdownB = CreateWindow(TEXT("button"), TEXT("防止关机(不可逆)"), WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 10, 210, 150, 30, hwnd, HMENU(DELETSHUTDOWN_BUTTON), HINSTANCE(hwnd), NULL);
KeyboardHookB = CreateWindow(TEXT("button"), TEXT(""), WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, 170, 210, 15, 15, hwnd, HMENU(KEYBOARDHOOK_BUTTON), HINSTANCE(hwnd), NULL);
CreateWindow(TEXT("static"), TEXT("解除键盘锁"), WS_VISIBLE | WS_CHILD, 190, 210, 100, 20, hwnd, NULL, HINSTANCE(hwnd), NULL);
SetFirstB = CreateWindow(TEXT("button"), TEXT(""), WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX, 170, 230, 15, 15, hwnd, HMENU(SETFIRST_BUTTON), HINSTANCE(hwnd), NULL);
SendMessage(SetFirstB, BM_SETCHECK, BST_CHECKED, 0);
CreateWindow(TEXT("static"), TEXT("置顶窗口"), WS_VISIBLE | WS_CHILD, 190, 230, 100, 20, hwnd, NULL, HINSTANCE(hwnd), NULL);
KeyBoardHookEvent = CreateEventEx(NULL, "IsSetKeyboardHook", CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
ResetEvent(KeyBoardHookEvent);
hFont = CreateFont(-15, -7.5, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, TEXT("微软雅黑"));
EnumChildWindows(hwnd, SetWindowFont, (LPARAM)0);
threadisstart = (HANDLE)_beginthreadex(NULL, 0, IsStart, hwnd, 0, 0);
threadKeyboardHook = (HANDLE)_beginthreadex(NULL, 0, KeyboardHook, hwnd, 0, 0);
break;
}
case WM_ENDSESSION: {
return 0;
}
case WM_HOTKEY: {
switch (LOWORD(wParam)) {
case ID_ACCR_SHOW: {
ShowWindow(hwnd, SW_RESTORE);
break;
}
case ID_ACCR_HIDE: {
ShowWindow(hwnd, SW_HIDE);
break;
}
default: {
break;
}
}
break;
}
case WM_COMMAND: {
switch (LOWORD(wParam)) {
case SUSPEND_BUTTON: {
EnterCriticalSection(&CSPID);
SuspendProcess(jiyu.id, TRUE);
LeaveCriticalSection(&CSPID);
break;
}
case HUIFU_BUTTON: {
EnterCriticalSection(&CSPID);
SuspendProcess(jiyu.id, FALSE);
LeaveCriticalSection(&CSPID);
break;
}
case NTSDKILL_BUTTON: {
UseNtsd();
if (WinExec("ntsd -c q -pn studentmain.exe", SW_HIDE) <= 32) {
ShowBalloonTip("ntsd执行失败!", "提示");
}
break;
}
case JC_BUTTON: {
EnumChildWindows(Class, EnumChildWindowsProc, (LPARAM)0);
break;
}
case PASSWD_BUTTON: {
SetClipboard("mythware_super_password");
ShowBalloonTip("已复制万能密码", "提示");
break;
}
case KEYBOARDHOOK_BUTTON: {
printf("%u\n", Message);
LRESULT res = SendMessage(KeyboardHookB, BM_GETSTATE, 0, 0);
if (res == BST_CHECKED) {
SetEvent(KeyBoardHookEvent);
} else {
ResetEvent(KeyBoardHookEvent);
}
break;
}
case REBOOT_BUTTON: {
char tstr[MAX_PATH * 2 + 1];
GetWindowText(mythwareversiontext, tstr, MAX_PATH * 2);
strcat(tstr, "StudentMain.exe");
if (WinExec(tstr, SW_HIDE) <= 32) {
ShowBalloonTip("重启极域失败!", "提示");
}
break;
}
case GETREGEDITPASSWD_BUTTON: {
char str[MAX_PATH * 10] = {0};
if (GetMythwarePasswordFromRegedit(str) != FALSE) {
ShowBalloonTip("复制密码成功", "提示");
SetClipboard(str);
} else {
ShowBalloonTip("复制密码失败", "提示");
}
break;
}
case TASKILLKILLD_BUTTON: {
if (WinExec("taskkill /f /im studentmain.exe", SW_HIDE) <= 32) {
ShowBalloonTip("taskill执行失败!", "提示");
}
break;
}
case DELETSHUTDOWN_BUTTON: {
char sdpath[MAX_PATH + 1] = {};
GetMythwarePathFromRegedit(sdpath, 0);
strcat(sdpath, "Shutdown.exe");
printf("sdpath - %s", sdpath);
if (DeleteFile(sdpath)) {
ShowBalloonTip("删除Shutdown.exe文件成功", "提示");
}
else {
ShowBalloonTip("删除Shutdown.exe文件失败,文件或许已被删除,或尝试切换为管理员权限重试", "提示");
}
break;
}
}
break;
}
default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
SetProcessDPIAware();
if (!IsRegeditHasSet("MythwareHelper", "agree")) {
if (MessageBox(NULL, TISHIYU, "提示", MB_YESNO | MB_ICONWARNING) != IDYES) {
return 0;
}
if (!SetRegedit("MythwareHelper", "agree", "yes")) {
MessageBox(NULL, "写注册表失败,请尝试以管理员权限重新运行本程序,除此以外本程序不需要以管理员权限运行", "提示", MB_OK);
return 0;
}
}
WNDCLASSEX wc;
HWND hwnd;
MSG msg;
memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX);
wc.lpfnWndProc = WndProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wc.lpszClassName = TEXT("WindowClass");
wc.hIcon = LoadIcon(NULL, IDC_ICON);
wc.hIconSm = LoadIcon(NULL, IDC_ICON);
if (!RegisterClassEx(&wc)) {
MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "WindowClass", "Mythware helper", (WS_VISIBLE | WS_OVERLAPPEDWINDOW)^WS_MAXIMIZEBOX ^ WS_SIZEBOX,
CW_USEDEFAULT,
CW_USEDEFAULT,
340,
370,
NULL, NULL, hInstance, NULL);
if (hwnd == NULL) {
MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
UINT_PTR timeid1 = SetTimer(hwnd, 1, 1, SetWindowToTopT);
UINT_PTR timeid2 = SetTimer(hwnd, 2, 1, SetHideorShowT);
while (GetMessage(&msg, NULL, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
KillTimer(NULL, timeid1);
KillTimer(NULL, timeid2);
return msg.wParam;
}