dr_insert_call

Function dr_insert_call 

Source
pub unsafe extern "C" fn dr_insert_call(
    drcontext: *mut c_void,
    ilist: *mut instrlist_t,
    where_: *mut instr_t,
    callee: *mut c_void,
    num_args: uint,
    ...
)
Expand description

Inserts into \p ilist prior to \p where meta-instruction(s) to set up the passed-in parameters, make a call to \p callee, and clean up the parameters.

The callee must use the standard C calling convention that matches the underlying 32-bit or 64-bit binary interface convention (“cdecl”). Other calling conventions, such as “fastcall” and “stdcall”, are not supported.

This routine uses the existing stack. In 64-bit mode, this routine assumes that the stack pointer is currently 16-byte aligned.

The application state is NOT saved or restored (use dr_prepare_for_call() and dr_cleanup_after_call(), or replace this routine with dr_insert_clean_call()). The parameter set-up may write to registers if the calling convention so dictates. The registers are NOT saved beforehand (to do so, use dr_insert_clean_call()).

It is up to the caller of this routine to preserve any caller-saved registers that the callee might modify.

DR does not support translating a fault in an argument. For fault transparency, the client must perform the translation (see #dr_register_restore_state_event()), or use #dr_insert_clean_call().

For 64-bit, for purposes of reachability, this call is assumed to be destined for encoding into DR’s code cache-reachable memory region. This includes the code cache as well as memory allocated with dr_thread_alloc(), dr_global_alloc(), dr_nonheap_alloc(), or dr_custom_alloc() with #DR_ALLOC_CACHE_REACHABLE. The call used here will be direct if it is reachable from those locations; if it is not reachable, an indirect call through r11 will be used (with r11’s contents being clobbered). Use dr_insert_call_ex() when encoding to a location other than DR’s regular code region.

\note This routine only supports passing arguments that are integers or pointers of a size equal to the register size: i.e., no floating-point, multimedia, or aggregate data types. The routine also supports immediate integers that are smaller than the register size, and for 64-bit mode registers or memory references that are OPSZ_4.

\note For 64-bit mode, passing arguments that use calling convention registers (for Windows, RCX, RDX, R8, R9; for Linux, RDI, RSI, RDX, RCX, R8 and R9) are supported but may incur additional stack usage.

\note For 64-bit mode, if a 32-bit immediate integer is specified as an argument and it has its top bit set, we assume it is intended to be sign-extended to 64-bits; otherwise we zero-extend it.

\note For 64-bit mode, variable-sized argument operands may not work properly.

\note Arguments that reference DR_REG_XSP are not supported in 64-bit mode.