Skip to main content

InjectionBuilder

Struct InjectionBuilder 

Source
pub struct InjectionBuilder { /* private fields */ }
Expand description

An injection builder holding the target address, returned by Injection::at.

Implementations§

Source§

impl InjectionBuilder

Source

pub fn code(self, code: &[u8]) -> InjectionWith

Injects the caller’s own machine code at the target.

The bytes are copied, so the slice needn’t outlive this call. The code must follow the ABI rules of install.

Source

pub fn asm<F>(self, build: F) -> InjectionWith
where F: FnOnce(&mut CodeAssembler) -> Result<(), IcedError> + 'static,

Injects machine code written as assembly.

build appends to an asm::CodeAssembler; pass Rust values as operands, e.g. a.mov(rax, some_addr). It’s assembled at the stub’s real address, so rip-relative operands resolve, and the jump back is appended. The ABI rules of install apply.

Source

pub fn inspect<F>(self, callback: F) -> InjectionWith
where F: Fn(&Context) + Send + Sync + 'static,

Injects a callback that reads the registers at the target.

callback gets the saved Context, then the original code resumes unchanged. It may run on several threads at once; see Injection.

Source

pub fn modify<F>(self, callback: F) -> InjectionWith
where F: Fn(&mut Context) + Send + Sync + 'static,

Injects a callback that can change the registers at the target.

Like inspect, but register writes take effect before the original code resumes. Changing rip jumps there instead, skipping the displaced instructions.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.