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


#include <windows.h>
#include <d3d11.h>
#include <dxgi.h>
#include <string>
#include <vector>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cfloat>

#pragma comment(lib, "d3d11.lib")
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "winmm.lib")

#include "imgui/imgui.h"
#include "imgui/backends/imgui_impl_dx11.h"
#include "imgui/backends/imgui_impl_win32.h"
#include "minhook/include/MinHook.h"

// ============================================================
// math & structs
// ============================================================
struct Vec2 { float x, y; };
struct Vec3 {
    float x, y, z;
    Vec3 operator+(const Vec3& o) const { return { x + o.x, y + o.y, z + o.z }; }
    Vec3 operator-(const Vec3& o) const { return { x - o.x, y - o.y, z - o.z }; }
    Vec3 operator*(float s)      const { return { x * s, y * s, z * s }; }
    float Dot(const Vec3& o)     const { return x * o.x + y * o.y + z * o.z; }
    float Length()               const { return std::sqrt(x * x + y * y + z * z); }
    Vec3 Normalized()            const { float l = Length(); return l > 1e-4f ? Vec3{ x / l, y / l, z / l } : Vec3{ 0,0,0 }; }
};
struct Matrix4x4 { float m[4][4]; };

static float Deg2Rad(float d) { return d * 3.14159265f / 180.f; }
static float Rad2Deg(float r) { return r * 180.f / 3.14159265f; }

static bool WorldToScreen(const Vec3& w, Vec2& out, const Matrix4x4& vm, int sw, int sh) {
    float ww = vm.m[3][0] * w.x + vm.m[3][1] * w.y + vm.m[3][2] * w.z + vm.m[3][3];
    if (ww < 0.01f) return false;
    float xx = vm.m[0][0] * w.x + vm.m[0][1] * w.y + vm.m[0][2] * w.z + vm.m[0][3];
    float yy = vm.m[1][0] * w.x + vm.m[1][1] * w.y + vm.m[1][2] * w.z + vm.m[1][3];
    out.x = (sw * 0.5f) + (xx / ww) * (sw * 0.5f);
    out.y = (sh * 0.5f) - (yy / ww) * (sh * 0.5f);
    return true;
}

// ============================================================
// memory utils
// ============================================================
namespace mem {
    inline uintptr_t Base(const char* n) { return (uintptr_t)GetModuleHandleA(n); }

    inline size_t Size(const char* n) {
        auto b = Base(n); if (!b) return 0;
        auto dos = (IMAGE_DOS_HEADER*)b;
        auto nt = (IMAGE_NT_HEADERS*)(b + dos->e_lfanew);
        return nt->OptionalHeader.SizeOfImage;
    }

    inline uintptr_t Pattern(const char* mod, const char* pat) {
        auto base = Base(mod), sz = Size(mod);
        if (!base || !sz) return 0;
        std::vector<int> bytes;
        for (const char* p = pat; *p; ) {
            if (*p == ' ') { ++p; continue; }
            if (*p == '?') { bytes.push_back(-1); ++p; if (*p == '?')++p; }
            else { bytes.push_back((int)strtol(std::string(p, 2).c_str(), nullptr, 16)); p += 2; }
        }
        auto d = (uint8_t*)base;
        for (size_t i = 0; i + bytes.size() < sz; ++i) {
            bool f = true;
            for (size_t j = 0; j < bytes.size(); ++j)
                if (bytes[j] != -1 && d[i + j] != (uint8_t)bytes[j]) { f = false; break; }
            if (f) return base + i;
        }
        return 0;
    }

    inline uintptr_t Rel(uintptr_t a, int pos, int len) {
        if (!a) return 0;
        __try {
            int32_t r = *(int32_t*)(a + pos);
            return a + len + r;
        } __except (EXCEPTION_EXECUTE_HANDLER) { return 0; }
    }

    template<typename T> inline T Read(uintptr_t a) {
        if (!a) return T{};
        __try { return *(T*)a; }
        __except (EXCEPTION_EXECUTE_HANDLER) { return T{}; }
    }

    template<typename T> inline void Write(uintptr_t a, T v) {
        if (!a) return;
        __try { *(T*)a = v; }
        __except (EXCEPTION_EXECUTE_HANDLER) {}
    }
}

// ============================================================
// offsets (scan)
// ============================================================
namespace offs {
    inline uintptr_t dwEntityList = 0;
    inline uintptr_t dwLocalController = 0;
    inline uintptr_t dwLocalPawn = 0;
    inline uintptr_t dwViewMatrix = 0;
    inline uintptr_t fnCreateMove = 0;
    inline uintptr_t fnTraceShape = 0;

    inline void Init() {
        auto p1 = mem::Pattern("client.dll", "48 8B 0D ?? ?? ?? ?? 48 89 7C 24");
        if (p1) dwEntityList = mem::Rel(p1, 3, 7);

        auto p2 = mem::Pattern("client.dll", "48 8B 05 ?? ?? ?? ?? 41 89 BE");
        if (p2) dwLocalController = mem::Rel(p2, 3, 7);

        auto p3 = mem::Pattern("client.dll", "48 8B 0D ?? ?? ?? ?? 48 8B 01 48 8B 40 38");
        if (p3) dwLocalPawn = mem::Rel(p3, 3, 7);

        auto p4 = mem::Pattern("client.dll", "48 8D 0D ?? ?? ?? ?? 48 C1 E0 06");
        if (p4) dwViewMatrix = mem::Rel(p4, 3, 7);

        auto p5 = mem::Pattern("client.dll", "E8 ?? ?? ?? ?? 48 8B 4D ?? 48 85 C9");
        if (p5) fnTraceShape = mem::Rel(p5, 1, 5);

        auto p6 = mem::Pattern("client.dll", "48 8B C4 4C 89 48 18 55 56 41 55");
        if (p6) fnCreateMove = p6;
    }
}

// ============================================================
// entity
// ============================================================
struct Pawn {
    uintptr_t ptr = 0;
    bool ok() const { return ptr != 0; }
    int hp() const { return mem::Read<int>(ptr + 0x344); }
    int team() const { return mem::Read<int>(ptr + 0x3C8); }
    int flags() const { return mem::Read<int>(ptr + 0x3D4); }
    int shotsFired() const { return mem::Read<int>(ptr + 0x1C64); }
    bool alive() const { return hp() > 0; }

    Vec3 origin() const {
        uintptr_t sn = mem::Read<uintptr_t>(ptr + 0x328);
        return mem::Read<Vec3>(sn + 0xC8);
    }
    Vec3 eye() const {
        Vec3 o = origin();
        float e = mem::Read<float>(ptr + 0x14D0);
        return Vec3(o.x, o.y, o.z + e);
    }
    uintptr_t bones() const {
        uintptr_t sn = mem::Read<uintptr_t>(ptr + 0x328);
        return mem::Read<uintptr_t>(sn + 0x160 + 0x80);
    }
    Vec3 bone(int i) const {
        uintptr_t b = bones();
        if (!b) return Vec3(0, 0, 0);
        struct B { float x, y, z, w; };
        B v = mem::Read<B>(b + i * 32);
        return Vec3(v.x, v.y, v.z);
    }
    bool spotted() const {
        return mem::Read<bool>(ptr + 0x1C38);
    }
    int crosshairId() const {
        return mem::Read<int>(ptr + 0x1A28);
    }
    Vec3 aimPunch() const {
        return mem::Read<Vec3>(ptr + 0x1710);
    }
};

struct Controller {
    uintptr_t ptr = 0;
    bool ok() const { return ptr != 0; }

    Pawn pawn() const {
        uintptr_t h = mem::Read<uintptr_t>(ptr + 0x7D8);
        if (!h) return Pawn{ 0 };
        uintptr_t list = mem::Read<uintptr_t>(offs::dwEntityList);
        if (!list) return Pawn{ 0 };
        uintptr_t e = mem::Read<uintptr_t>(list + 0x10 + 8 * (h >> 9));
        if (!e) return Pawn{ 0 };
        uintptr_t result = mem::Read<uintptr_t>(e + 8 * (h & 0x1FF));
        return Pawn{ result };
    }
    const char* name() const {
        const char* n = (const char*)(ptr + 0x618);
        __try { if (n) return n; }
        __except (EXCEPTION_EXECUTE_HANDLER) {}
        return "?";
    }
    int team() const { return mem::Read<int>(ptr + 0x3E4); }
};

static Controller GetPlayer(int i) {
    uintptr_t list = mem::Read<uintptr_t>(offs::dwEntityList);
    if (!list) return Controller{ 0 };
    uintptr_t e = mem::Read<uintptr_t>(list + 0x10 + 8 * (i >> 9));
    if (!e) return Controller{ 0 };
    uintptr_t result = mem::Read<uintptr_t>(e + 8 * (i & 0x1FF));
    return Controller{ result };
}

// ============================================================
// config
// ============================================================
struct Config {
    bool  espEn = true, box = true, skel = true, hp = true, name = true, dist = true, visOnly = false;
    float col[4] = { 0.15f, 0.85f, 1.f, 1.f };
    float thick = 1.5f;

    bool  aimEn = false, aimOnKey = true;
    int   aimKey = VK_XBUTTON2;
    float aimFov = 12.f, aimSmooth = 4.f;
    int   aimBone = 6;
    bool  aimVisOnly = true;

    bool  bhopEn = false;
    bool  triggerEn = false;
    bool  rcsEn = false;
    float rcsAmount = 1.0f;
    bool  wallbang = false;
    bool  autoPeek = false;
    int   peekKey = 'C';

    bool  spinEn = false;
    float spinSpeed = 15.f;

    bool  menu = false;
    int   activeTab = 0; // 0 = Visuals, 1 = Aim, 2 = Misc
} cfg;

// ============================================================
// esp
// ============================================================
static ImU32 Col(const float c[4]) { return ImGui::GetColorU32(ImVec4(c[0], c[1], c[2], c[3])); }

static void DrawESP() {
    if (!cfg.espEn) return;
    uintptr_t vmAddr = mem::Read<uintptr_t>(offs::dwViewMatrix);
    Matrix4x4 vm = mem::Read<Matrix4x4>(vmAddr);
    ImGuiIO& io = ImGui::GetIO();
    int sw = (int)io.DisplaySize.x;
    int sh = (int)io.DisplaySize.y;
    ImDrawList* dl = ImGui::GetBackgroundDrawList();

    uintptr_t lp = mem::Read<uintptr_t>(offs::dwLocalPawn);
    if (!lp) return;
    Pawn me(lp);
    int myTeam = me.team();

    for (int i = 1; i <= 64; ++i) {
        Controller ctrl = GetPlayer(i);
        if (!ctrl.ok()) continue;
        Pawn p = ctrl.pawn();
        if (!p.ok() || !p.alive()) continue;
        if (p.team() == myTeam) continue;
        if (cfg.visOnly && !p.spotted()) continue;

        Vec3 o = p.origin();
        Vec3 h = p.bone(6);
        Vec2 so, shh;
        if (!WorldToScreen(o, so, vm, sw, sh)) continue;
        if (!WorldToScreen(h, shh, vm, sw, sh)) continue;

        float bh = so.y - shh.y;
        float bw = bh * 0.5f;
        float bx = shh.x - bw * 0.5f;
        float by = shh.y;
        ImU32 c = Col(cfg.col);

        if (cfg.box) dl->AddRect(ImVec2(bx, by), ImVec2(bx + bw, by + bh), c, 0, 0, cfg.thick);
        if (cfg.hp) {
            float f = p.hp() / 100.f;
            dl->AddRectFilled(ImVec2(bx - 6, by + bh * (1 - f)), ImVec2(bx - 2, by + bh), ImGui::GetColorU32(ImVec4(1 - f, f, 0.1f, 1)));
        }
        if (cfg.name) dl->AddText(ImVec2(bx, by - 16), c, ctrl.name());
        if (cfg.skel) {
            static const int b[][2] = { {6,5},{5,4},{4,3},{5,7},{7,8},{8,9}, {5,11},{11,12},{12,13},{4,14},{14,15},{15,16}, {4,17},{17,18},{18,19} };
            for (int j = 0; j < 15; ++j) {
                Vec2 a, c2;
                if (WorldToScreen(p.bone(b[j][0]), a, vm, sw, sh) && WorldToScreen(p.bone(b[j][1]), c2, vm, sw, sh)) {
                    dl->AddLine(ImVec2(a.x, a.y), ImVec2(c2.x, c2.y), c, cfg.thick);
                }
            }
        }
        if (cfg.dist) {
            float d = (o - me.origin()).Length() / 100.f;
            char buf[32];
            snprintf(buf, sizeof buf, "[%.0fm]", d);
            dl->AddText(ImVec2(bx, by + bh + 2), c, buf);
        }
    }
}

// ============================================================
// aimbot & trigger & rcs
// ============================================================
static Vec3 CalcAngle(const Vec3& f, const Vec3& t) {
    Vec3 d = t - f;
    float hyp = std::sqrt(d.x * d.x + d.y * d.y);
    return { Rad2Deg(std::atan2(-d.z, hyp)), Rad2Deg(std::atan2(d.y, d.x)), 0.f };
}
static float Norm(float a) { while (a > 180)a -= 360; while (a < -180)a += 360; return a; }

static void RunAimbot(void* input) {
    uintptr_t lp = mem::Read<uintptr_t>(offs::dwLocalPawn);
    if (!lp) return;
    Pawn me(lp);
    if (!me.alive()) return;

    Vec3 eye = me.eye();
    int myTeam = me.team();
    Vec3 cur = mem::Read<Vec3>((uintptr_t)input + 0x2E0);

    if (cfg.rcsEn && me.shotsFired() > 1) {
        Vec3 punch = me.aimPunch();
        cur.x -= punch.x * 2.0f * cfg.rcsAmount;
        cur.y -= punch.y * 2.0f * cfg.rcsAmount;
        mem::Write<Vec3>((uintptr_t)input + 0x2E0, cur);
    }

    if (cfg.aimEn) {
        if (!cfg.aimOnKey || (GetAsyncKeyState(cfg.aimKey) & 0x8000)) {
            float best = cfg.aimFov;
            Vec3 bestAng;
            bool has = false;

            for (int i = 1; i <= 64; ++i) {
                Controller ctrl = GetPlayer(i);
                if (!ctrl.ok()) continue;
                Pawn p = ctrl.pawn();
                if (!p.ok() || !p.alive()) continue;
                if (p.team() == myTeam) continue;

                Vec3 bone = p.bone(cfg.aimBone);
                if (bone.x == 0 && bone.y == 0 && bone.z == 0) continue;
                
                if (!cfg.wallbang && cfg.aimVisOnly && !p.spotted()) continue;

                Vec3 a = CalcAngle(eye, bone);
                float dp = Norm(a.x - cur.x);
                float dy = Norm(a.y - cur.y);
                float f = std::sqrt(dp * dp + dy * dy);
                if (f < best) {
                    best = f;
                    bestAng = a;
                    has = true;
                }
            }
            if (has) {
                float step = cfg.aimSmooth > 0.01f ? 1.f / cfg.aimSmooth : 1.f;
                Vec3 out;
                out.x = cur.x + Norm(bestAng.x - cur.x) * step;
                out.y = cur.y + Norm(bestAng.y - cur.y) * step;
                out.z = 0;
                mem::Write<Vec3>((uintptr_t)input + 0x2E0, out);
            }
        }
    }

    if (cfg.triggerEn) {
        int crossId = me.crosshairId();
        if (crossId > 0 && crossId <= 64) {
            Controller target = GetPlayer(crossId);
            if (target.ok()) {
                Pawn p = target.pawn();
                if (p.ok() && p.alive() && p.team() != myTeam) {
                    mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                    Sleep(15); 
                    mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                }
            }
        }
    }
}

// ============================================================
// misc (bhop, auto-peek, spin)
// ============================================================
static void RunMisc(void* input) {
    uintptr_t lp = mem::Read<uintptr_t>(offs::dwLocalPawn);
    if (!lp) return;
    Pawn me(lp);
    if (!me.alive()) return;

    uint32_t buttons = mem::Read<uint32_t>((uintptr_t)input + 0x38);

    if (cfg.bhopEn) {
        if (GetAsyncKeyState(VK_SPACE) & 0x8000) {
            if (me.flags() & 1) {
                mem::Write<uint32_t>((uintptr_t)input + 0x38, buttons | 2);
            }
        }
    }

    if (cfg.autoPeek) {
        static Vec3 savedPos;
        static bool isPeeking = false;
        
        if (GetAsyncKeyState(cfg.peekKey) & 0x8000) {
            if (!isPeeking) {
                savedPos = me.origin();
                isPeeking = true;
            }
        } else {
            if (isPeeking) {
                isPeeking = false;
            }
        }
    }

    if (cfg.spinEn) {
        static float g_spin = 0;
        g_spin += cfg.spinSpeed;
        if (g_spin > 360) g_spin -= 360;
        mem::Write<Vec3>((uintptr_t)input + 0x2E0, Vec3(0, g_spin, 0));
    }
}

// ============================================================
// menu (Xone Style)
// ============================================================
static void DrawMenu() {
    if (!cfg.menu) return;
    
    ImGui::SetNextWindowSize({ 620, 480 }, ImGuiCond_FirstUseEver);
    ImGui::Begin("worm shadow", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize);
    
    // ---- ЛЕВАЯ ПАНЕЛЬ (SIDEBAR) ----
    ImGui::BeginChild("Sidebar", ImVec2(160, 0), true);
    {
        ImGui::Spacing();
        ImGui::TextColored(ImVec4(0.6f, 0.2f, 1.0f, 1.0f), "WORM SHADOW");
        ImGui::TextColored(ImVec4(0.6f, 0.2f, 1.0f, 1.0f), "  :: CS2");
        ImGui::Separator();
        ImGui::Spacing(); ImGui::Spacing();

        auto TabButton = [](const char* label, int id, int* active) {
            bool isActive = (*active == id);
            if (isActive) {
                ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.6f, 0.2f, 1.0f, 1.0f));
                ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1, 1, 1, 1));
            } else {
                ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.1f, 0.1f, 0.12f, 1.0f));
                ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.6f, 0.6f, 0.6f, 1.0f));
            }
            if (ImGui::Button(label, ImVec2(140, 40))) *active = id;
            ImGui::PopStyleColor(2);
            ImGui::Spacing();
        };

        TabButton("Visuals", 0, &cfg.activeTab);
        TabButton("Aimbot", 1, &cfg.activeTab);
        TabButton("Misc", 2, &cfg.activeTab);

        // Кнопка закрытия внизу панели
        ImGui::SetCursorPosY(ImGui::GetWindowHeight() - 50);
        if (ImGui::Button("Close Menu", ImVec2(140, 35))) cfg.menu = false;
    }
    ImGui::EndChild();

    ImGui::SameLine();

    // ---- ПРАВАЯ ПАНЕЛЬ (КОНТЕНТ) ----
    ImGui::BeginChild("Content", ImVec2(0, 0), true);
    {
        ImGui::Spacing();
        if (cfg.activeTab == 0) { // VISUALS
            ImGui::TextColored(ImVec4(0.6f, 0.2f, 1.0f, 1.0f), "ESP & VISUALS");
            ImGui::Separator();
            ImGui::Spacing();
            ImGui::Checkbox("Master Switch", &cfg.espEn);
            ImGui::Checkbox("Bounding Box", &cfg.box);
            ImGui::Checkbox("Skeleton", &cfg.skel);
            ImGui::Checkbox("Health Bar", &cfg.hp);
            ImGui::Checkbox("Player Name", &cfg.name);
            ImGui::Checkbox("Distance", &cfg.dist);
            ImGui::Spacing();
            ImGui::Checkbox("Visible Only", &cfg.visOnly);
            ImGui::Spacing();
            ImGui::SliderFloat("Thickness", &cfg.thick, 0.5f, 4.f, "%.1f px");
            ImGui::ColorEdit4("ESP Color", cfg.col);
        }
        else if (cfg.activeTab == 1) { // AIMBOT
            ImGui::TextColored(ImVec4(0.6f, 0.2f, 1.0f, 1.0f), "AIMBOT & TRIGGER");
            ImGui::Separator();
            ImGui::Spacing();
            ImGui::Checkbox("Aimbot", &cfg.aimEn);
            ImGui::Checkbox("On Key (Mouse5)", &cfg.aimOnKey);
            ImGui::SliderFloat("FOV", &cfg.aimFov, 1, 90, "%.0f deg");
            ImGui::SliderFloat("Smooth", &cfg.aimSmooth, 0.5f, 20);
            ImGui::Checkbox("Wallbang (Ignore Walls)", &cfg.wallbang);
            
            const char* bn[] = { "Pelvis","Chest","Neck","Head" };
            int bi = cfg.aimBone <= 3 ? 0 : cfg.aimBone == 4 ? 1 : cfg.aimBone == 5 ? 2 : 3;
            if (ImGui::Combo("Target Bone", &bi, bn, 4)) {
                static const int map[] = { 0,4,5,6 };
                cfg.aimBone = map[bi];
            }
            ImGui::Spacing();
            ImGui::Checkbox("Triggerbot (Auto-Fire)", &cfg.triggerEn);
        }
        else if (cfg.activeTab == 2) { // MISC
            ImGui::TextColored(ImVec4(0.6f, 0.2f, 1.0f, 1.0f), "MISCELLANEOUS");
            ImGui::Separator();
            ImGui::Spacing();
            ImGui::Checkbox("Auto Bhop", &cfg.bhopEn);
            ImGui::Checkbox("Auto Peek (Hold C)", &cfg.autoPeek);
            ImGui::Spacing();
            ImGui::Checkbox("RCS (No Recoil)", &cfg.rcsEn);
            ImGui::SliderFloat("RCS Strength", &cfg.rcsAmount, 0.1f, 2.0f);
            ImGui::Spacing();
            ImGui::Checkbox("Spinbot", &cfg.spinEn);
            ImGui::SliderFloat("Spin Speed", &cfg.spinSpeed, 1, 60);
        }
    }
    ImGui::EndChild();
    
    ImGui::End();
}

// ============================================================
// hooks
// ============================================================
using PresentFn = HRESULT(__stdcall*)(IDXGISwapChain*, UINT, UINT);
using CreateMoveFn = bool(__fastcall*)(void*, void*);
static PresentFn    oPresent = nullptr;
static CreateMoveFn oCreateMove = nullptr;

static ID3D11Device* g_dev = nullptr;
static ID3D11DeviceContext* g_ctx = nullptr;
static ID3D11RenderTargetView* g_rtv = nullptr;
static HWND                    g_hwnd = nullptr;
static WNDPROC                 g_wnd = nullptr;

static void MakeRTV(IDXGISwapChain* sc) {
    ID3D11Texture2D* bb = nullptr;
    sc->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)&bb);
    if (bb) { g_dev->CreateRenderTargetView(bb, nullptr, &g_rtv); bb->Release(); }
}

extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

static LRESULT CALLBACK WndProc(HWND h, UINT m, WPARAM w, LPARAM l) {
    if (m == WM_KEYDOWN && w == VK_INSERT) {
        cfg.menu = !cfg.menu;
        if (!cfg.menu) {
            RECT r; GetClientRect(h, &r); MapWindowPoints(h, nullptr, (LPPOINT)&r, 2); ClipCursor(&r);
        }
    }

    if (cfg.menu) {
        ImGui_ImplWin32_WndProcHandler(h, m, w, l);
        if (m == WM_INPUT) return true;
        if ((m >= WM_MOUSEFIRST && m <= WM_MOUSELAST) || (m >= WM_KEYFIRST && m <= WM_KEYLAST))
            return true;
    }

    return CallWindowProc(g_wnd, h, m, w, l);
}

static HRESULT __stdcall Present(IDXGISwapChain* sc, UINT s, UINT f) {
    if (!g_dev) {
        sc->GetDevice(__uuidof(ID3D11Device), (void**)&g_dev);
        g_dev->GetImmediateContext(&g_ctx);
        DXGI_SWAP_CHAIN_DESC d; sc->GetDesc(&d);
        g_hwnd = d.OutputWindow;
        MakeRTV(sc);

        ImGui::CreateContext();
        
        ImGuiIO& io = ImGui::GetIO();
        ImFont* font = io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\segoeui.ttf", 18.0f);
        if (!font) font = io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\tahoma.ttf", 18.0f);
        if (!font) io.Fonts->AddFontDefault();

        ImGuiStyle& style = ImGui::GetStyle();
        ImGui::StyleColorsDark();
        
        style.WindowRounding    = 8.0f;
        style.FrameRounding     = 4.0f;
        style.PopupRounding     = 4.0f;
        style.ScrollbarRounding = 4.0f;
        style.GrabRounding      = 4.0f;
        style.TabRounding       = 4.0f;
        
        style.WindowPadding     = ImVec2(10, 10);
        style.FramePadding      = ImVec2(10, 6);
        style.ItemSpacing       = ImVec2(10, 10);

        // ТЕМНАЯ ТЕМА С ФИОЛЕТОВЫМ НЕОНОМ (Xone style)
        ImVec4* colors = style.Colors;
        colors[ImGuiCol_WindowBg]           = ImVec4(0.04f, 0.04f, 0.05f, 0.96f); // Почти черный
        colors[ImGuiCol_ChildBg]            = ImVec4(0.06f, 0.06f, 0.08f, 0.50f);
        colors[ImGuiCol_Border]             = ImVec4(0.25f, 0.10f, 0.40f, 0.80f); // Фиолетовая обводка
        colors[ImGuiCol_FrameBg]            = ImVec4(0.10f, 0.10f, 0.12f, 1.00f);
        colors[ImGuiCol_FrameBgHovered]     = ImVec4(0.15f, 0.15f, 0.18f, 1.00f);
        colors[ImGuiCol_FrameBgActive]      = ImVec4(0.20f, 0.20f, 0.25f, 1.00f);
        colors[ImGuiCol_TitleBg]            = ImVec4(0.04f, 0.04f, 0.05f, 1.00f);
        colors[ImGuiCol_TitleBgActive]      = ImVec4(0.04f, 0.04f, 0.05f, 1.00f);
        colors[ImGuiCol_CheckMark]          = ImVec4(0.60f, 0.20f, 1.00f, 1.00f); // Яркий фиолетовый
        colors[ImGuiCol_SliderGrab]         = ImVec4(0.60f, 0.20f, 1.00f, 1.00f);
        colors[ImGuiCol_SliderGrabActive]   = ImVec4(0.70f, 0.30f, 1.00f, 1.00f);
        colors[ImGuiCol_Button]             = ImVec4(0.10f, 0.10f, 0.12f, 1.00f);
        colors[ImGuiCol_ButtonHovered]      = ImVec4(0.60f, 0.20f, 1.0f, 0.60f);
        colors[ImGuiCol_ButtonActive]       = ImVec4(0.60f, 0.20f, 1.0f, 1.00f);
        colors[ImGuiCol_Header]             = ImVec4(0.15f, 0.15f, 0.18f, 1.00f);
        colors[ImGuiCol_HeaderHovered]      = ImVec4(0.60f, 0.20f, 1.0f, 0.50f);
        colors[ImGuiCol_HeaderActive]       = ImVec4(0.60f, 0.20f, 1.0f, 1.00f);
        colors[ImGuiCol_Text]               = ImVec4(0.90f, 0.90f, 0.95f, 1.00f);
        colors[ImGuiCol_Separator]          = ImVec4(0.20f, 0.10f, 0.30f, 0.80f);

        io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange;
        ImGui_ImplWin32_Init(g_hwnd);
        ImGui_ImplDX11_Init(g_dev, g_ctx);

        g_wnd = (WNDPROC)SetWindowLongPtr(g_hwnd, GWLP_WNDPROC, (LONG_PTR)WndProc);
    }

    RECT rect;
    GetClientRect(g_hwnd, &rect);
    float winW = (float)(rect.right - rect.left);
    float winH = (float)(rect.bottom - rect.top);
    
    ImGui::GetIO().DisplaySize = ImVec2(winW, winH);

    ImGui_ImplDX11_NewFrame();
    ImGui_ImplWin32_NewFrame();
    
    if (cfg.menu) {
        ImGui::GetIO().MouseDrawCursor = false;
        ClipCursor(NULL); 
        
        POINT p;
        GetCursorPos(&p);
        ScreenToClient(g_hwnd, &p);
        ImGui::GetIO().MousePos = ImVec2((float)p.x, (float)p.y);
    } else {
        ImGui::GetIO().MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
    }

    ImGui::NewFrame();
    DrawESP();
    DrawMenu();
    ImGui::Render();
    g_ctx->OMSetRenderTargets(1, &g_rtv, nullptr);
    ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());

    return oPresent(sc, s, f);
}

static bool __fastcall CreateMove(void* in, void* a2) {
    bool r = oCreateMove(in, a2);
    RunMisc(in);
    RunAimbot(in);
    return r;
}

// ============================================================
// init
// ============================================================
static DWORD WINAPI Main(LPVOID) {
    while (!GetModuleHandleA("client.dll")) Sleep(100);
    Sleep(1500);
    offs::Init();
    MH_Initialize();

    WNDCLASSEXA wc{ sizeof wc };
    wc.lpfnWndProc = DefWindowProcA;
    wc.hInstance = GetModuleHandleA(nullptr);
    wc.lpszClassName = "wsc";
    RegisterClassExA(&wc);
    HWND dummy = CreateWindowA("wsc", "", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, nullptr, nullptr, wc.hInstance, nullptr);

    DXGI_SWAP_CHAIN_DESC sd{};
    sd.BufferCount = 1;
    sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
    sd.OutputWindow = dummy;
    sd.SampleDesc.Count = 1;
    sd.Windowed = TRUE;
    sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;

    IDXGISwapChain* sc = nullptr; 
    ID3D11Device* dv = nullptr; 
    ID3D11DeviceContext* cx = nullptr;
    D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, nullptr, 0, D3D11_SDK_VERSION, &sd, &sc, &dv, nullptr, &cx);

    if (!sc) return 0;

    void** vt = *(void***)sc;
    MH_CreateHook(vt[8], &Present, (void**)&oPresent);
    MH_EnableHook(vt[8]);
    
    sc->Release(); dv->Release(); cx->Release();
    DestroyWindow(dummy); UnregisterClassA("wsc", wc.hInstance);

    if (offs::fnCreateMove) {
        MH_CreateHook((void*)offs::fnCreateMove, &CreateMove, (void**)&oCreateMove);
        MH_EnableHook((void*)offs::fnCreateMove);
    }

    return 0;
}

BOOL APIENTRY DllMain(HMODULE, DWORD r, LPVOID) {
    if (r == DLL_PROCESS_ATTACH) {
        DisableThreadLibraryCalls(GetModuleHandleA(nullptr));
        CreateThread(nullptr, 0, Main, nullptr, 0, nullptr);
    }
    return TRUE;
}