Skip to main content

dr_redirect_native_target

Function dr_redirect_native_target 

Source
pub unsafe extern "C" fn dr_redirect_native_target(
    drcontext: *mut c_void,
) -> *mut byte
Expand description

Returns the target to use for a native context transfer to a target application address.

Normally, redirection is performed from a client context in a clean call or event callback by invoking dr_redirect_execution(). In some circumstances, redirection from an application (or “native”) context is desirable without creating an application control transfer in a basic block.

To accomplish such a redirection, store the target application address in #SPILL_SLOT_REDIRECT_NATIVE_TGT by calling dr_write_saved_reg(). Set up any other application state as desired directly in the current machine context. Then jump to the target returned by this routine. By default, the target is global and can be cached globally. However, if traces are thread-private, or if traces are disabled and basic blocks are thread-private, there will be a separate target per \p drcontext.

If a basic block is exited via such a redirection, the block should be emitted with the flag DR_EMIT_MUST_END_TRACE in order to avoid trace building errors.

For ARM, the address returned by this routine has its least significant bit set to 1 if the target is Thumb.

Returns null on error.