Macro dinvoke

Source
macro_rules! dinvoke {
    ($module:expr, $function:expr, $ty:ty, $($arg:expr),*) => { ... };
}
Expand description

Macro to dynamically invoke a function from a specified module.

§Arguments

  • $module - Module address for the api to be called (e.g., "ntdll.dll").
  • $function - A string slice with the name of the function to invoke (e.g., "NtQueryInformationProcess").
  • $ty - The type of the function to cast to, including its signature.
  • $($arg-expr),* - A variadic list of arguments to pass to the function.

§Example

let ntdll = get_ntdll_address();
let result = dinvoke!(ntdll, "NtQueryInformationProcess", extern "system" fn(...) -> u32, arg1, arg2);