https://github.com/0xvpr/vpr-deviate
C99/C++20 Header only library for dependency free function hooking in windows.
https://github.com/0xvpr/vpr-deviate
cplusplus cpp cpp11 cpp17 cpp20 detour-hook function-hooking hacking-tool header-only hook library
Last synced: 6 months ago
JSON representation
C99/C++20 Header only library for dependency free function hooking in windows.
- Host: GitHub
- URL: https://github.com/0xvpr/vpr-deviate
- Owner: 0xvpr
- License: mit
- Created: 2024-03-28T23:24:23.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-11T01:06:47.000Z (almost 2 years ago)
- Last Synced: 2025-01-02T17:50:05.647Z (about 1 year ago)
- Topics: cplusplus, cpp, cpp11, cpp17, cpp20, detour-hook, function-hooking, hacking-tool, header-only, hook, library
- Language: C++
- Homepage:
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
vpr-deviate
A Function hooking/detouring header-only library for Windows (MinGW)
## Table of Contents
- [Example Usage](#example-usage)
- [Integration](#integration)
- [Compilation](#compilation)
### Example Usage
C++
```cpp
#include
#include
void target(int x) {
fprintf(stdout, "%d\n", x);
}
int main() {
unsigned char original_bytes[_rel_jmp_size_];
target(5); // 5 - original
vpr::deviate::detour( target,
[](int x) { return x*x; },
original_bytes,
sizeof(original_bytes) );
target(5); // 25 - detoured
```
C
```c
#include
#include
void target(int x) {
fprintf(stdout, "%d\n", x);
}
void func(int x) {
fprintf(stdout, "%d\n", x*x);
}
int main() {
target(5); // 5 - original
vpr_deviate_detour((void *)target, (void *)func, nullptr, 0);
target(5); // 25 - detoured
return 0;
}
```
## Integration
### System-wide installation using CMake
```bash
git clone https://github.com/0xvpr/vpr-deviate.git
cd vpr-deviate
cmake -DCMAKE_INSTALL_PREFIX=/your/desired/path/ -B build
cmake --install build
```
### Local installation (fetch directly from github)
```cmake
#set( CMAKE_C_STANDARD 99 ) # at least c99 if using c
#set( CMAKE_CXX_STANDARD 17 ) # at least c++17 if using cpp
include(FetchContent)
FetchContent_Declare(
vpr-deviate
GIT_REPOSITORY https://github.com/0xvpr/vpr-deviate.git
GIT_TAG main # Or use a specific version tag like "v1.0.0"
)
FetchContent_MakeAvailable(vpr-deviate)
add_executable(app main.cpp)
target_link_libraries(app PRIVATE vpr-deviate::deviate)
```
### Compilation
Use GCC or Clang. MSVC won't accept the inline assembly for x64 (will for x86 but it's not supported by the library).