MemoryRead

Trait MemoryRead 

Source
pub trait MemoryRead {
    // Required method
    fn try_read_bytes_into(&self, address: u64, buffer: &mut [u8]) -> Option<()>;

    // Provided methods
    fn try_read_bytes(&self, address: u64, len: usize) -> Option<Vec<u8>> { ... }
    fn dump_memory(&self, range: MemoryRange) -> Option<Vec<u8>> { ... }
    fn valid_address(&self, address: u64) -> bool { ... }
    fn try_read_string(
        &self,
        address: u64,
    ) -> Option<Result<String, FromUtf8Error>> { ... }
    fn try_read_string_wide(
        &self,
        address: u64,
    ) -> Option<Result<String, FromUtf16Error>> { ... }
}
Expand description

Represents any type with a buffer that can be read from

Required Methods§

Source

fn try_read_bytes_into(&self, address: u64, buffer: &mut [u8]) -> Option<()>

Reads bytes from the process at the specified address into a buffer. Returns None if the address is not valid

Provided Methods§

Source

fn try_read_bytes(&self, address: u64, len: usize) -> Option<Vec<u8>>

Reads bytes from the process at the specified address and returns the bytes as a Vector. Returns none if the address is not valid

Source

fn dump_memory(&self, range: MemoryRange) -> Option<Vec<u8>>

Dumps a memory range into a Vector. If any part of the memory range is not valid, it will return None

Source

fn valid_address(&self, address: u64) -> bool

Returns true if the specified address is valid. By default reads one byte at that location and returns the success value

Source

fn try_read_string(&self, address: u64) -> Option<Result<String, FromUtf8Error>>

Reads a string at the specified location with char length of 1. If the address is valid or there is no null terminator in MAX_STRING_SIZE characters, it will return None

Source

fn try_read_string_wide( &self, address: u64, ) -> Option<Result<String, FromUtf16Error>>

Reads a wide string at the specified location with char length of 1. If the address is valid or there is no null terminator in MAX_STRING_SIZE characters, it will return None

Trait Implementations§

Source§

impl MemoryReadExt for dyn MemoryRead

Source§

fn try_read<T: Pod>(&self, address: u64) -> Option<T>

Reads bytes from the process at the specified address into a value of type T. Returns None if the address is not valid
Source§

unsafe fn try_read_unchecked<T>(&self, address: u64) -> Option<T>

Reads any type T from the process without the restriction of Pod
Source§

fn read<T: Pod>(&self, address: u64) -> T

Reads bytes from the process at the specified address into a value of type T. Panics if the address is not valid
Source§

fn try_read_bytes_const<const LEN: usize>( &self, address: u64, ) -> Option<[u8; LEN]>

Reads a const number of bytes from the process returning a stack allocated array.
Source§

fn try_read_bytes_into_chunked<const CHUNK_SIZE: usize>( &self, address: u64, buf: &mut [u8], ) -> Option<()>

Reads bytes from the process in chunks with the specified size
Source§

fn try_read_bytes_into_chunked_fallible<const CHUNK_SIZE: usize>( &self, address: u64, buf: &mut [u8], ) -> Option<usize>

Reads bytes from the process in chunks with the specified size. The function will return Some(n) with the number of bytes read unless every single chunk fails

Implementations on Foreign Types§

Source§

impl<'a> MemoryRead for &'a [u8]

Source§

fn try_read_bytes_into(&self, address: u64, buffer: &mut [u8]) -> Option<()>

Source§

impl<'a, T: 'a + MemoryRead + ?Sized> MemoryRead for &'a T

Source§

fn try_read_bytes_into(&self, address: u64, buffer: &mut [u8]) -> Option<()>

Source§

fn try_read_bytes(&self, address: u64, len: usize) -> Option<Vec<u8>>

Source§

fn dump_memory(&self, range: MemoryRange) -> Option<Vec<u8>>

Source§

fn valid_address(&self, address: u64) -> bool

Source§

fn try_read_string(&self, address: u64) -> Option<Result<String, FromUtf8Error>>

Source§

fn try_read_string_wide( &self, address: u64, ) -> Option<Result<String, FromUtf16Error>>

Source§

impl<'a, T: 'a + MemoryRead + ?Sized> MemoryRead for &'a mut T

Source§

fn try_read_bytes_into(&self, address: u64, buffer: &mut [u8]) -> Option<()>

Source§

fn try_read_bytes(&self, address: u64, len: usize) -> Option<Vec<u8>>

Source§

fn dump_memory(&self, range: MemoryRange) -> Option<Vec<u8>>

Source§

fn valid_address(&self, address: u64) -> bool

Source§

fn try_read_string(&self, address: u64) -> Option<Result<String, FromUtf8Error>>

Source§

fn try_read_string_wide( &self, address: u64, ) -> Option<Result<String, FromUtf16Error>>

Source§

impl<T: AsRef<[u8]>> MemoryRead for Cell<T>

Source§

fn try_read_bytes_into(&self, address: u64, buffer: &mut [u8]) -> Option<()>

Source§

impl<T: MemoryRead + ?Sized> MemoryRead for Box<T>

Source§

fn try_read_bytes_into(&self, address: u64, buffer: &mut [u8]) -> Option<()>

Source§

fn try_read_bytes(&self, address: u64, len: usize) -> Option<Vec<u8>>

Source§

fn dump_memory(&self, range: MemoryRange) -> Option<Vec<u8>>

Source§

fn valid_address(&self, address: u64) -> bool

Source§

fn try_read_string(&self, address: u64) -> Option<Result<String, FromUtf8Error>>

Source§

fn try_read_string_wide( &self, address: u64, ) -> Option<Result<String, FromUtf16Error>>

Implementors§