An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

        





spud logo


License: MIT
GitHub Actions


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