[−][src]Trait process_memory::Memory
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
.
Errors
Returns an error if copying memory fails or if a null pointer dereference would otherwise occur.
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
.
Errors
Returns an error if copying memory fails or if a null pointer dereference would otherwise occur.
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.
Errors
Returns an error if copying memory fails or if a null pointer dereference would otherwise occur.
Implementors
impl<T: Sized + Copy> Memory<T> for DataMember<T>
[src]
fn set_offset(&mut self, new_offsets: Vec<usize>)
[src]
fn get_offset(&self) -> Result<usize>
[src]
fn read(&self) -> Result<T>
[src]
fn write(&self, value: &T) -> Result<()>
[src]
impl<T: Sized + Copy> Memory<T> for LocalMember<T>
[src]
fn set_offset(&mut self, new_offsets: Vec<usize>)
[src]
fn get_offset(&self) -> Result<usize>
[src]
fn read(&self) -> Result<T>
[src]
This will only return a error if one of the offsets gives a null pointer. or give a non-aligned read
fn write(&self, value: &T) -> Result<()>
[src]
This will only return a error if one of the offsets gives a null pointer.