Skip to content

nefarius/HydraHook

Repository files navigation

HydraHook

API-Hooking and rendering framework for DirectX-based games.

Build status Discord Website GitHub followers Mastodon Follow

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 FreeLibrary when done. Supports mid-process injection (e.g. D3D12 games already running). Graceful shutdown via ExitProcess / PostQuitMessage / FreeLibrary hooks 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_nothrow to 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

Build steps

  1. Clone the repository and initialize submodules: git submodule update --init --recursive
  2. Open HydraHook.sln in 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!

Last updated

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:

.\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

Half-Life 2 Demo

DirectX 9 Ex

Castlevania: Lords of Shadow, 32-Bit

Castlevania: Lords of Shadow Demo

DirectX 10

Bioshock 2, 32-Bit

Bioshock 2 Demo

DirectX 11

Road Redemption, 64-Bit

Road Redemption Demo

DirectX 12

Supported on 64-bit builds. The ImGui sample automatically detects and hooks DX12 games.

BEHEMOTH, 64-Bit

BEHEMOTH Demo

Sources

Dependencies

This project uses the following libraries (via vcpkg):

Core library only:

Sample projects only:

References & inspiration

Sponsor this project

Contributors