Skip to main content

drwrap_replace

Function drwrap_replace 

Source
pub unsafe extern "C" fn drwrap_replace(
    original: app_pc,
    replacement: app_pc,
    override_: bool_,
) -> bool_
Expand description

Replaces the application function that starts at the address \p original with the code at the address \p replacement.

Only one replacement is supported per target address. If a replacement already exists for \p original, this function fails unless \p override is true, in which case it replaces the prior replacement. To remove a replacement, pass NULL for \p replacement and \b true for \p override. When removing or replacing a prior replacement, existing replaced code in the code cache will be flushed lazily: i.e., there may be some execution in other threads after this call is made.

Only the first target replacement address in a basic block will be honored. All code after that address is removed.

When replacing a function, it is up to the user to ensure that the replacement mirrors the calling convention and other semantics of the original function. The replacement code will be executed as application code, NOT as client code.

\note The priority of the app2app pass used here is DRMGR_PRIORITY_APP2APP_DRWRAP and its name is DRMGR_PRIORITY_NAME_DRWRAP.

\note Not supported if #DRWRAP_INVERT_CONTROL is set.

\return whether successful.