dr_register_persist_patch

Function dr_register_persist_patch 

Source
pub unsafe extern "C" fn dr_register_persist_patch(
    func_patch: Option<unsafe extern "C" fn(drcontext: *mut c_void, perscxt: *mut c_void, bb_start: *mut byte, bb_size: usize, user_data: *mut c_void) -> bool_>,
) -> bool_
Expand description

\warning This patching interface is in flux and is subject to change in the next release. Consider it experimental in this release.

Registers a callback function for patching code prior to storing it in a persisted cache file. The length of each instruction cannot be changed, but displacements and offsets can be adjusted to make the code position-independent. A patch callback is only called once per persisted file, regardless of whether one or all of read-only, executable, or writable data has been added. Use the \p user_data parameter to pass the file offset or other data from the other persistence events to this one.

@param[in] func_patch The function to call to perform any necessary patching of the to-be-persisted basic block code. The function should decode up to \p bb_size bytes from \p bb_start and look for call or jump displacements or rip-relative data references that need to be updated to use data in the persisted file. There is no padding between instructions, so a simple decode loop will find every instruction. The \p perscxt parameter can be passed to the routines dr_persist_start(), dr_persist_size(), and dr_fragment_persistable() to identify the region of code being persisted. \return whether successful.