Macro chiter::make_functions[][src]

macro_rules! make_functions {
    ( $( $address:expr; fn $fn_name:ident( $($argument:ty),* ) -> $returntype:ty);* ) => { ... };
}

A macro to convert multiple pointers into functions

take note: untested

Example:

// This code is in C.
int add_one(int thing) {
    return thing + 1;
}

int get_random_number() {
    return 4;
}
// This code is in Rust.
// 0xDEADBEEF is the address where add_one starts,
// and 0x0DEADBEEF + 70 is the address where get_random_number starts.

let add_one;
let get_random_number;

unsafe {
    make_functions! {
        0xDEADBEEF; fn add_one(i32) -> i32;
        0xDEADBEEF + 70; fn get_random_number() -> i32
    }
}

assert_eq!(add_one(400), 401);
assert_eq!(get_random_number(), 4);