pub trait CopyAddress {
// Required methods
fn copy_address(&self, addr: usize, buf: &mut [u8]) -> Result<()>;
fn get_pointer_width(&self) -> Architecture;
// Provided method
fn get_offset(&self, offsets: &[usize]) -> Result<usize> { ... }
}
Expand description
A trait that defines that it is possible to copy some memory from something represented by a type into a buffer.
Required Methods§
Sourcefn copy_address(&self, addr: usize, buf: &mut [u8]) -> Result<()>
fn copy_address(&self, addr: usize, buf: &mut [u8]) -> Result<()>
Copy an address into user-defined buffer.
§Errors
std::io::Error
if an error occurs copying the address.
Sourcefn get_pointer_width(&self) -> Architecture
fn get_pointer_width(&self) -> Architecture
Get the the pointer width of the underlying process.
This is required for get_offset
to work.
§Performance
Any implementation of this function should be marked with
#[inline(always)]
as this function is very commonly called and
should be inlined.
Provided Methods§
Sourcefn get_offset(&self, offsets: &[usize]) -> Result<usize>
fn get_offset(&self, offsets: &[usize]) -> Result<usize>
Get the actual memory location from a set of offsets.
If copy_address
and get_pointer_width
are already defined, then
we can provide a standard implementation that will work across all
operating systems.
§Errors
std::io::Error
if an error occurs copying the address.