|
|
@ -6,19 +6,27 @@ A c++ header only library for inline hooking. Supports x86_64, x86, and arm. Sma
|
|
|
|
|
|
|
|
|
|
|
|
Installing the hook/Init.
|
|
|
|
Installing the hook/Init.
|
|
|
|
```cpp
|
|
|
|
```cpp
|
|
|
|
hook::make_hook(
|
|
|
|
__attribute__((noinline)) // very important that this is not inline!
|
|
|
|
&WriteFile, //address to put inline hook at.
|
|
|
|
FILE* hook_test(const char* filename, const char* open_type)
|
|
|
|
&HookWriteFile //address to jmp too.
|
|
|
|
{
|
|
|
|
);
|
|
|
|
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);
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Disabling the hook so you can call the original function.
|
|
|
|
### Disable Hook
|
|
|
|
```cpp
|
|
|
|
|
|
|
|
hook::disable(&WriteFile);
|
|
|
|
|
|
|
|
WriteFile(.....)
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
hook::disable(&fopen);
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Enable Hook
|
|
|
|
|
|
|
|
|
|
|
|
Enabling the hook.
|
|
|
|
|
|
|
|
```
|
|
|
|
```
|
|
|
|
hook::enable(&WriteFile);
|
|
|
|
hook::enable(&fopen);
|
|
|
|
```
|
|
|
|
```
|