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
-
make -
sudo 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>
void integerPrinter(int value) {
printf("Your modified? integer: %d\n", value);
}
void (*originalIntegerPrinter)(int);
void hookedIntegerPrinter(int value) {
printf("Custom printing integer: ~~%d~~\n", value);
// Modfication of `value` and callback
value = 1337;
originalIntegerPrinter(value);
}
int main(int argc, char *argv[]) {
originalIntegerPrinter = &integerPrinter;
// Returns NULL on error
hook_t *hook = allocHook((void *)hookedIntegerPrinter, (void **)&originalIntegerPrinter);
if (!hook)
return 1;
integerPrinter(55);
freeHook(hook);
return 0;
}Output:
Custom printing integer: ~~55~~
Your modified? integer: 1337