You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SafetyHook is a C++23 procedure hooking library for Windows x86 and x86_64 systems. It aims to make runtime procedure hooking as safe as possible while maintaining simplicity of its implementation. To that end it currently does:
Stops all other threads when creating or deleting hooks
Fixes the IP of threads that may be affected by the creation or deletion of hooks
Fixes IP relative displacements of relocated instructions (eg. lea rax, [rip + 0x1234])
Fixes relative offsets of relocated instructions (eg. jmp 0x1234)
Widens short branches into near branches
Handles short branches that land within the trampoline
Uses a modern disassembler engine that supports the latest instructions
Has a carefully designed API that is hard to misuse
Installation
SafetyHook can be added via CMake's FetchContent, git submodules, or copied directly into your project using the amalgamated builds. SafetyHook requires Zydis to function.
Amalgamated builds
This is the easiest way to use safety hook. You can find amalgamated builds on the releases page. Simply download the ZIP file containing Zydis (or without Zydis if you already have it in your project) and copy the files into your project.
You may need to define ZYDIS_STATIC_BUILD if you're using the build with Zydis included.