[][src]Trait process_memory::Memory

pub trait Memory<T> {
    fn set_offset(&mut self, new_offsets: Vec<usize>);
fn get_offset(&self) -> Result<usize>;
fn read(&self) -> Result<T>;
fn write(&self, value: &T) -> Result<()>; }

A trait that refers to and allows writing to a region of memory in a running program.

Required methods

fn set_offset(&mut self, new_offsets: Vec<usize>)

Set the offsets to the location in memory. This is used for things such as multi-level pointers, such as a Vec<Vec<T>> or a Vec<String>.

For those sorts of data structures, to access data you need to go via multiple pointers, so that if an inner region reallocates its size, the variable that is being modified will be correctly modified.

fn get_offset(&self) -> Result<usize>

Gets the actual total offset from the offsets given by Memory::set_offset.

This function is safe because it should never internally allow for a null pointer deference, and instead should return a std::io::Error with a std::io::ErrorKind of Other.

fn read(&self) -> Result<T>

Reads the value of the pointer from the offsets given by Memory::set_offset.

This function is safe because it should never internally allow for a null pointer deference, and instead should return a std::io::Error with a std::io::ErrorKind of Other.

fn write(&self, value: &T) -> Result<()>

Writes value to the pointer from the offsets given by Memory::set_offset.

This function is safe because it should never internally allow for a null pointer deference, and instead should return a std::io::Error with a std::io::ErrorKind of Other.

This function takes a reference instead of taking ownership so if the caller passes in a String or a Vec, it does not have to be cloned.

Loading content...

Implementors

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

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

fn read(&self) -> Result<T>[src]

This will only return a error if one of the offsets gives a null pointer.

fn write(&self, value: &T) -> Result<()>[src]

This will only return a error if one of the offsets gives a null pointer.

Loading content...