Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/std-microblock/blook
A modern C++ library for hacking.
https://github.com/std-microblock/blook
aob aob-scan game-hacking hacking hook inline-hook memory-scanning
Last synced: 7 days ago
JSON representation
A modern C++ library for hacking.
- Host: GitHub
- URL: https://github.com/std-microblock/blook
- Owner: std-microblock
- License: gpl-3.0
- Created: 2024-06-21T05:22:16.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-08T03:29:41.000Z (about 2 months ago)
- Last Synced: 2024-09-22T18:02:33.905Z (about 1 month ago)
- Topics: aob, aob-scan, game-hacking, hacking, hook, inline-hook, memory-scanning
- Language: C++
- Homepage:
- Size: 2.06 MB
- Stars: 57
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
> [!WARNING]
> This project is in a relatively early stage and is not ready for production. Use at your own risk.
> 此项目仍较早期,不建议实际使用。
blook
A modern C++ library for hacking.
## So what?
Inline hook a function? Easy!
```cpp
auto process = blook::Process::self();
auto hook = process->module("user32.dll").value()
->exports("MessageBoxA")
->inline_hook();
hook->install([=](int64_t a, char *text, char *title, int64_t b) -> int64_t {
return hook->trampoline_t()(
a, "oh yes", text, b);
});MessageBoxA(nullptr, "hi", "hi", 0);
```...hook more? Sure!
```cpp
auto process = blook::Process::self();
auto mod = process->module("user32.dll").value();
for (auto& func: mod.obtain_exports()) {
auto hook = mod
->exports(func)
->inline_hook();
hook->install([=](int64_t a) -> int64_t {
// Yes, capture anything you want!
std::cout << "Someone called: " << std::hex << func << "\n";
return hook->trampoline_t()(a);
});
}
```How about hooking a method that's not exported?
```cpp
auto process = blook::Process::self();
auto mod = process->module().value();
// Let's find the specific function in .text (Code Segment) with blook's AOB shortcut!.
auto text_segment = mod->section(".text").value();
using ANYp = blook::memory_scanner::ANYPattern;
auto hook = text_segment.find_one({
0x55, 0x56, 0x57, 0x48, 0x83, 0xec, 0x70, 0x48, 0x8d, 0x6c, 0x24, 0x70,
0x48, 0xc7, 0x45, 0xf8, 0xfe, 0xff, 0xff, 0xff, 0x48, 0x89, 0xce, 0x48,
0x8d, 0x7d, 0xd0, 0x48, 0x89, 0xfa, 0xe8, 0x44, ANYp, ANYp, ANYp
})->sub(-0x28).as_function().inline_hook();// And now it's easy to hook it.
hook->install([=](int64_t a) -> int64_t {
std::cout << "Someone called some internal function!\n";
return hook->trampoline_t()(a);
});
```## Getting started
### Compile
Clone the repository to local, and build it with cmake!
### Using in a CMake project
### a) git submodule
First, add the repo as submodule.
```shell
git submodule add https://github.com/MicroCBer/blook
git submodule update --init --recursive
```Then, import it and add it to your project in `CMakeLists.txt`
```cmake
add_subdirectory(external/blook)
target_link_libraries(your_target blook)
```### b) CMake FetchContent
Add those lines into your `CMakeLists.txt`
```cmake
include(FetchContent)###### Fetch blook from GitHub #####
FetchContent_Declare(
blook
GIT_REPOSITORY https://github.com/MicroCBer/blook
GIT_TAG origin/main
)
FetchContent_MakeAvailable(blook)
####################################target_link_libraries(your_target blook)
```### Manual installation
It's strongly discouraged to use the project without CMake, but it should be possible.