> module
std::stub::hooking
low-level inline function hooking
std::stub::hooking provides low-level inline function hooking by address or symbol name. For Il2Cpp method hooking, prefer Method.hook() or Method.hook_void_block() from std::stub::il2cpp, which handle ABI marshalling automatically. This module is for hooking arbitrary native functions where you manage the calling convention yourself.
> functions
Sentinel for skipping the original method in an Il2Cpp hook. Return Some(hooking::Skip()) from a Method.hook() callback to skip the original without supplying a return value (the caller sees 0).
Create a hook by looking up a symbol: by_name(symbol, dest) searches every loaded library, by_name(module, symbol, dest) only module. Returns a bare Hook (not a Result) and raises a runtime error if the symbol isn't found or the arguments don't fit either form.
> types
These return a Result whose error is a HookError (LockPoisoned, CreateFailed, ApplyFailed or RemoveFailed, each but the first carrying a message) — thread them with ?.
Activate the hook. Calls to the target are redirected to the destination.
Get the address of the trampoline that calls the original function.
An opaque value; see the functions that return it.
> examples
use std::stub::hooking;
// `detour` is the address of your replacement function.
fn install(detour: i64) -> Result<()> {
// Hook a function by address
let hook = hooking::create(0x7f0001000, detour)?;
hook.apply()?;
let orig = hook.original()?;
// Hook by symbol name
// (by_name raises instead of returning a Result)
let hook = hooking::by_name("libgame.so", "GameUpdate", detour);
hook.apply()?;
// Remove when done
hook.remove()?;
Ok(())
}