Загрузка данных


#include <Windows.h>

#define CROSSHAIR_ADDR 0x110B5314

HANDLE hProcess = NULL;
bool triggerEnabled = true;

void Shoot() {
    INPUT input = {0};
    input.type = INPUT_MOUSE;
    input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
    SendInput(1, &input, sizeof(INPUT));
    Sleep(10);
    input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
    SendInput(1, &input, sizeof(INPUT));
}

LRESULT CALLBACK MenuProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    switch (msg) {
        case WM_COMMAND:
            if (LOWORD(wParam) == 1) {
                triggerEnabled = true;
                SetWindowTextW(hwnd, L"Trigger Bot CS 1.6 [ON]");
            }
            if (LOWORD(wParam) == 2) {
                triggerEnabled = false;
                SetWindowTextW(hwnd, L"Trigger Bot CS 1.6 [OFF]");
            }
            return 0;
        case WM_CLOSE:
            DestroyWindow(hwnd);
            return 0;
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    }
    return DefWindowProcW(hwnd, msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) {
    WNDCLASSEXW wc = {0};
    wc.cbSize = sizeof(WNDCLASSEXW);
    wc.lpfnWndProc = MenuProc;
    wc.hInstance = hInst;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    wc.lpszClassName = L"TriggerMenuClass";
    RegisterClassExW(&wc);
    
    int screenX = GetSystemMetrics(SM_CXSCREEN);
    int screenY = GetSystemMetrics(SM_CYSCREEN);
    
    HWND hMenu = CreateWindowExW(
        WS_EX_TOPMOST,
        L"TriggerMenuClass",
        L"Trigger Bot CS 1.6 [ON]",
        WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_VISIBLE,
        (screenX - 250) / 2, (screenY - 120) / 2,
        250, 130,
        NULL, NULL, hInst, NULL
    );
    
    CreateWindowW(L"BUTTON", L"ON", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
                  20, 50, 80, 35, hMenu, (HMENU)1, hInst, NULL);
    CreateWindowW(L"BUTTON", L"OFF", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
                  130, 50, 80, 35, hMenu, (HMENU)2, hInst, NULL);
    CreateWindowW(L"STATIC", L"Rutube: https://rutube.ru/channel/43805541",
                  WS_VISIBLE | WS_CHILD,
                  20, 15, 210, 25, hMenu, NULL, hInst, NULL);
    
    while (true) {
        HWND gameWnd = FindWindowW(NULL, L"Counter-Strike");
        if (gameWnd && !hProcess) {
            DWORD pid;
            GetWindowThreadProcessId(gameWnd, &pid);
            hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
        }
        
        if (hProcess) {
            DWORD exitCode;
            GetExitCodeProcess(hProcess, &exitCode);
            if (exitCode != STILL_ACTIVE) {
                CloseHandle(hProcess);
                hProcess = NULL;
            }
        }
        
        if (triggerEnabled && hProcess) {
            int val = 0;
            ReadProcessMemory(hProcess, (LPCVOID)CROSSHAIR_ADDR, &val, sizeof(int), NULL);
            if (val == 2) {
                static int last = 0;
                int now = GetTickCount();
                if (now - last > 100) {
                    Shoot();
                    last = now;
                }
            }
        }
        
        MSG msg;
        while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        Sleep(10);
    }
    
    return 0;
}