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
/// 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
/// ```ignore
/// // 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
/// Updates the context for an already-installed hook.
///
/// # Example
/// ```ignore
/// forge::update_hook_ctx!(my_hook, &mut new_value);
/// ```