跳到正文

休闲·娱乐

实用程序

dengxk约 14 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 14 分钟

版本

  1. v2当前
  2. v1

使用Deepseek“辅助”编写
其实全是Deepseek写的
1.解除注册表、任务管理器及管理控制台限制

C++
#include <windows.h>
#include <cstdio>
#include <vector>
#include <clocale>
#include <cwchar>

struct RegSetting {
    HKEY rootKey;
    const char* subKey;
    const char* valueName;
    DWORD value;
};

int main() {
    printf("[I] 这个程序将解除通过各种方式禁用的注册表编辑器、任务管理器和管理控制台\n");
    printf("[W] 注意,在机房使用时务必小心,后果自负\n");
    printf("[I] 按任意键开始\n");
    getchar();

    std::vector<RegSetting> settings = {
        { HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", "DisableRegistryTools", 0 },
        { HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", "DisableTaskMgr", 0 },
        { HKEY_CURRENT_USER, "Software\\Policies\\Microsoft\\MMC\\{8FC0B734-A0E1-11D1-A7D3-0000F87571E3}", "Restrict_Run", 0 },
        { HKEY_CURRENT_USER, "Software\\Policies\\Microsoft\\MMC", "RestrictToPermittedSnapins", 0 },
        { HKEY_CURRENT_USER, "Software\\Policies\\Microsoft\\MMC", "Restrict_Run", 0 }
    };

    for (const auto& setting : settings) {
        HKEY hKey;
        DWORD disposition;

        // 使用多字节字符集API
        LONG result = RegCreateKeyExA(
            setting.rootKey,
            setting.subKey,
            0,
            NULL,
            REG_OPTION_NON_VOLATILE,
            KEY_WRITE,  // 修正为KEY_WRITE
            NULL,
            &hKey,
            &disposition
        );

        if (result == ERROR_SUCCESS) {
            result = RegSetValueExA(
                hKey,
                setting.valueName,
                0,
                REG_DWORD,
                reinterpret_cast<const BYTE*>(&setting.value),
                sizeof(setting.value)
            );

            if (result == ERROR_SUCCESS) {
                printf("[+] 成功修改: %s\\%s\n", setting.subKey, setting.valueName);
            } else {
                printf("[-] 修改失败: %s\\%s (错误代码: 0x%X)\n", setting.subKey, setting.valueName, result);
                if (result == ERROR_ACCESS_DENIED) {
                    printf("    原因: 访问被拒绝 - 权限不足\n");
                }
            }
            RegCloseKey(hKey);
        } else {
            printf("[-] 打开注册表项失败: %s (错误代码: 0x%X)\n", setting.subKey, result);
            if (result == ERROR_ACCESS_DENIED) {
                printf("    原因: 访问被拒绝 - 权限不足\n");
            }
        }
    }

    printf("\n尝试刷新组策略...\n");
    HMODULE hModule = LoadLibraryA("user32.dll");
    if (hModule) {
        typedef int (WINAPI * SendMessageTimeoutFunc)(HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR);
        auto SendMessageTimeout = reinterpret_cast<SendMessageTimeoutFunc>(
            GetProcAddress(hModule, "SendMessageTimeoutA"));

        if (SendMessageTimeout) {
            DWORD_PTR result;
            SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
                               reinterpret_cast<LPARAM>("Policy"), SMTO_ABORTIFHUNG,
                               5000, &result);
            printf("[!] 组策略刷新信号已发送\n");
        }
        FreeLibrary(hModule);
    }

    printf("\n操作完成。重要提示:\n");
    printf("1. 修改可能需要注销后重新登录或重启才能生效\n");
    printf("2. 组策略刷新(默认90分钟一次)可能会覆盖这些设置\n");
    printf("3. 安全软件(如机房管家)可能会阻止或恢复这些修改\n");
    printf("4. 在学校环境中尝试这些操作可能导致纪律处分\n");
    printf("[I] 按任意键结束");
    getchar();
    return 0;
}

2.干掉学生机房管理助手

C++
#include <windows.h>
#include <tlhelp32.h>
#include <cctype>
#include <cstring>
#include <cstdio>

// 不区分大小写的字符串比较函数
bool iequals(const char* a, const char* b) {
    while (*a && *b) {
        if (std::tolower(static_cast<unsigned char>(*a)) !=
            std::tolower(static_cast<unsigned char>(*b))) {
            return false;
        }
        ++a;
        ++b;
    }
    return *a == *b;
}

void ForceKillProcess(const char* processName) {
    HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (hSnapshot == INVALID_HANDLE_VALUE) return;

    PROCESSENTRY32 pe32;
    pe32.dwSize = sizeof(PROCESSENTRY32);

    if (Process32First(hSnapshot, &pe32)) {
        do {
            if (iequals(pe32.szExeFile, processName)) {
                HANDLE hProcess = OpenProcess(
                    PROCESS_TERMINATE,
                    FALSE,
                    pe32.th32ProcessID
                );

                if (hProcess) {
                    TerminateProcess(hProcess, 1);
                    CloseHandle(hProcess);
                    printf("[+] 已杀死进程: %s (PID: %d)\n", processName, pe32.th32ProcessID);
                }
            }
        } while (Process32Next(hSnapshot, &pe32));
    }
    CloseHandle(hSnapshot);
}

int main() {
    // 强制终止目标进程
    printf("[I] 这个程序将杀死烦人的“学生机房管理助手”的进程\n");
    printf("[I] 进程可能包括:tqqmk.exe、zmserv.exe、main.exe、jfglzs.exe、przs.exe、srvany.exe\n")
    printf("[I] 本程序将杀死这些进程,请注意保存工作和程序,防止误杀\n")
    printf("[W] 注意,在机房使用时务必小心,后果自负\n");
    printf("[I] 按任意键开始\n");
    getchar();
    ForceKillProcess("tqqmk.exe");
    ForceKillProcess("zmserv.exe");
	ForceKillProcess("main.exe");
	ForceKillProcess("jfglzs.exe");
	ForceKillProcess("przs.exe");
	ForceKillProcess("srvany.exe");
	printf("[I] 完成,按任意键结束");
	getchar();
    return 0;
}

3.强制解除全屏(用处不大)

C++
#include <Windows.h>
#include <cstdio>

// 判断是否是系统关键窗口
bool IsSystemWindow(HWND hwnd) {
    char className[256];
    GetClassNameA(hwnd, className, sizeof(className));

    // 跳过任务栏、桌面窗口等
    return (strcmp(className, "Shell_TrayWnd") == 0) ||
           (strcmp(className, "Progman") == 0) ||
           (strcmp(className, "Button") == 0); // 开始按钮
}

// 窗口枚举回调函数
BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM) {
    if (!IsWindowVisible(hwnd)) return TRUE;
    if (IsSystemWindow(hwnd)) return TRUE;

    // 解除全屏状态
    WINDOWPLACEMENT wp;
    GetWindowPlacement(hwnd, &wp);
    if (wp.showCmd == SW_SHOWMAXIMIZED) {
        ShowWindow(hwnd, SW_RESTORE);
    }

    // 解除置顶属性
    LONG exStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
    if (exStyle & WS_EX_TOPMOST) {
        SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
                     SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
    }

    return TRUE;
}

int main() {
    // 枚举并处理所有窗口
    printf("[I] 本程序将强制把全屏窗口正常化\n");
	printf("[W] 注意,在机房使用时务必小心,后果自负\n");
    printf("[I] 按任意键开始,按Ctrl+C结束\n");
    getchar();
    while (true)
    {
    	EnumWindows(EnumWindowsProc, 0);
    }
    return 0;
}

4.解除鼠标限制(用处不大)

C++
#include <Windows.h>

int main() {
    // 方法1:完全解除剪切区域(推荐)
    while (true) {
        ClipCursor(NULL);  // 解除鼠标限制
        //Sleep(10);         // 每10毫秒执行一次

        // 按ESC键退出程序
        if (GetAsyncKeyState(VK_ESCAPE) & 0x8000)
            break;
    }

    // 方法2:重置为整个屏幕区域(备选)
    /*
    RECT screenRect;
    GetWindowRect(GetDesktopWindow(), &screenRect); // 获取整个屏幕区域

    while (true) {
        ClipCursor(&screenRect);  // 将鼠标限制到整个屏幕
        Sleep(10);
        if (GetAsyncKeyState(VK_ESCAPE) & 0x8000)
            break;
    }
    */

    return 0;
}
原文