Skip to content
/ spud Public

just some stuff to do hooking/detour things

Notifications You must be signed in to change notification settings

tashcan/spud

Repository files navigation

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:

add_subdirectory(path/to/spud)
target_link_libraries(your-project-name PRIVATE spud)

Examples

  • Simple example
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.

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 and 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 for unit-testing
  • asmjit for code-gen on x86 and arm
  • zydis for disassembling x86 code
  • x86 and x86-64 opcode and instruction reference

License

  • MIT