HydraHook
DirectX API-hooking framework
**HydraHook** is a DirectX API-hooking framework The project is written primarily in C++, distributed under the MIT License license, first published in 2015. Key topics include: api-hooking, directx-10, directx-11, directx-12, directx-9.
<img src="assets/HydraHook_128x128.png" align="left" /> HydraHook
API-Hooking and rendering framework for DirectX-based games.
About
HydraHook consists of a self-contained library (DLL) which exposes a minimalistic API for rendering custom content in foreign processes eliminating the need for in-depth knowledge about Direct3D and API-hooking. The most common use-case might be drawing custom overlays on top of your games. The framework takes care about pesky tasks like detecting the DirectX version the game was built for.
[!CAUTION]
Use caution when injecting HydraHook into any game protected by anti-cheat software. API hooking and DLL injection are commonly detected by anti-cheat systems and may result in permanent bans from online services. Use only with games you own and in environments where such use is permitted.
[!NOTE]
The authors of this project do not condone the use of HydraHook in cheating software. The project's motivation has been curiosity and education entirely.
Features
-
Runtime injection and ejection — No launcher required. Inject into any running DirectX process and eject via
FreeLibrarywhen done. Supports mid-process injection (e.g. D3D12 games already running). Graceful shutdown viaExitProcess/PostQuitMessage/FreeLibraryhooks avoids loader-lock and unload races. -
Performance-focused — Lock-free hot path for hook callbacks (atomic counters only; no mutex, no kernel transition). Shutdown uses loader-lock-safe
remove_nothrowto avoid deadlocks during process exit. -
No external dependencies at runtime — Everything needed is statically linked in. Just drop the DLL into the target process; no redistributables or runtime packages required.
Supported DirectX versions
- DirectX 9.0
- DirectX 9.0 Extended (Vista+)
- DirectX 10
- DirectX 11
- DirectX 12
How to build
Prerequisites
- Visual Studio 2022 (Community Edition is free)
- Windows SDK
Build steps
- Clone the repository and initialize submodules:
git submodule update --init --recursive - Open
HydraHook.slnin Visual Studio and build
Dependencies (spdlog, detours, imgui, directxtk) are declared in vcpkg.json and installed via vcpkg (included as a submodule). Run prepare-deps.bat from a Developer Command Prompt for VS 2022 (or x64 Native Tools Command Prompt) before the first build in Visual Studio; the build will use existing vcpkg_installed if present.
Pre-built binaries
[!WARNING]
The downloads contain a DLL Injector utility which might be flagged as unsafe by the browser due to it sharing behavior with malicious code. Use at your own risk!
Pre-built binaries are available from the buildbot. Note: these builds may be outdated; for the latest code, build from source.
How to use
Inject the resulting host library (e.g. HydraHook-ImGui.dll) into the target process first using a DLL injection utility of your choice (you can ofc. use mine as well). The following example loads the imgui sample:
PowerShell.\Injector -n hl2.exe -i HydraHook-ImGui.dll
Just make sure your host library doesn't require any external dependencies not present in the process context or you'll get a LoadLibrary failed error.
Diagnostics
The core library logs its progress and potential errors to HydraHook.log. It tries to write in this order: (1) the directory of the process executable, (2) the directory of the HydraHook DLL, (3) %TEMP% if both prior locations fail (e.g. no write permissions).
Demos
The following demo videos show imgui being rendered in foreign processes using different versions of DirectX. Click a thumbnail to watch the video.
DirectX 9
Half-Life 2, 32-Bit
DirectX 9 Ex
Castlevania: Lords of Shadow, 32-Bit
DirectX 10
Bioshock 2, 32-Bit
DirectX 11
Road Redemption, 64-Bit
DirectX 12
Supported on 64-bit builds. The ImGui sample automatically detects and hooks DX12 games.
BEHEMOTH, 64-Bit
Sources
Dependencies
This project uses the following libraries (via vcpkg):
Core library only:
- spdlog – Fast C++ logging library
- Microsoft Detours – API hooking library
Sample projects only:
- Dear ImGui – Immediate mode GUI
- DirectXTK – DirectX Toolkit
- OpenCV – Computer vision library
References & inspiration
Contributors
Showing top 5 contributors by commit count.
