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
impl Injection
pub fn new(entry_point: usize, f_new: Vec<u8>) -> Injection
Sourcepub fn new_from_aob(
region: &MemoryRegion,
f_new: Vec<u8>,
memory_pattern: MemoryPattern,
) -> Result<Injection>
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§
Auto Trait Implementations§
impl Freeze for Injection
impl RefUnwindSafe for Injection
impl Send for Injection
impl Sync for Injection
impl Unpin for Injection
impl UnwindSafe for Injection
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more