Skip to main content

install_hook

Macro install_hook 

Source
macro_rules! install_hook {
    ($base:expr, $hook:ident) => { ... };
    ($base:expr, $hook:ident, $ctx:expr) => { ... };
}
Expand description

Installs a hook generated by #[forge::hook].

The first argument is the base address (e.g. from forge::mem::text_addr()), and the second is the hook module created by #[forge::hook]. The macro adds the hook’s OFFSET constant to the base to compute the final target.

An optional third argument passes a context pointer that can be retrieved inside the hook body with context!() or context!(T).

§Examples

// No context
forge::install_hook!(forge::mem::text_addr(), my_hook);

// With context
let mut num: u32 = 3;
forge::install_hook!(forge::mem::text_addr(), my_hook, &mut num);

Note: num MUST outlive the hook