https://github.com/bruhmoment21/UniversalHookX
Universal graphical hook for Windows apps.
https://github.com/bruhmoment21/UniversalHookX
directx graphics hook hooking imgui opengl runtime-hooking vulkan
Last synced: about 1 year ago
JSON representation
Universal graphical hook for Windows apps.
- Host: GitHub
- URL: https://github.com/bruhmoment21/UniversalHookX
- Owner: bruhmoment21
- License: mit
- Created: 2022-06-15T13:42:42.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-31T18:26:38.000Z (almost 2 years ago)
- Last Synced: 2024-11-07T14:39:50.752Z (over 1 year ago)
- Topics: directx, graphics, hook, hooking, imgui, opengl, runtime-hooking, vulkan
- Language: C++
- Homepage:
- Size: 1.03 MB
- Stars: 191
- Watchers: 5
- Forks: 42
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UniversalHookX  
Universal graphical hook for Windows apps, although it should work on [Linux](https://user-images.githubusercontent.com/53657322/176435063-c1511ee4-462c-47f2-9f3a-1cc983c73310.png) too if you implement it correctly, that will display an [ImGui Demo Window](https://github.com/bruhmoment21/UniversalHookX/blob/main/UniversalHookX/src/menu/menu.cpp#L24) as an example.
## Usage
Call `Utils::SetRenderingBackend(eRenderingBackend)` in DllMain as shown [here](https://github.com/bruhmoment21/UniversalHookX/blob/main/UniversalHookX/src/dllmain.cpp#L19).
You must do this or the DLL won't know what to hook or how to hook. [What is eRenderingBackend?](https://github.com/bruhmoment21/UniversalHookX/blob/main/UniversalHookX/src/utils/utils.hpp#L3). To enable or disable a specific backend comment backends in [backend.hpp](https://github.com/bruhmoment21/UniversalHookX/blob/main/UniversalHookX/src/backend.hpp)
## 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](https://github.com/bruhmoment21/UniversalHookX/tree/main/UniversalHookX/src/hooks/backend).
## Supported Backends
- [x] DirectX9 + DirectX9Ex
- [x] DirectX10
- [x] DirectX11
- [x] DirectX12
- [x] OpenGL
- [x] 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](https://docs.microsoft.com/en-us/windows/console/getconsolewindow). See the `CreateDeviceD3DX` function in every DirectX backend. [See DX12 example 'CreateDeviceD3D12'](https://github.com/bruhmoment21/UniversalHookX/blob/main/UniversalHookX/src/hooks/backend/dx12/hook_directx12.cpp#L43-L72). 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. [See code used in DX12 backend hook.](https://github.com/bruhmoment21/UniversalHookX/blob/main/UniversalHookX/src/hooks/backend/dx12/hook_directx12.cpp#L195-L259)
## OpenGL
We hook wglSwapBuffers which is an exported function in opengl32.dll. [See code used in OpenGL backend hook.](https://github.com/bruhmoment21/UniversalHookX/blob/main/UniversalHookX/src/hooks/backend/opengl/hook_opengl.cpp#L39-L56)
## Vulkan
We create a 'dummy device' to get the required functions addresses. The point is to hook into [vkQueuePresentKHR](https://www.khronos.org/registry/vulkan/specs/1.3-extensions/man/html/vkQueuePresentKHR.html) where we will submit the queue with our data from our command pool and our command buffer. [See code used in Vulkan backend hook.](https://github.com/bruhmoment21/UniversalHookX/blob/main/UniversalHookX/src/hooks/backend/vulkan/hook_vulkan.cpp#L314-L349)
# Media
## DirectX9 32bit


## DirectX10 32bit

## DirectX11 64bit

## DirectX12 64bit

## OpenGL 32bit + 64bit


## Vulkan 32bit + 64bit


# Other
Feel free to open an issue if something isn't working. Input handling is left for the user because there is no general solution.
## Known issues
Tip: Try pressing the "Home" key, that will rehook graphics, and see if anything changed.
- **[!] Conflicts with other overlays such as MSI Afterburner and will probably crash.**
- [Vulkan] Games or apps that present from a queue that doesn't support GRAPHICS_BIT may have issues such as artifacts and menu jittering. (Example: DOOM Eternal)
- ~~[Vulkan] Portal 2 will crash if injected while Valve intro is playing.~~
- [OpenGL] [Minecraft (tested on 1.19) - ui textures glitched sometimes.](https://user-images.githubusercontent.com/53657322/174030423-aa92e780-057e-451d-9d60-ddd20f668d03.png)
## Dependencies
[MinHook](https://github.com/TsudaKageyu/minhook) - TsudaKageyu - Used for hooking (trampoline method).
[ImGui](https://github.com/ocornut/imgui) - ocornut - self-explanatory.
[Vulkan SDK](https://vulkan.lunarg.com/) - for the Vulkan API.