vmt_hook

Function vmt_hook 

Source
pub unsafe fn vmt_hook(
    object: *const (),
    index: usize,
    detour: usize,
) -> Result<VmtHook>
Expand description

hook a virtual function in an object’s VMT

§Safety

Object must be a valid C++ object with a vtable.

§Arguments

  • object - pointer to the C++ object
  • index - vtable index of the function
  • detour - address of the detour function

§Example

let hook = unsafe { vmt_hook(object_ptr, 5, my_detour as usize)? };
let original: fn() = unsafe { std::mem::transmute(hook.original()) };