Struct frida_gum::interceptor::Interceptor
source · pub struct Interceptor<'a> { /* private fields */ }
Expand description
Function hooking engine interface.
Implementations§
source§impl<'a> Interceptor<'a>
impl<'a> Interceptor<'a>
sourcepub fn obtain<'b>(_gum: &'b Gum) -> Interceptor<'_>where
'b: 'a,
pub fn obtain<'b>(_gum: &'b Gum) -> Interceptor<'_>where
'b: 'a,
Obtain an Interceptor handle, ensuring that the runtime is properly initialized. This may be called as many times as needed, and results in a no-op if the Interceptor is already initialized.
sourcepub fn attach<I: InvocationListener>(
&mut self,
f: NativePointer,
listener: &mut I
) -> NativePointer
Available on crate feature invocation-listener
only.
pub fn attach<I: InvocationListener>( &mut self, f: NativePointer, listener: &mut I ) -> NativePointer
invocation-listener
only.Attach a listener to the beginning of a function address.
§Safety
The provided address must point to the start of a function in a valid memory region.
sourcepub fn attach_instruction<I: ProbeListener>(
&mut self,
instr: NativePointer,
listener: &mut I
) -> NativePointer
Available on crate feature invocation-listener
only.
pub fn attach_instruction<I: ProbeListener>( &mut self, instr: NativePointer, listener: &mut I ) -> NativePointer
invocation-listener
only.Attach a listener to an instruction address.
§Safety
The provided address must point to a valid instruction.
sourcepub fn detach(&mut self, listener: NativePointer)
Available on crate feature invocation-listener
only.
pub fn detach(&mut self, listener: NativePointer)
invocation-listener
only.Detach an attached listener.
§Safety
The listener must have been attached with Interceptor::attach()
.
sourcepub fn replace(
&mut self,
function: NativePointer,
replacement: NativePointer,
replacement_data: NativePointer
) -> Result<NativePointer>
pub fn replace( &mut self, function: NativePointer, replacement: NativePointer, replacement_data: NativePointer ) -> Result<NativePointer>
Replace a function with another function. The new function should have the same signature as the old one.
§Safety
Assumes that the provided function and replacement addresses are valid and point to the start of valid functions
sourcepub fn replace_fast(
&mut self,
function: NativePointer,
replacement: NativePointer
) -> Result<NativePointer>
pub fn replace_fast( &mut self, function: NativePointer, replacement: NativePointer ) -> Result<NativePointer>
Replace a function with another function. The new function should have the same signature
as the old one. This implementation avoids the overhead of the re-entrancy checking and
context push/pop of conventional interceptors returning the address of a simple trampoline
and patching the original function with the provided replacement. This type is not
interoperable with attach
and requires the caller to pass any required data to the hook
function themselves.
§Safety
Assumes that the provided function and replacement addresses are valid and point to the start of valid functions
sourcepub fn revert(&mut self, function: NativePointer)
pub fn revert(&mut self, function: NativePointer)
Reverts a function replacement for the given function, such that the implementation is the original function.
§Safety
Assumes that function is the start of a real function previously replaced uisng
Interceptor::replace
.
sourcepub fn current_invocation() -> InvocationContext<'a>
Available on crate feature invocation-listener
only.
pub fn current_invocation() -> InvocationContext<'a>
invocation-listener
only.Retrieve the current InvocationContext
.
§Safety
Should only be called from within a hook or replacement function.
sourcepub fn begin_transaction(&mut self)
pub fn begin_transaction(&mut self)
Begin an Interceptor
transaction. This may improve performance if
applying many hooks.
§Safety
After placing hooks, the transaction must be ended with Interceptor::end_transaction()
.
sourcepub fn end_transaction(&mut self)
pub fn end_transaction(&mut self)
End an Interceptor
transaction. This must be called after placing hooks
if in a transaction started with Interceptor::begin_transaction()
.