Expand description
This crate is a rusty binding of Dobby.
§Quickstart
use dobby_rs::{resolve_symbol, hook, Address};
use std::mem::transmute;
#[inline(never)]
#[no_mangle]
extern "C" fn add(a: u64, b: u64) -> u64 {
a + b
}
#[inline(never)]
#[no_mangle]
extern "C" fn sub(a: u64, b: u64) -> u64 {
a - b
}
unsafe {
let addr = add as usize as Address;
let replace = sub as usize as Address;
let origin = hook(addr, replace).unwrap();
let origin: extern "C" fn(u64, u64) -> u64 = transmute(origin);
assert_eq!(origin(2, 1), 2 + 1);
assert_eq!(add(2, 1), 2 - 1);
}
Enums§
Functions§
- hook⚠
- Set up a hook at
addr
, return the trampoline address of the original function. - hook_
and_ ⚠update_ origin - Set up a hook at
addr
. The trampoline address will be set simultaneously. - patch_
code ⚠ - Patch the code at
addr
with supplied bytes. - resolve_
symbol - Locate a symbol name within an image.
This function will return
None
if the symbol does not exist or the image has not been loaded yet. - unhook⚠
- Undo all hooks at
addr
.