Другое С/С++ Вопрос - Ответ

kin4stat

mq-team
Всефорумный модератор
2,731
4,693
игра вылетает, что не так?

C++:
#include <Windows.h>
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "d3dx9.lib")

typedef HRESULT(WINAPI* _EndScene)(IDirect3DDevice9*); //прототип
_EndScene oEndScene; //экземпляр прототипа, для возврата оригинала

typedef HRESULT(WINAPI* _Reset)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*);
_Reset oReset;


HRESULT WINAPI myEndScene(IDirect3DDevice9* m_pDevice)
{
      ImGui_ImplDX9_NewFrame();
      ImGui_ImplWin32_NewFrame();
      ImGui::NewFrame();

      ImGui::EndFrame();
      ImGui::Render();
      ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
    return oEndScene(m_pDevice); // возврат оригинала
}

HRESULT WINAPI myReset(IDirect3DDevice9* m_pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
    auto  result = oReset(m_pDevice, pPresentationParameters);
    return result;
}

void InitHook()
{
    void** vTableDevice = *(void***)(*(DWORD*)0xC97C28); // адрес Device
    VMTHookManager* vmtHooks = new VMTHookManager(vTableDevice);
    oEndScene = (_EndScene)vmtHooks->Hook(42, (void*)myEndScene);  // 42 - номер EndScene
}

int WINAPI Thread()
{
    while (*(DWORD*)0xC8D4C0 != 9) // проверка на статус загрузки игры
        Sleep(100);
    InitHook();
    return 0;
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
    if (dwReason == DLL_PROCESS_ATTACH)
        CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)Thread, NULL, NULL, NULL);
    return TRUE;
}
ImGui_ImplDX9_InvalidateDeviceObjects(); в Reset
 
  • Нравится
Реакции: !Sam#0235

!Sam#0235

Активный
105
35
ImGui_ImplDX9_InvalidateDeviceObjects(); в Reset
продолжать терпеть неудачу
1661122980262.png
 

kin4stat

mq-team
Всефорумный модератор
2,731
4,693
  • Влюблен
Реакции: !Sam#0235

kin4stat

mq-team
Всефорумный модератор
2,731
4,693
спасибо, еще один вопрос, как добавить движение окну?
 
  • Нравится
Реакции: !Sam#0235

savva7906

Новичок
2
0
Как объединить 2 main в 1 и привязать к imgui меню?

Код:
#include "memory.h"
#include "vector.h"
#include <thread>

namespace offset

{
    constexpr ::std::ptrdiff_t  localPlayer = 0xDC04CC;
    constexpr ::std::ptrdiff_t  flags = 0x104;
    constexpr ::std::ptrdiff_t  forceJump = 0x52868EC;
    constexpr ::std::ptrdiff_t  entityList = 0x52868EC;
    constexpr ::std::ptrdiff_t  teamNum = 0xF4;
    // клиент
    constexpr ::std::ptrdiff_t dwLocalPlayer = 0xDC04CC;
    constexpr ::std::ptrdiff_t dwEntityList = 0x4DDC90C;

    // двигатель
    constexpr ::std::ptrdiff_t dwClientState = 0x58CFDC;
    constexpr ::std::ptrdiff_t dwClientState_ViewAngles = 0x4D90;
    constexpr ::std::ptrdiff_t dwClientState_GetLocalPlayer = 0x180;
   
    // организация

    constexpr ::std::ptrdiff_t m_dwBoneMatrix = 0x26A8;
    constexpr ::std::ptrdiff_t m_bDormant = 0xED;
    constexpr ::std::ptrdiff_t m_iTeamNum = 0xF4;
    constexpr ::std::ptrdiff_t m_lifeState = 0x25F;
    constexpr ::std::ptrdiff_t m_vecOrigin = 0x138;
    constexpr ::std::ptrdiff_t m_vecViewOffset = 0x108;
    constexpr ::std::ptrdiff_t m_aimPunchAngle = 0x303C;
    constexpr ::std::ptrdiff_t m_bSpottedByMask = 0x980;
}


constexpr Vector3 CalculateAngle(
    const Vector3& localPosition,
    const Vector3& enemyPosition,
    const Vector3& viewAngles) noexcept
{
    return ((enemyPosition - localPosition).ToAngle() - viewAngles);
}

main()

{

    // инициализировать класс памяти

    const auto memory = Memory{ "csgo.exe" };



    // адреса модулей

    const auto client = memory.GetModuleAddress("client.dll");
    const auto engine = memory.GetModuleAddress("engine.dll");



    // бесконечный цикл

    while (true)

    {

        std::this_thread::sleep_for(std::chrono::milliseconds(1));



        // кнопка aimbot

        if (!GetAsyncKeyState(VK_XBUTTON2))

            continue;



        // получить местнахождения игрока

        const auto localPlayer = memory.Read<std::uintptr_t>(client + offset::dwLocalPlayer);

        const auto localTeam = memory.Read<std::int32_t>(localPlayer + offset::m_iTeamNum);



        // eye position = origin + viewOffset

        const auto localEyePosition = memory.Read<Vector3>(localPlayer + offset::m_vecOrigin) +

            memory.Read<Vector3>(localPlayer + offset::m_vecViewOffset);



        const auto clientState = memory.Read<std::uintptr_t>(engine + offset::dwClientState);



        const auto localPlayerId =

            memory.Read<std::int32_t>(clientState + offset::dwClientState_GetLocalPlayer);



        const auto viewAngles = memory.Read<Vector3>(clientState + offset::dwClientState_ViewAngles);

        const auto aimPunch = memory.Read<Vector3>(localPlayer + offset::m_aimPunchAngle) * 2;



        // значение fov aimbot

        auto bestFov = 8.f;

        auto bestAngle = Vector3{ };



        for (auto i = 1; i <= 360; ++i)

        {

            const auto player = memory.Read<std::uintptr_t>(client + offset::dwEntityList + i * 0x10);



            if (memory.Read<std::int32_t>(player + offset::m_iTeamNum) == localTeam)

                continue;



            if (memory.Read<bool>(player + offset::m_bDormant))

                continue;



            if (memory.Read<std::int32_t>(player + offset::m_lifeState))

                continue;



            if (memory.Read<std::int32_t>(player + offset::m_bSpottedByMask) & (1 << localPlayerId))

            {

                const auto boneMatrix = memory.Read<std::uintptr_t>(player + offset::m_dwBoneMatrix);



                // положение головы игрока в 3D-пространстве

                //индекс костей

                const auto playerHeadPosition = Vector3{

                    memory.Read<float>(boneMatrix + 0x30 * 8 + 0x0C),

                    memory.Read<float>(boneMatrix + 0x30 * 8 + 0x1C),

                    memory.Read<float>(boneMatrix + 0x30 * 8 + 0x2C)

                };



                const auto angle = CalculateAngle(

                    localEyePosition,

                    playerHeadPosition,

                    viewAngles + aimPunch

                );



                const auto fov = std::hypot(angle.x, angle.y);



                if (fov < bestFov)

                {

                    bestFov = fov;

                    bestAngle = angle;

                }

            }

        }



        // плавность aimbot

        if (!bestAngle.IsZero())

            memory.Write<Vector3>(clientState + offset::dwClientState_ViewAngles, viewAngles + bestAngle / 1.f); // значение smoothing

    }



}



main()

{
    const auto memory = Memory{ "csgo.exe" };
    const auto client = memory.GetModuleAddress("client.dll");
    while (true)
    {
        std::this_thread::sleep_for(std::chrono::milliseconds(1));
        const auto localPlayer = memory.Read<std::uintptr_t>(client + offset::localPlayer);

        if (!localPlayer)
            continue;

        const auto localPlayerTeam = memory.Read<std::uintptr_t>(localPlayer + offset::teamNum);
        const auto localPlayerFlags = memory.Read<std::uintptr_t>(localPlayer + offset::flags);

        // сам бхоп
        if (GetAsyncKeyState(VK_SPACE))
            (localPlayerFlags & (1 << 0)) ?
            memory.Write<std::uintptr_t>(client + offset::forceJump, 6) :
            memory.Write<std::uintptr_t>(client + offset::forceJump, 4);
    }
}
 
Последнее редактирование модератором:

F0RQU1N and

Известный
1,305
491
Как объединить 2 main в 1 и привязать к imgui меню?

Код:
#include "memory.h"
#include "vector.h"
#include <thread>

namespace offset

{
    constexpr ::std::ptrdiff_t  localPlayer = 0xDC04CC;
    constexpr ::std::ptrdiff_t  flags = 0x104;
    constexpr ::std::ptrdiff_t  forceJump = 0x52868EC;
    constexpr ::std::ptrdiff_t  entityList = 0x52868EC;
    constexpr ::std::ptrdiff_t  teamNum = 0xF4;
    // клиент
    constexpr ::std::ptrdiff_t dwLocalPlayer = 0xDC04CC;
    constexpr ::std::ptrdiff_t dwEntityList = 0x4DDC90C;

    // двигатель
    constexpr ::std::ptrdiff_t dwClientState = 0x58CFDC;
    constexpr ::std::ptrdiff_t dwClientState_ViewAngles = 0x4D90;
    constexpr ::std::ptrdiff_t dwClientState_GetLocalPlayer = 0x180;
  
    // организация

    constexpr ::std::ptrdiff_t m_dwBoneMatrix = 0x26A8;
    constexpr ::std::ptrdiff_t m_bDormant = 0xED;
    constexpr ::std::ptrdiff_t m_iTeamNum = 0xF4;
    constexpr ::std::ptrdiff_t m_lifeState = 0x25F;
    constexpr ::std::ptrdiff_t m_vecOrigin = 0x138;
    constexpr ::std::ptrdiff_t m_vecViewOffset = 0x108;
    constexpr ::std::ptrdiff_t m_aimPunchAngle = 0x303C;
    constexpr ::std::ptrdiff_t m_bSpottedByMask = 0x980;
}


constexpr Vector3 CalculateAngle(
    const Vector3& localPosition,
    const Vector3& enemyPosition,
    const Vector3& viewAngles) noexcept
{
    return ((enemyPosition - localPosition).ToAngle() - viewAngles);
}

main()

{

    // инициализировать класс памяти

    const auto memory = Memory{ "csgo.exe" };



    // адреса модулей

    const auto client = memory.GetModuleAddress("client.dll");
    const auto engine = memory.GetModuleAddress("engine.dll");



    // бесконечный цикл

    while (true)

    {

        std::this_thread::sleep_for(std::chrono::milliseconds(1));



        // кнопка aimbot

        if (!GetAsyncKeyState(VK_XBUTTON2))

            continue;

       
  std::this_thread::sleep_for(std::chrono::milliseconds(1));
        const auto localPlayer = memory.Read<std::uintptr_t>(client + offset::localPlayer);

        if (!localPlayer)
            continue;

        const auto localPlayerTeam = memory.Read<std::uintptr_t>(localPlayer + offset::teamNum);
        const auto localPlayerFlags = memory.Read<std::uintptr_t>(localPlayer + offset::flags);

        // сам бхоп
        if (GetAsyncKeyState(VK_SPACE))
            (localPlayerFlags & (1 << 0)) ?
            memory.Write<std::uintptr_t>(client + offset::forceJump, 6) :
            memory.Write<std::uintptr_t>(client + offset::forceJump, 4);
    }

        // получить местнахождения игрока

        const auto localPlayer = memory.Read<std::uintptr_t>(client + offset::dwLocalPlayer);

        const auto localTeam = memory.Read<std::int32_t>(localPlayer + offset::m_iTeamNum);



        // eye position = origin + viewOffset

        const auto localEyePosition = memory.Read<Vector3>(localPlayer + offset::m_vecOrigin) +

            memory.Read<Vector3>(localPlayer + offset::m_vecViewOffset);



        const auto clientState = memory.Read<std::uintptr_t>(engine + offset::dwClientState);



        const auto localPlayerId =

            memory.Read<std::int32_t>(clientState + offset::dwClientState_GetLocalPlayer);



        const auto viewAngles = memory.Read<Vector3>(clientState + offset::dwClientState_ViewAngles);

        const auto aimPunch = memory.Read<Vector3>(localPlayer + offset::m_aimPunchAngle) * 2;



        // значение fov aimbot

        auto bestFov = 8.f;

        auto bestAngle = Vector3{ };



        for (auto i = 1; i <= 360; ++i)

        {

            const auto player = memory.Read<std::uintptr_t>(client + offset::dwEntityList + i * 0x10);



            if (memory.Read<std::int32_t>(player + offset::m_iTeamNum) == localTeam)

                continue;



            if (memory.Read<bool>(player + offset::m_bDormant))

                continue;



            if (memory.Read<std::int32_t>(player + offset::m_lifeState))

                continue;



            if (memory.Read<std::int32_t>(player + offset::m_bSpottedByMask) & (1 << localPlayerId))

            {

                const auto boneMatrix = memory.Read<std::uintptr_t>(player + offset::m_dwBoneMatrix);



                // положение головы игрока в 3D-пространстве

                //индекс костей

                const auto playerHeadPosition = Vector3{

                    memory.Read<float>(boneMatrix + 0x30 * 8 + 0x0C),

                    memory.Read<float>(boneMatrix + 0x30 * 8 + 0x1C),

                    memory.Read<float>(boneMatrix + 0x30 * 8 + 0x2C)

                };



                const auto angle = CalculateAngle(

                    localEyePosition,

                    playerHeadPosition,

                    viewAngles + aimPunch

                );



                const auto fov = std::hypot(angle.x, angle.y);



                if (fov < bestFov)

                {

                    bestFov = fov;

                    bestAngle = angle;

                }

            }

        }



        // плавность aimbot

        if (!bestAngle.IsZero())

            memory.Write<Vector3>(clientState + offset::dwClientState_ViewAngles, viewAngles + bestAngle / 1.f); // значение smoothing

    }



}
вот так наверно, не проверял.
не совсем понял вопроса "как привязать к имгуй"? что значит привязать? а вообще у тебя же чит экстернал, тебе нужно создавать окно и поверх игры этот имгуй рисовать а не в игре
 
  • Нравится
Реакции: savva7906

savva7906

Новичок
2
0
вот так наверно, не проверял.
не совсем понял вопроса "как привязать к имгуй"? что значит привязать? а вообще у тебя же чит экстернал, тебе нужно создавать окно и поверх игры этот имгуй рисовать а не в игре
Спасибо код собирается но аим бот не работает а бхоп работает при нажатие кнопки аима и пробела
 

Dark_Knight

Me, me and me.
Друг
4,056
2,075
тот же результат. мне нужно получать ABCDEF, обрезая два последних символа
Посмотреть вложение 164485
Не допонял сначала. Щас (color >> 8). Хотя зачем тебе это я фиг знает. Если ты хочешь цвет игрока так выводит, то мне проще альфа канал установить на FF значение.
 
  • Нравится
Реакции: yung milonov

Savchik Blazer

Но я, мечту свою лелея...
Проверенный
672
292
Как можно сконвертировать экранные координаты игры в экранные координаты системы без апи?
 
  • Нравится
Реакции: Z3roKwq