Skip to main content

verify_callgraph

Macro verify_callgraph 

Source
macro_rules! verify_callgraph {
    (exe: $exe:expr; $($body:tt)*) => { ... };
    (@each $exe:expr;
        $(#[$m:meta])* fn $name:ident @ $addr:expr => exact [ $($t:expr),* $(,)? ] ; $($rest:tt)*) => { ... };
    (@each $exe:expr;
        $(#[$m:meta])* fn $name:ident @ $addr:expr => superset [ $($t:expr),* $(,)? ] ; $($rest:tt)*) => { ... };
    (@each $exe:expr;
        $(#[$m:meta])* fn $name:ident @ $addr:literal { $($clauses:tt)* } $($rest:tt)*) => { ... };
    (@each $exe:expr;) => { ... };
    (@clauses $s:expr; calls: exact [ $($t:expr),* $(,)? ] ; $($r:tt)*) => { ... };
    (@clauses $s:expr; calls: superset [ $($t:expr),* $(,)? ] ; $($r:tt)*) => { ... };
    (@clauses $s:expr; fields: [ $($t:expr),* $(,)? ] ; $($r:tt)*) => { ... };
    (@clauses $s:expr; globals: [ $($t:expr),* $(,)? ] ; $($r:tt)*) => { ... };
    (@clauses $s:expr; vtables: [ $($t:expr),* $(,)? ] ; $($r:tt)*) => { ... };
    (@clauses $s:expr; vcall_slots: [ $($t:expr),* $(,)? ] ; $($r:tt)*) => { ... };
    (@clauses $s:expr; iat: [ $($t:expr),* $(,)? ] ; $($r:tt)*) => { ... };
    (@clauses $s:expr;) => { ... };
}
Expand description

Declare expected facts for origin: functions and generate one #[test] per function, checked against the real binary.

Two forms:

ⓘ
verify_callgraph! {
    exe: "../../target.exe";

    // 1) shorthand — direct calls only
    fn set_name @ 0x006ff420 => exact [0x00401f00, 0x00401f20, 0x00984b6a];

    // 2) block — any subset of clauses, each `;`-terminated
    fn ni_node_ctor @ 0x0070b780 {
        calls: superset [0x004b2d30];
        fields: [0xbc, 0xc0, 0xc4, 0xc8];   // struct offsets it must touch
        vtables: [0x00a7e38c];              // NiNode vtable VA installed
        vcall_slots: [0x84];                // virtual call slot, if any
    }
}

CALL clauses: exact (equality) or superset (hallucination-only). The other clauses are present-checks: each declared value must appear in the binary’s harvested set, else it’s a hallucination.