Skip to main content

Crate fishhook

Crate fishhook 

Source
Expand description

§fishhook-rs

A Rust port of 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:

[dependencies]
fishhook = "0.3"

§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 () 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,
           },
        ]);
    }
}

Structs§

Rebinding

Functions§

register