You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
913 B

5 years ago
# shithook
5 years ago
3 years ago
A c++ header only library for inline hooking. Supports x86_64, x86, and arm. Small, simple, and easily detected :)
5 years ago
# usage
Installing the hook/Init.
```cpp
3 years ago
__attribute__((noinline)) // very important that this is not inline!
FILE* hook_test(const char* filename, const char* open_type)
{
std::printf("> filename = %s\n", filename);
std::printf("> open type = %s\n", open_type);
std::getchar();
return hook::get_func(&fopen)(filename, open_type);
}
hook::make_hook(&fopen, &hook_test);
5 years ago
```
3 years ago
### Calling Original
`hook::get_func` is templated so that you can pass a function pointer I.E `&fopen` and the returned pointer will be of that type.
3 years ago
```cpp
3 years ago
return hook::get_func(&fopen)(filename, open_type); // returned value is of type: FILE* (*)(const char*, const char*);
```
3 years ago
### Disable Hook
3 years ago
```cpp
3 years ago
hook::disable(&fopen);
```
### Enable Hook
5 years ago
3 years ago
```cpp
3 years ago
hook::enable(&fopen);
4 years ago
```