https://github.com/tashcan/spud
just some stuff to do hooking/detour things
https://github.com/tashcan/spud
cpp detour hooking hooking-library modding modding-library
Last synced: 2 months ago
JSON representation
just some stuff to do hooking/detour things
- Host: GitHub
- URL: https://github.com/tashcan/spud
- Owner: tashcan
- Created: 2023-08-08T17:17:46.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-16T19:38:09.000Z (5 months ago)
- Last Synced: 2025-01-16T20:23:55.126Z (5 months ago)
- Topics: cpp, detour, hooking, hooking-library, modding, modding-library
- Language: C++
- Homepage:
- Size: 2 MB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
spud - multi-architecture cross-platform hooking library.## Features
- **x86-64 and arm64 support**
- **Windows, Mac and Linux support**## Building
### With CMake (as a subproject)
Clone repository to subfolder and link `spud` to your project:
```cmake
add_subdirectory(path/to/spud)
target_link_libraries(your-project-name PRIVATE spud)
```## Examples
- Simple example
```c++
void hook(auto original, int n) {
if (n == 0) {
// Run some custom code here
return;
}
// Forward to the original code
return original(n);
}void test_function(int n) {
if (n == 0) {
printf("N was 0\n");
}
printf("%d\n", n);
}SPUD_STATIC_DETOUR(test_function, hook);
```## Build & Install
`spud` can be easily added to any cmake-based project. Just add a few lines in `CMakeLists.txt`.
```cmake
FetchContent_Declare(
spud
GIT_REPOSITORY "https://github.com/tashcan/spud.git"
GIT_TAG origin/main
)
FetchContent_MakeAvailable(spud)
```## Documentation
Feel free to browse through [tests](https://github.com/tashcan/spud/tree/main/tests) and [benchmark](https://github.com/tashcan/spud/tree/main/benchmark) if you just want to get a quick glance and some example code.
Otherwise head over to https://spud.tashcan.com/ for a more in-depth documentation
## Missing features
- Easy way to patch VTables
- Memory Manipulation facilities
- Import Table Patching## References
- [catch2](https://github.com/catchorg/Catch2) for unit-testing
- [asmjit](https://github.com/asmjit/asmjit) for code-gen on x86 and arm
- [zydis](https://github.com/zyantific/zydis) for disassembling x86 code
- [x86](http://ref.x86asm.net/coder32.html) and [x86-64](http://ref.x86asm.net/coder64.html) opcode and instruction reference## License
- MIT