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


#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#include <Psapi.h>
#include <cmath>
#pragma comment(lib, "Psapi.lib")

// Смещения (проверьте для вашей версии)
#define OFFSET_DW_LOCAL_PLAYER 0x1A29B8
#define OFFSET_DW_ENTITY_LIST 0x1A2A78
#define OFFSET_M_I_HEALTH 0xF8
#define OFFSET_M_I_TEAM_NUM 0xF0
#define OFFSET_M_VEC_ORIGIN 0x130
#define OFFSET_VIEW_MATRIX 0x12EAF0

DWORD clientBase = 0;
bool espEnabled = true;

struct Vec3 { float x, y, z; };

DWORD GetLocalPlayer() {
    DWORD local;
    ReadProcessMemory(GetCurrentProcess(), (LPCVOID)(clientBase + OFFSET_DW_LOCAL_PLAYER), &local, 4, NULL);
    return local;
}

int GetHealth(DWORD entity) {
    int health;
    ReadProcessMemory(GetCurrentProcess(), (LPCVOID)(entity + OFFSET_M_I_HEALTH), &health, 4, NULL);
    return health;
}

int GetTeam(DWORD entity) {
    int team;
    ReadProcessMemory(GetCurrentProcess(), (LPCVOID)(entity + OFFSET_M_I_TEAM_NUM), &team, 4, NULL);
    return team;
}

Vec3 GetOrigin(DWORD entity) {
    Vec3 pos;
    ReadProcessMemory(GetCurrentProcess(), (LPCVOID)(entity + OFFSET_M_VEC_ORIGIN), &pos, sizeof(Vec3), NULL);
    return pos;
}

bool WorldToScreen(Vec3 world, float* matrix, int w, int h, float& sx, float& sy) {
    float x = matrix[0] * world.x + matrix[1] * world.y + matrix[2] * world.z + matrix[3];
    float y = matrix[4] * world.x + matrix[5] * world.y + matrix[6] * world.z + matrix[7];
    float ww = matrix[12] * world.x + matrix[13] * world.y + matrix[14] * world.z + matrix[15];
    if (ww < 0.01f) return false;
    sx = (w / 2) * (1 + x / ww);
    sy = (h / 2) * (1 - y / ww);
    return true;
}

void DrawRect(HDC hdc, float x, float y, float w, float h, COLORREF color) {
    HPEN pen = CreatePen(PS_SOLID, 2, color);
    HBRUSH brush = CreateSolidBrush(color);
    SelectObject(hdc, pen);
    SelectObject(hdc, brush);
    Rectangle(hdc, x - w/2, y - h/2, x + w/2, y + h/2);
    DeleteObject(pen);
    DeleteObject(brush);
}

DWORD WINAPI ESPThread(LPVOID lpParam) {
    // Ждём загрузки игры
    while (!FindWindowA(NULL, "Counter-Strike")) Sleep(100);
    
    // Находим базу hw.dll
    HMODULE mods[1024];
    DWORD needed;
    EnumProcessModules(GetCurrentProcess(), mods, sizeof(mods), &needed);
    for (unsigned i = 0; i < needed / sizeof(HMODULE); i++) {
        char name[256];
        GetModuleBaseNameA(GetCurrentProcess(), mods[i], name, sizeof(name));
        if (strcmp(name, "hw.dll") == 0) {
            clientBase = (DWORD)mods[i];
            break;
        }
    }
    
    if (!clientBase) {
        MessageBoxA(0, "hw.dll не найден", "ESP", MB_OK);
        return 0;
    }
    
    // Простое уведомление, что чит загружен
    MessageBoxA(0, "ESP загружен! Нажмите Insert для вкл/выкл", "CS 1.6 Cheat", MB_OK);
    
    // Основной цикл
    while (true) {
        if (GetAsyncKeyState(VK_INSERT) & 1) {
            espEnabled = !espEnabled;
        }
        
        if (espEnabled) {
            DWORD local = GetLocalPlayer();
            if (local) {
                int localTeam = GetTeam(local);
                float viewMatrix[16];
                for (int i = 0; i < 16; i++) {
                    ReadProcessMemory(GetCurrentProcess(), (LPCVOID)(clientBase + OFFSET_VIEW_MATRIX + i * 4), &viewMatrix[i], 4, NULL);
                }
                
                RECT rc;
                HWND gameWnd = FindWindowA(NULL, "Counter-Strike");
                GetClientRect(gameWnd, &rc);
                int w = rc.right - rc.left, h = rc.bottom - rc.top;
                
                HDC hdc = GetDC(gameWnd);
                
                for (int i = 1; i <= 32; i++) {
                    DWORD entity;
                    ReadProcessMemory(GetCurrentProcess(), (LPCVOID)(clientBase + OFFSET_DW_ENTITY_LIST + i * 4), &entity, 4, NULL);
                    if (!entity) continue;
                    if (GetTeam(entity) == localTeam) continue;
                    if (GetHealth(entity) <= 0) continue;
                    
                    Vec3 pos = GetOrigin(entity);
                    pos.z += 60.0f; // голова
                    
                    float sx, sy;
                    if (WorldToScreen(pos, viewMatrix, w, h, sx, sy)) {
                        DrawRect(hdc, sx, sy, 20, 30, RGB(255, 0, 0));
                    }
                }
                
                ReleaseDC(gameWnd, hdc);
            }
        }
        
        Sleep(16);
    }
    
    return 0;
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
    if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
        CreateThread(NULL, 0, ESPThread, NULL, 0, NULL);
    }
    return TRUE;
}