Struct Injection

Source
pub struct Injection {
    pub entry_point: usize,
    pub f_orig: Vec<u8>,
    pub f_new: Vec<u8>,
}
Expand description

Injection is a simple structure that contains an address where the instructions to be modified are, and the original bytes with the new ones. This struct is intended to be injected and removed easily.

Fields§

§entry_point: usize

Entry point relative to the executable

§f_orig: Vec<u8>

Original bytes

§f_new: Vec<u8>

Bytes to be injected

Implementations§

Source§

impl Injection

Source

pub fn new(entry_point: usize, f_new: Vec<u8>) -> Injection

Source

pub fn new_from_aob( region: &MemoryRegion, f_new: Vec<u8>, memory_pattern: MemoryPattern, ) -> Result<Injection>

Creates a new injection using the generate_aob_pattern macro.

§Example
static arr: [u8; 5] = [0xEE, 0xAA, 0xFF, 0xBB, 0xFF];
let mut injection = Injection::new_from_aob(&proc_inf.region, vec![0x90; 3],
    generate_aob_pattern![0xAA, _, 0xBB, 0xFF]).unwrap();
// With this we nop the bytes (i.e. we write 0x90) where
// generate_aob_pattern has a match.
injection.inject();
assert_eq!(&arr[1..4], &[0x90, 0x90, 0x90]);

// If we remove the injection (or `injection` gets dropped) the original
// array should be restored.
injection.remove_injection();
assert_eq!(&arr[1..4], &[0xAA, 0xFF, 0xBB]);

Trait Implementations§

Source§

impl Debug for Injection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Injection

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Inject for Injection

Source§

fn inject(&mut self)

Source§

fn remove_injection(&mut self)

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.