Cross platform minimal and fast hooking library with useful extensions
This project depends on capstone. Make sure you have correctly installed it and that the required header and library are available for your compiler.
- Get the source
git clone https://github.com/ptrstr/lobstr
- Configure project
cd lobstr/buildcmake ..
- Build
Linux
makesudo make installUse this option to install the library
Windows
You will need to build the
dllwith Visual Studio with the provided.slnfile
This project was made to be as easy as possible to use. Here is an example:
#include<lobstr/lobstr.h>#include<stdio.h>voidintegerPrinter(intvalue) {
printf("Your modified? integer: %d\n", value);
}
void (*originalIntegerPrinter)(int);
voidhookedIntegerPrinter(intvalue) {
printf("Custom printing integer: ~~%d~~\n", value);
// Modfication of `value` and callbackvalue=1337;
originalIntegerPrinter(value);
}
intmain(intargc, char*argv[]) {
originalIntegerPrinter=&integerPrinter;
// Returns NULL on errorhook_t*hook=allocHook((void*)hookedIntegerPrinter, (void**)&originalIntegerPrinter);
if (!hook)
return1;
integerPrinter(55);
freeHook(hook);
return0;
}Output:
Custom printing integer: ~~55~~
Your modified? integer: 1337