1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//!
//!# fishhook-rs
//!
//! A Rust port of [fishhook](https://github.com/facebook/fishhook) — a library that enables dynamically rebinding symbols
//! for Linux and Mach-O binaries at runtime. Useful for intercepting system functions like `malloc`, `free`, or `open`.
//!
//! > **Platform support**: Currently tested on Linux (x86_64) and macOS (aarch64-apple-darwin)
//!
//! ## Installation
//!
//! Add to your `Cargo.toml`:
//!
//! ```toml
//! [dependencies]
//! fishhook = "0.3"
//! ```
//!
//! ## Usage
//! Example below uses [ctor](https://github.com/mmastrac/rust-ctor) for invoking ***init()*** first
//! ```rust
//! use fishhook::{register, Rebinding};
//!
//! #[ctor::ctor]
//! fn init() {
//! unsafe {
//! register(vec![
//! Rebinding {
//! name: "malloc".to_string(),
//! function: my_malloc as *const () as usize,
//! },
//! Rebinding {
//! name: "calloc".to_string(),
//! function: my_calloc as *const () as usize,
//! },
//! Rebinding {
//! name: "realloc".to_string(),
//! function: my_realloc as *const () as usize,
//! },
//! Rebinding {
//! name: "free".to_string(),
//! function: my_free as *const () as usize,
//! },
//! ]);
//! }
//! }
//! ```
pub use Rebinding;
pub unsafe