fishhook 0.1.0

A library that enables dynamically rebinding symbols in Mach-O binaries at runtime
docs.rs failed to build fishhook-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: fishhook-0.3.0

fishhook-rs

A Rust port of fishhook — a library that enables dynamically rebinding symbols in Mach-O binaries at runtime. Useful for intercepting system functions like malloc, free, or open on Apple platforms.

Platform support: Currently tested only on macOS (aarch64-apple-darwin)

Installation

Add to your Cargo.toml:

[dependencies]
fishhook-rs = "0.1"

Usage

Example below uses ctor for invoking init() first

use fishhook::{register, Rebinding};

#[ctor::ctor]
fn init() {
    unsafe {
        register(vec![
            Rebinding {
                name: "malloc".to_string(),
                function: my_malloc as *const c_void,
            },
            Rebinding {
                name: "calloc".to_string(),
                function: my_calloc as *const c_void,
            },
            Rebinding {
                name: "realloc".to_string(),
                function: my_realloc as *const c_void,
            },
            Rebinding {
                name: "free".to_string(),
                function: my_free as *const c_void,
            },
            Rebinding {
                name: "atexit".to_string(),
                function: my_exit as *const c_void,
            },
        ]);
    }
}