Guide Guide to ImGui Hooks for Game Hack Menus

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,380
78,998
2,414
Game Name
N/A
Anticheat
N/A
Tutorial Link
N/A
How long you been coding/hacking?
5 Years
What is Dear ImGui?

Dear ImGui is a Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies .

Dear ImGui is a bloat-free graphical user interface library for C++. It outputs optimized vertex buffers that you can render anytime in your 3D-pipeline enabled application. It is fast, portable, renderer agnostic and self-contained (no external dependencies).

Dear ImGui is designed to enable fast iterations and to empower programmers to create content creation tools and visualization / debug tools (as opposed to UI for the average end-user). It favors simplicity and productivity toward this goal, and lacks certain features normally found in more high-level libraries.

Dear ImGui is particularly suited to integration in games engine (for tooling), real-time 3D applications, fullscreen applications, embedded applications, or any applications on consoles platforms where operating system features are non-standard.

ImGui can be injected into:
DirectX9, DirectX10, DirectX11, DirectX12, OpenGL (legacy), OpenGL3/ES/ES2 (modern) & Vulkan


ocornut/imgui

ImGui Examples
ImGui has a collection of examples depending what you want to inject into, including every version of Direct3D, OpenGL & More

All of your stupid question about ImGui are solved by reading the documentation, following the guides from the ImGui github and reading this thread.

Learn how to use ImGui as a standalone application before trying to inject it into a game and feeling like an idiot when it doesn't work.

Use the latest version of imgui, many bug fixes are included.

How to inject ImGui into a D3D9 Endscene Hook


GamePhreakers - Game Modding Tutorials

- ImGui D3D9 Example Code ( not injection based)

This is from @Raylands:
ImGui initialization:
void InitImGui(IDirect3DDevice9* pDevice) {
    D3DDEVICE_CREATION_PARAMETERS CP;
    pDevice->GetCreationParameters(&CP);
    window = CP.hFocusWindow;
    ImGuiIO& io = ImGui::GetIO(); (void)io;
    io.IniFilename = NULL;
    io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
    io.Fonts->AddFontDefault();

    ImGui_ImplWin32_Init(window);
    ImGui_ImplDX9_Init(pDevice);
    initialized = true;
    return;
}
EndScene Hook:
HRESULT __stdcall hkEndScene(IDirect3DDevice9* pDevice) {

    if (!initialized) InitImGui(pDevice);
    else {
        ImGui_ImplDX9_NewFrame();
        ImGui_ImplWin32_NewFrame();

        ImGui::NewFrame();

        if (g_ShowMenu)
        {
            bool bShow = true;
            ImGui::ShowDemoWindow(&bShow);
        }

        ImGui::EndFrame();
        ImGui::Render();
        ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
    }
    return oEndScene(pDevice);
}

DirectX 11 ImGui Hook Template
https://guidedhacking.com/threads/my-directx-11-hook-template-imgui.13613/
Sh0ckFR/Universal-ImGui-D3D11-Hook

Direct3D9 ImGui Overlay
Tutorial - ImGui DirectX9 Overlay

OpenGL ImGui Hook for Assault Cube
GamePhreakers - Game Modding Tutorials

Can't interact with your menu with your mouse?
you're not setting your oWndProc correctly

oWndProc = (WNDPROC)SetWindowLongPtr(window,GWL_WNDPROC, (LONG_PTR)WndProc);
For CSGO ImGui texture glitches
Imgui isnt backing up the render state correctly. change D3DSBT_ALL to D3DSBT_PIXELSTATE in imgui_impl_dx9.cpp
For CSGO ImGui input issues
read this thread
There is a ConVar in the source sdk "cl_mouseenable" to show / hide the cursor.
If you set it to 1 you can interact like in the menu with your menu.
Personally i just press ESC to open the csgo menu.
for fps they reset mouse to center screen in a loop, to properly handle this hook getmousepos and setmousepos and when your menu is open return 0 to them so the game cant reset the position of the mouse, also when menu open use imgudrawmousecursor so u can see ur cursor

you can prolly get away with just returning 0 to setmousepos and drawing mouse with imgui when menu open, however you should do both otherwise when ur menu is open ur character will still follow ur mouse

alternatively what 0xf posted will work but should be avoided as if u ever do othergames they usually dont have this option
- Solved - How to not interact with cs:s main menu (imgui)

Cursor Issues? Mouse Cursor flickering over your menu or frozen?
- Solved - ImGui menu with csgo cheat.
- Question - ImGui cursor problem

How to display images using ImGui?
- ocornut/imgui
- ocornut/imgui
- How can i show an image in imgui window · Issue #1848 · ocornut/imgui

How to load or change fonts?
- ocornut/imgui

How to capture mouse and keyboard input in ImGui?
ocornut/imgui


Open Source ImGui AOEII Hack
Source Code - Age of Empires II Cheats - Map hack & ESP ( 2013 )

Cube 2: Sauerbraten | Aimbot - Esp - Imgui
https://github.com/Coolx2/Sauerbraten

internal C++ CSGO hack / Dll injection / D3D9 / ImGui
CelestialPaler/CSGO-Internal-Hack

ImGui BioShock Hack Tutorial
GamePhreakers - Game Modding Tutorials
GamePhreakers - Game Modding Tutorials
 
Last edited:

Eroik95

Newbie
Full Member
Sep 2, 2017
5
38
0
Hello guys,

I have a problem with my menu (imgui). In game imgui window is catched when i press my hotkey menu (css don't interact in game when my menu show up i click items etc..).
But my problem is in CSS main menu i have my hook worked (mouse hooked with wndproc) but when i click anywhere on my menu it's click throught the menu so i click "search server" etc..

Sorry for my bad english i write this without translate.

Thanks for reply
 

timb3r

Semi-Retired
Dank Tier VIP
Jul 15, 2018
768
24,668
47
Inside your hooked message proc you need to make sure ImGui's message proc is called first, you also need to make sure that you return if ImGui processes the message to avoid passing it to the main window.
C++:
// SNIP ....
LRESULT WINAPI HookedWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
        return true;

    switch (msg)
    {
// .... SNIP
 

Eroik95

Newbie
Full Member
Sep 2, 2017
5
38
0
Inside your hooked message proc you need to make sure ImGui's message proc is called first, you also need to make sure that you return if ImGui processes the message to avoid passing it to the main window.
C++:
// SNIP ....
LRESULT WINAPI HookedWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
        return true;

    switch (msg)
    {
// .... SNIP
Thanks for you for reply for i already called wndproc first, i tried multiple things but not worked. Im using an old version of imgui (1.50 WIP).
For in game not interact with UI i found this code
Code:
        *(int*)((DWORD)GetModuleHandleA("vguimatsurface.dll") + 0x139CC0);
Tried to get css main module but not worked.

Hook.cpp
Code:
    hWindow = FindWindowA("Valve001", nullptr);
    pOldWindowProc = reinterpret_cast<WNDPROC>(SetWindowLongPtr(hWindow, GWLP_WNDPROC, LONG_PTR(wnd_proc_hooked)));
Hook.h
Code:
LRESULT STDMETHODCALLTYPE    wnd_proc_hooked(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
WndProC.cpp
Code:
#include "hooks.h"


bool PressedKeys[256]{ false };
bool was_initialized = false;
WNDPROC pOldWindowProc = nullptr;
HWND hWindow = nullptr;

extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND, UINT, WPARAM, LPARAM);

LRESULT STDMETHODCALLTYPE wnd_proc_hooked(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_LBUTTONDOWN:
        PressedKeys[VK_LBUTTON] = true;
        break;
    case WM_LBUTTONUP:
        PressedKeys[VK_LBUTTON] = false;
        break;
    case WM_RBUTTONDOWN:
        PressedKeys[VK_RBUTTON] = true;
        break;
    case WM_RBUTTONUP:
        PressedKeys[VK_RBUTTON] = false;
        break;
    case WM_KEYDOWN:
        PressedKeys[wParam] = true;
        break;
    case WM_KEYUP:
        PressedKeys[wParam] = false;
        break;
    default: break;
    }

    {
        static bool isDown = false;
        static bool isClicked = false;
        if (PressedKeys[VK_INSERT])
        {
            isClicked = false;
            isDown = true;
        }
        else if (!PressedKeys[VK_INSERT] && isDown)
        {
            isClicked = true;
            isDown = false;
        }
        else
        {
            isClicked = false;
            isDown = false;
        }

        if (isClicked) 
        {
            config.menu_opened = !config.menu_opened;

        *(int*)((DWORD)GetModuleHandleA("vguimatsurface.dll") + 0x139CC0) = !config.menu_opened;
        }
    }

    if (was_initialized && config.menu_opened && ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam))
        return 1;

    return CallWindowProc(pOldWindowProc, hWnd, uMsg, wParam, lParam);
}
D3dEndscene.cpp
Code:
#include "hooks.h"
#include "../tools/config.h"
#include "../menu.h"

#include <imgui/examples/directx9_example/imgui_impl_dx9.h>

void initialize_gui(IDirect3DDevice9* vDevice)
{
    ImGui::CreateContext();
    ImGui_ImplDX9_Init(hWindow, vDevice);

    auto& style = ImGui::GetStyle();

    //style.ChildWindowRounding = 3.f;
    style.GrabRounding = 0.f;
    style.WindowRounding = 0.f;
    style.ScrollbarRounding = 3.f;
    style.FrameRounding = 3.f;
    style.WindowTitleAlign = ImVec2(0.5f, 0.5f);

    style.Colors[ImGuiCol_Text] = ImVec4(0.73f, 0.73f, 0.73f, 1.00f);
    style.Colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
    style.Colors[ImGuiCol_WindowBg] = ImVec4(0.26f, 0.26f, 0.26f, 0.95f);
    style.Colors[ImGuiCol_ChildWindowBg] = ImVec4(0.28f, 0.28f, 0.28f, 1.00f);
    style.Colors[ImGuiCol_PopupBg] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f);
    style.Colors[ImGuiCol_Border] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f);
    style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f);
    style.Colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f);
    style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f);
    style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f);
    style.Colors[ImGuiCol_TitleBg] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_TitleBgActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_MenuBarBg] = ImVec4(0.26f, 0.26f, 0.26f, 1.00f);
    style.Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.21f, 0.21f, 0.21f, 1.00f);
    style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    //style.Colors[ImGuiCol_ComboBg] = ImVec4(0.32f, 0.32f, 0.32f, 1.00f);
    style.Colors[ImGuiCol_CheckMark] = ImVec4(0.78f, 0.78f, 0.78f, 1.00f);
    style.Colors[ImGuiCol_SliderGrab] = ImVec4(0.74f, 0.74f, 0.74f, 1.00f);
    style.Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.74f, 0.74f, 0.74f, 1.00f);
    style.Colors[ImGuiCol_Button] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.43f, 0.43f, 0.43f, 1.00f);
    style.Colors[ImGuiCol_ButtonActive] = ImVec4(0.11f, 0.11f, 0.11f, 1.00f);
    style.Colors[ImGuiCol_Header] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_HeaderActive] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_Column] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
    style.Colors[ImGuiCol_ColumnHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
    style.Colors[ImGuiCol_ColumnActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
    style.Colors[ImGuiCol_ResizeGrip] = ImVec4(0.36f, 0.36f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
    style.Colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
    style.Colors[ImGuiCol_CloseButton] = ImVec4(0.59f, 0.59f, 0.59f, 1.00f);
    style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98f, 0.39f, 0.36f, 1.00f);
    style.Colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
    style.Colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
    style.Colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
    style.Colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
    style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.32f, 0.52f, 0.65f, 1.00f);
    style.Colors[ImGuiCol_ModalWindowDarkening] = ImVec4(0.20f, 0.20f, 0.20f, 0.50f);
}

HRESULT STDMETHODCALLTYPE end_scene_hooked(IDirect3DDevice9* vDevice)
{
    if (was_initialized)
    {
        ImGui_ImplDX9_NewFrame();
        ImGui::GetIO().MouseDrawCursor = config.menu_opened;

        menu->render();

        ImGui::Render();
    }
    else
    {
        was_initialized = true;
        initialize_gui(vDevice);
    }

    return o_end_scene(vDevice);
}
This is a little thing i'm stuck since 2 days, i tried to fund others method but only worked well for csgo
 

LaShakun

Jr.Coder
Full Member
Nobleman
Jan 1, 2017
128
2,378
6
first of all you have to have your engine hooked. In there you should have a function called "ClientCmd" or something like this. This function should be able to run the css console code e.g "sv_cheats 1", "bot_stop 1" etc.

C++:
void mousefix()
{
    //if delete is toggled change the bool that opens your menue to true (you dont really need this im just giving you some of my code)
    if (GetKeyState(VK_DELETE) == 1)
    {
        if (!var.men1)
        {

            //here we are "merging" two strings to have some css console code
            std::string msg = "cl_mouseenable " + std::to_string(false);
            //here we are using the engines function "ClientCmd" to run our  console code that we created above
            eng->ClientCmd(msg.c_str());

            //some testing(you dont really need this too)
            var.men1 = true;
            var.men2 = true;
            var.Menu = true;
            cout << "666" << endl;
        }
    }

    //same stuff as above just reversed
    if (GetKeyState(VK_DELETE) == 0)
    {
        if (var.men2)
        {
            std::string msg = "cl_mouseenable " + std::to_string(true);
            eng->ClientCmd(msg.c_str());
            var.men1 = false;
            var.men2 = false;
            var.Menu = false;
            cout << "888" << endl;
        }

    }
}
I apologize if I confussed you. You basicly only need
C++:
std::string msg = "cl_mouseenable " + std::to_string(false);
eng->ClientCmd(msg.c_str());
if your menue is turned on and
C++:
std::string msg = "cl_mouseenable " + std::to_string(true);
eng->ClientCmd(msg.c_str());
if you turn your menue off and your hooked engine with it's functions of course

https://guidedhacking.com/threads/guide-to-imgui-hooks-for-game-hack-menus.13993/
 
Last edited by a moderator:

Clipsy

Full Member
Dec 22, 2018
34
228
0
Hello,
I’ve decided I wanted to make a menu for my internal csgo hack and decided that imgui was a good choice. But, I can’t seem to figure out how to set it up for a menu for csgo.

If anyone has some good tutorials for setting up an imgui menu for a game please let me know.

Thanks,
Clipsy.
 

Rake

Cesspool Admin
Administrator
Jan 21, 2014
12,380
78,998
2,414
Anymore links or tips we need to include in this guide?

If you have a ImGui source code posted, link me so I can share it in this thread
 
Last edited:

Sigmaa

Meme Tier VIP
Full Member
Dec 14, 2018
292
3,528
10
If all of these resources aren't enough for you, you should go back a few steps and get some more experience. Great job compiling all these, they will definitely help alot!
 
  • Like
Reactions: Rake

scx1125

Dank Tier Donator
Mar 21, 2018
4
334
0
Warning: Speak English only
[QUOTE =“ timb3r,帖子:85442,成员:98353”]
是。查看imgui github页面上的示例部分。
[/引用]
有dx12或vulkan hook的菜单示例,我可以轻松地在dx11上工作。但是在dx12和vulkan中遇到了很多问题
 

timb3r

Semi-Retired
Dank Tier VIP
Jul 15, 2018
768
24,668
47
I have no idea what you said but it's probably something along the lines "tried it, doesn't work".

If you can't get it working with two (working) examples on the github page that leads me to believe you're pasting code.

Don't paste code.

Vulkan and DirectX 12 are much more complicated than DirectX 11. You might want to consider doing the tutorials on the DirectX Toolkit page to enhance your understanding of DX12.
 

Ramen172

Full Member
Jul 28, 2018
10
173
1
Quick question could anyone link me a good example for OpenGL ImGUI hook for AC becuase the one linked in the orignal post is not available.
 

catalinqs

Dank Tier Donator
Nobleman
Aug 2, 2019
63
553
2
Well i can't get the mouse to click, when i hover over the demowindow options it does show the animation.
I've tried reading this : Source Code - Internal Assault Cube Hack With ImGUI OpenGL but it's on opengl, i also watched some youtuber called Null but i couldn't quite make out some stuff.
I've tried ocornut/imgui still nothing changed
i also tried reading :
C++:
// SNIP ....
LRESULT WINAPI HookedWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
        return true;

    switch (msg)
    {
// .... SNIP
didn't understood most of it so i couldn't use it.
I've also looked into this CelestialPaler/CSGO-Internal-Hack found familiar things but couldn't pin point what he did modify regarding the clicking problem ¯\_(ツ)_/¯

The clicking works i mean by using this:
C++:
for (int i = 0; i < 5; i++) ImGui::GetIO().MouseDown[i] = false;
            if (GetAsyncKeyState(VK_LBUTTON))
            {
                std::cout << "clicked\n";

                for (int i = 0; i < 5; i++) ImGui::GetIO().MouseDown[i] = true;

            }
but i want for the click from the imgui to work
 
Last edited:

LaShakun

Jr.Coder
Full Member
Nobleman
Jan 1, 2017
128
2,378
6
Well i can't get the mouse to click, when i hover over the demowindow options it does show the animation.
I've tried reading this : Source Code - Internal Assault Cube Hack With ImGUI OpenGL but it's on opengl, i also watched some youtuber called Null but i couldn't quite make out some stuff.
I've tried ocornut/imgui still nothing changed
i also tried reading :
C++:
// SNIP ....
LRESULT WINAPI HookedWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
        return true;

    switch (msg)
    {
// .... SNIP
didn't understood most of it so i couldn't use it.
I've also looked into this CelestialPaler/CSGO-Internal-Hack found familiar things but couldn't pin point what he did modify regarding the clicking problem ¯\_(ツ)_/¯

The clicking works i mean by using this:
C++:
for (int i = 0; i < 5; i++) ImGui::GetIO().MouseDown[i] = false;
            if (GetAsyncKeyState(VK_LBUTTON))
            {
                std::cout << "clicked\n";

                for (int i = 0; i < 5; i++) ImGui::GetIO().MouseDown[i] = true;

            }
but i want for the click from the imgui to work
Maybe this'll help you eyyyyyyy3/_OGH
Take a look at Hooked_LockCursor and oLockCursor = ...
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods