____ _____ ____ ____ __ __ __ ____ ______ _
/ __ \__ // __ \/ __ \ / / / /___ ____ / /__ / _/___ ___ / ____/_ __(_)
/ / / //_ </ / / / /_/ / / /_/ / __ \/ __ \/ //_/ / // __ `__ \/ / __/ / / / /
/ /_/ /__/ / /_/ /\__, / / __ / /_/ / /_/ / ,< _/ // / / / / / /_/ / /_/ / /
/_____/____/_____//____/ /_/ /_/\____/\____/_/|_| /___/_/ /_/ /_/\____/\__,_/_/
D3D9 Hook with ImGui integration (x86 / x64)
Make DirectX 9 internal menu with ImGui
(Resize & Fullscreen support)
D3D9 Hook with ImGui integration written in C++, works on x86 and x64 with all librairies and includes.
- Handle window resize
- DLL unload itself
- Handler external unload
- Handle fullscreen change
This use the dummy device technique to retrieve the virtual method table of DirectX 9.
This project use MS Detours library for hooking and obviously DirectX 9 SDK.
MS Detours library is already include in the project folder, but if you don't have DirectX SDK you can download it here.
Note
Make sure that DXSDK_DIR is declared in your environment variables.
To see your environment variables :
Settings --> System --> About --> System Advanced Settings --> Environment Variables
- Open the solution file (.sln).
- Build the project in Release (x86 or x64)
Every configuration in x86 / x64 (Debug and Realese) are already configured with librairies and includes.
This CMakeLists.txt should compile the project.
cmake_minimum_required(VERSION 3.0)
project(D3D9_HOOK)
set(CMAKE_CXX_STANDARD 17)
include_directories(Detours/include $ENV{DXSDK_DIR}Include)
link_directories(Detours/x86 $ENV{DXSDK_DIR}Lib/x86/)
file(GLOB ImGui ImGui/*.cpp ImGui/*.h)
add_library(D3D9_HOOK SHARED pch.h dllmain.cpp Hook.h Hook.cpp Drawing.h Drawing.cpp ${ImGui})
target_link_libraries(D3D9_HOOK detours.lib d3d9.lib d3dx9.lib)
Tested on CLion with MSVC compiler, you can get Visual Studio Build Tools here.
You can hook every functions of DirectX 9 by changing the virtual function index (in Hook.cpp) :
Here I hook EndScene Function.
oEndScene = (tEndScene)d3d9Device[42];
All functions index of DirectX 9 are here.