[][src]Struct process_memory::DataMember

pub struct DataMember<T> { /* fields omitted */ }

Tools for working with memory of other programs

This module provides functions for modifying the memory of a program from outside of the address space of that program.

Examples:

// We have a variable with some value
let x = 4u32;
println!("Original x-value: {}", x);

// We need to make sure that we get a handle to a process, in this case, ourselves
let handle = (std::process::id() as Pid).try_into_process_handle().unwrap();
// We make a `DataMember` that has an offset referring to its location in memory
let member = DataMember::new_offset(handle, vec![&x as *const _ as usize]);
// The memory refered to is now the same
println!("Memory location: &x: {}, member: {}", &x as *const _ as usize,
    member.get_offset().unwrap());
assert_eq!(&x as *const _ as usize, member.get_offset().unwrap());
// The value of the member is the same as the variable
println!("Member value: {}", member.read().unwrap());
assert_eq!(x, member.read().unwrap());
// We can write to and modify the value of the variable using the member
member.write(&6u32).unwrap();
println!("New x-value: {}", x);
assert_eq!(x, 6u32);

Implementations

impl<T: Sized + Copy> DataMember<T>[src]

#[must_use]pub fn new(handle: ProcessHandle) -> Self[src]

Create a new DataMember from a ProcessHandle. You must remember to call try_into_process_handle on a Pid, because the types may have the same backing type, resulting in errors when called with the wrong value.

By default, there will be no offsets, leading to an error when attempting to call Memory::read, so you will likely need to call Memory::set_offset before attempting any reads.

#[must_use]pub fn new_offset(handle: ProcessHandle, offsets: Vec<usize>) -> Self[src]

Create a new DataMember from a ProcessHandle and some number of offsets. You must remember to call try_into_process_handle on a Pid as sometimes the Pid can have the same backing type as a ProcessHandle, resulting in an error.

Trait Implementations

impl<T: Clone> Clone for DataMember<T>[src]

impl<T: Debug> Debug for DataMember<T>[src]

impl<T: Sized + Copy> Memory<T> for DataMember<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for DataMember<T> where
    T: RefUnwindSafe

impl<T> !Send for DataMember<T>

impl<T> !Sync for DataMember<T>

impl<T> Unpin for DataMember<T>

impl<T> UnwindSafe for DataMember<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.