pub trait MemoryView: Send {
Show 31 methods fn read_raw_iter<'a>(
        &mut self,
        data: CIterator<'_, ReadData<'a>>,
        out_fail: &mut ReadFailCallback<'_, 'a>
    ) -> Result<()>;
fn write_raw_iter<'a>(
        &mut self,
        data: CIterator<'_, WriteData<'a>>,
        out_fail: &mut WriteFailCallback<'_, 'a>
    ) -> Result<()>;
fn metadata(&self) -> MemoryViewMetadata; fn read_raw_list(&mut self, data: &mut [ReadData<'_>]) -> PartialResult<()> { ... }
fn read_raw_into(
        &mut self,
        addr: Address,
        out: &mut [u8]
    ) -> PartialResult<()> { ... }
fn read_raw(&mut self, addr: Address, len: usize) -> PartialResult<Vec<u8>> { ... }
fn read_into<T: Pod + ?Sized>(
        &mut self,
        addr: Address,
        out: &mut T
    ) -> PartialResult<()>
    where
        Self: Sized
, { ... }
fn read<T: Pod + Sized>(&mut self, addr: Address) -> PartialResult<T>
    where
        Self: Sized
, { ... }
fn read_addr32(&mut self, addr: Address) -> PartialResult<Address>
    where
        Self: Sized
, { ... }
fn read_addr64(&mut self, addr: Address) -> PartialResult<Address>
    where
        Self: Sized
, { ... }
fn read_addr_arch(
        &mut self,
        arch: ArchitectureObj,
        addr: Address
    ) -> PartialResult<Address>
    where
        Self: Sized
, { ... }
fn read_ptr_into<U: PrimitiveAddress, T: Pod + ?Sized>(
        &mut self,
        ptr: Pointer<U, T>,
        out: &mut T
    ) -> PartialResult<()>
    where
        Self: Sized
, { ... }
fn read_ptr<U: PrimitiveAddress, T: Pod + Sized>(
        &mut self,
        ptr: Pointer<U, T>
    ) -> PartialResult<T>
    where
        Self: Sized
, { ... }
fn write_raw_list(&mut self, data: &[WriteData<'_>]) -> PartialResult<()> { ... }
fn write_raw(&mut self, addr: Address, data: &[u8]) -> PartialResult<()> { ... }
fn write<T: Pod + ?Sized>(
        &mut self,
        addr: Address,
        data: &T
    ) -> PartialResult<()>
    where
        Self: Sized
, { ... }
fn write_ptr<U: PrimitiveAddress, T: Pod + ?Sized>(
        &mut self,
        ptr: Pointer<U, T>,
        data: &T
    ) -> PartialResult<()>
    where
        Self: Sized
, { ... }
fn read_char_array(
        &mut self,
        addr: Address,
        len: usize
    ) -> PartialResult<String> { ... }
fn read_char_string_n(
        &mut self,
        addr: Address,
        n: usize
    ) -> PartialResult<String> { ... }
fn read_char_string(&mut self, addr: Address) -> PartialResult<String> { ... }
fn cursor(&mut self) -> MemoryCursor<Fwd<&mut Self>>Notable traits for MemoryCursor<T>impl<T: MemoryView> Read for MemoryCursor<T>impl<T: MemoryView> Write for MemoryCursor<T>
    where
        Self: Sized
, { ... }
fn into_cursor(self) -> MemoryCursor<Self>Notable traits for MemoryCursor<T>impl<T: MemoryView> Read for MemoryCursor<T>impl<T: MemoryView> Write for MemoryCursor<T>
    where
        Self: Sized
, { ... }
fn cursor_at(&mut self, address: Address) -> MemoryCursor<Fwd<&mut Self>>Notable traits for MemoryCursor<T>impl<T: MemoryView> Read for MemoryCursor<T>impl<T: MemoryView> Write for MemoryCursor<T>
    where
        Self: Sized
, { ... }
fn into_cursor_at(self, address: Address) -> MemoryCursor<Self>Notable traits for MemoryCursor<T>impl<T: MemoryView> Read for MemoryCursor<T>impl<T: MemoryView> Write for MemoryCursor<T>
    where
        Self: Sized
, { ... }
fn batcher(&mut self) -> MemoryViewBatcher<'_, Self>
    where
        Self: Sized
, { ... }
fn into_overlay_arch(self, arch: ArchitectureObj) -> ArchOverlayView<Self>
    where
        Self: Sized
, { ... }
fn overlay_arch(
        &mut self,
        arch: ArchitectureObj
    ) -> ArchOverlayView<Fwd<&mut Self>>
    where
        Self: Sized
, { ... }
fn into_overlay_arch_parts(
        self,
        arch_bits: u8,
        little_endian: bool
    ) -> ArchOverlayView<Self>
    where
        Self: Sized
, { ... }
fn overlay_arch_parts(
        &mut self,
        arch_bits: u8,
        little_endian: bool
    ) -> ArchOverlayView<Fwd<&mut Self>>
    where
        Self: Sized
, { ... }
fn into_remap_view(
        self,
        mem_map: MemoryMap<(Address, umem)>
    ) -> RemapView<Self>
    where
        Self: Sized
, { ... }
fn remap_view(
        &mut self,
        mem_map: MemoryMap<(Address, umem)>
    ) -> RemapView<Fwd<&mut Self>>
    where
        Self: Sized
, { ... }
}
Expand description

The MemoryView trait implements generic access to memory, no matter if it is a process virtual memory, or machine’s physical memory.

The CPU accesses virtual memory by setting the CR3 register to the appropiate Directory Table Base (DTB) for that process. The ntoskrnl.exe Kernel Process has it’s own DTB. Using the DTB it is possible to resolve the physical memory location of a virtual address page. After the address has been resolved the physical memory page can then be read or written to.

There are 3 methods which are required to be implemented by the provider of this trait.

Examples

Reading from a MemoryView:

use memflow::types::Address;
use memflow::mem::MemoryView;

fn read(mem: &mut impl MemoryView, read_addr: Address) {
    let mut addr = 0u64;
    mem.read_into(read_addr, &mut addr).unwrap();
    println!("addr: {:x}", addr);
}

Required methods

Provided methods

Reads a fixed length string from the target.

Remarks:

The string does not have to be null-terminated. If a null terminator is found the string is truncated to the terminator. If no null terminator is found the resulting string is exactly len characters long.

Reads a variable length string with a length of up to specified amount from the target.

Arguments
  • addr - target address to read from
  • n - maximum number of bytes to read
Remarks:

The string must be null-terminated. If no null terminator is found the this function will return an error.

For reading fixed-size char arrays the [virt_read_char_array] should be used.

Reads a variable length string with up to 4kb length from the target.

Arguments
  • addr - target address to read from

Implementations on Foreign Types

Implementors