easy-to-use C++ starter kit for creating DirectX 11 game overlays using Dear ImGui. This project provides a solid foundation for injecting a customizable ImGui interface into DirectX 11 applications games, leveraging MinHook for function hooking and supporting ImGui's awesome docking and viewport features.
This means you can have ImGui windows that dock together within the game, or even drag them out as separate windows on your desktop
- DirectX 11 Hooking: Targets
PresentandResizeBuffersfor seamless ImGui rendering and window resize handling. - MinHook Integration: Uses the powerful MinHook library for x86 and x64 function hooking.
- Dear ImGui with Docking & Viewports:
- Full docking support (
IMGUI_HAS_DOCK). - Multi-viewport support (
IMGUI_HAS_VIEWPORT) allows ImGui windows to be moved outside the main game window.
- Full docking support (
- CMake Build System: Easy to configure and build.
- x86 & x64 Support: CMake configuration handles both architectures.
- Basic Menu Example: Includes a simple
menu.cppto get you started with your own UI. - Enhanced Stability: Includes error handling, logging (
OutputDebugStringW), and careful resource management to minimize crashes. - Clear Code Structure: Separated logic for DLL entry (
dllmain.cpp), hooking (hooks.cpp), and UI (menu.cpp).
You'll need to grab these libraries and place them in a libs folder (or adjust paths in CMakeLists.txt):
-
Dear ImGui (Docking Branch):
- Source: https://github.com/ocornut/imgui
- Branch: Make sure you're using the
dockingbranch. - Setup: Place the ImGui source directory (e.g.,
imgui-docking) in yourC:/libs/folder or updateIMGUI_PATHinCMakeLists.txt. The current setup expectsC:/libs/imgui-docking.
-
MinHook:
- Source: https://github.com/TsudaKageyu/minhook
- Version: The project was set up with v1.3.3 (the "bin" release was used in later iterations of the prompt, meaning
MinHook.dlland its import.lib). - Setup:
- If using the binary release (contains
.dlland.libin abinfolder): Place the MinHook directory (e.g.,MinHook_134_bin) inC:/libs/so the structure is likeC:/libs/MinHook_134_bin/include/MinHook.handC:/libs/MinHook_134_bin/bin/MinHook.x64.lib. UpdateMINHOOK_PATHinCMakeLists.txtif needed. - If compiling MinHook from source: Build MinHook as a static library (
.lib) using the same compiler toolset as this project to avoid mismatches. Then updateCMakeLists.txtto link against your compiled static library.
- If using the binary release (contains
This project uses CMake to generate build files for your preferred compiler (e.g., Visual Studio).
- Prerequisites:
- A C++ compiler that supports C++17 (e.g., Visual Studio 2019 or newer).
- CMake (version 3.10 or newer).
- Configure Paths:
- Open
CMakeLists.txt. - Verify that
MINHOOK_PATHandIMGUI_PATHpoint to the correct locations of your MinHook and ImGui libraries.
- Open
- Generate Build Files:
- Create a
builddirectory in the project root. - Open a terminal or CMake GUI, navigate to the
builddirectory. - Run CMake to generate project files:
# from the build directory cmake .. # or specify a generator e.g. for visual studio 2022 x64 # cmake .. -G "Visual Studio 17 2022" -A x64
- Create a
- Compile:
- Open the generated solution file (e.g.,
.slnfor Visual Studio) or use the command line:cmake --build . --config Release - This will produce
ImGuiDX11Hook.dll(or a similar name based onPROJECT_NAMEin CMake) in your build output directory (e.g.,build/Release). The MinHook DLL (MinHook.x64.dllorMinHook.x86.dll) will also be copied to this directory.
- Open the generated solution file (e.g.,
- Build the DLL: Follow the build instructions above. You will get
YourProjectName.dlland the correspondingMinHook.dll. - Inject the DLL: Use your favorite DLL injector to inject 2 dlls which is project name dll and minhook dll but FIRST MINHOOK DLL into the target DirectX 11 game process (either x86 or x64, matching your build).
- Make sure both
YourProjectName.dlland theMinHook.dll(e.g.,MinHook.x64.dll) are in a location accessible by the game, or ideally, in the same directory. The CMake script copies MinHook's DLL to the output directory of your hook DLL.
- Make sure both
- Toggle Menu:
- Press the
INSERTkey to show/hide the ImGui menu.
- Press the
- Unload/Eject:
- Press the
DELETEkey. This will trigger the shutdown sequence in the DLL (unhooking functions, cleaning up ImGui) and then the DLL will callFreeLibraryAndExitThreadon itself. Your injector might then fully detach it.
- Press the
- VTable Indexes: The current method for finding
PresentandResizeBuffersfunction addresses relies on hardcoded VTable indexes (8 and 13). While common, these can change with different DirectX SDK versions or game updates, potentially breaking the hook. A more robust (but significantly more complex) solution would involve signature scanning. - Error Logging: The DLL uses
OutputDebugStringWfor logging. Use a tool like DebugView (from Sysinternals) to see these logs, which can be super helpful for troubleshooting. - Game Compatibility: This is a template. Specific games might have their own anti-cheat mechanisms or quirks that could detect or interfere with this type of hook.
- UI: Edit
src/menu.cppandsrc/menu.hto create your own ImGui interface. - Hooks: Add more hooks in
src/hooks.cppandsrc/hooks.hif you need to interact with other game functions. - ImGui Configuration: Modify
src/imgui_config.hfor custom ImGui backend flags or features.
Happy Hacking! ✨