UniversalHookX C++ Windows

Universal graphical hook for Windows apps that will display an ImGui Demo Window as an example.

Usage

Call Utils::SetRenderingBackground(eRenderingBackground) in DllMain as shown here. You must do this or the DLL won’t know what to hook or how to hook. What is eRenderingBackend?.

Purpose

The purpose of this library is to show how to hook different backends to display ImGui, the code should be easy to understand as I tried to make everything seem almost the same, see backends folder.

Supported Backends

  • DirectX9
  • DirectX10
  • DirectX11
  • DirectX12
  • OpenGL
  • Vulkan

How it works

DirectX

We create a ‘dummy device’ and a ‘dummy swapchain’ (for DirectX10 and higher) with a handle to the console window. See the CreateDeviceD3DX function in every DirectX backend. See DX12 example ‘CreateDeviceD3D12’. The point is to get a pointer to the vTable to get the required functions addresses. We release it right after getting the pointers because we won’t use our ‘dummy device’ and ‘dummy swapchain’ for drawing. Code used in DX12 backend hook.

OpenGL

We hook wglSwapBuffers which is an exported function in opengl32.dll. See code used in OpenGL backend

Media

DirectX9 32bit

image image

DirectX10 32bit

image

DirectX11 64bit

image

DirectX12 64bit

image

OpenGL 32bit + 64bit

image image

Other

Feel free to open an issue if something isn’t working, personally I couldn’t get it to work on ‘Far Cry 6’. Resizing works because ResizeBuffers is hooked. Input handling is up to you to decide how to make/use it. The WndProc hook is here. It should support both 64bit and 32bit architectures.

Known issues

Try pressing HOME to rehook and see if things got better. Minecraft (tested on 1.19) – menu textures glitched

Dependencies

MinHook – TsudaKageyu – Used for hooking (trampoline method). ImGui – ocornut – self-explanatory.

GitHub

View Github