hooks/
hooks.rs

1use panda::plugins::hooks::Hook;
2use panda::plugins::proc_start_linux::AuxvValues;
3use panda::prelude::*;
4
5#[panda::init]
6fn init(_: &mut PluginHandle) {
7    // No specialized init needed
8}
9
10#[panda::hook]
11fn entry_hook(_cpu: &mut CPUState, _tb: &mut TranslationBlock, _exit_code: u8, hook: &mut Hook) {
12    println!("\n\nHit entry hook!\n");
13    hook.enabled = false;
14}
15
16#[panda::on_rec_auxv]
17fn on_proc_start(_cpu: &mut CPUState, _tb: &mut TranslationBlock, auxv: &AuxvValues) {
18    let address = auxv.entry;
19    panda::hook::before_block_exec(move |_, _, hook| {
20        println!(
21            "Before block exec of closure entry hook. (at address: {:#x?})",
22            address
23        );
24
25        hook.enabled = false;
26    })
27    .at_addr(auxv.entry);
28
29    entry_hook::hook().after_block_exec().at_addr(auxv.entry)
30}
31
32fn main() {
33    Panda::new().generic("x86_64").replay("test").run();
34}