pub struct VirtMem {
pub mode: VirtMemMode,
pub covtrace: RefCell<VirtMemAllocator>,
pub covtrace_snapshot: RefCell<VirtMemAllocator>,
pub backtrace: RefCell<VirtMemAllocator>,
pub backtrace_snapshot: RefCell<VirtMemAllocator>,
}
Expand description
A wrapper structure for the coverage and backtrace address spaces. The current mode is
defined by the value stored in mode
which is either VirtMemMode::Coverage
or
VirtMemMode::Backtrace
.
Fields
mode: VirtMemMode
The address space type currently in use by the fuzzer.
covtrace: RefCell<VirtMemAllocator>
The address space where coverage hooks are applied.
covtrace_snapshot: RefCell<VirtMemAllocator>
Snapshot of the address space where coverage hooks are applied.
backtrace: RefCell<VirtMemAllocator>
The address space where backtrace hooks are applied.
backtrace_snapshot: RefCell<VirtMemAllocator>
Snapshot of the address space where backtrace hooks are applied.
Implementations
sourceimpl VirtMem
impl VirtMem
sourcepub fn new(pma: PhysMemAllocator) -> Result<Self>
pub fn new(pma: PhysMemAllocator) -> Result<Self>
Creates a new virtual memory wrapper structure.
sourcepub fn borrow(&self) -> Ref<'_, VirtMemAllocator>
pub fn borrow(&self) -> Ref<'_, VirtMemAllocator>
Borrows the address space in the current mode.
sourcepub fn borrow_mut(&self) -> RefMut<'_, VirtMemAllocator>
pub fn borrow_mut(&self) -> RefMut<'_, VirtMemAllocator>
Mutably borrows the address space in the current mode.
sourcepub fn borrow_snapshot(&self) -> Ref<'_, VirtMemAllocator>
pub fn borrow_snapshot(&self) -> Ref<'_, VirtMemAllocator>
Borrows the snapshot of the address space in the current mode.
sourcepub fn borrow_snapshot_mut(&self) -> RefMut<'_, VirtMemAllocator>
pub fn borrow_snapshot_mut(&self) -> RefMut<'_, VirtMemAllocator>
Mutably borrows the snapshot of the address space in the current mode.
sourcepub fn map(&mut self, addr: u64, size: usize, perms: MemPerms) -> Result<()>
pub fn map(&mut self, addr: u64, size: usize, perms: MemPerms) -> Result<()>
Wrapper for VirtMemAllocator::map
borrowing the
address space currently in use.
sourcepub fn map_privileged(
&mut self,
addr: u64,
size: usize,
perms: MemPerms
) -> Result<()>
pub fn map_privileged(
&mut self,
addr: u64,
size: usize,
perms: MemPerms
) -> Result<()>
Wrapper for
VirtMemAllocator::map_privileged
borrowing the address space currently in use.
sourcepub fn unmap(&mut self, addr: u64, size: usize) -> Result<()>
pub fn unmap(&mut self, addr: u64, size: usize) -> Result<()>
Wrapper for VirtMemAllocator::unmap
borrowing
the address space currently in use.
sourcepub fn restore_from_snapshot(
&mut self,
snapshot: &VirtMemAllocator
) -> Result<()>
pub fn restore_from_snapshot(
&mut self,
snapshot: &VirtMemAllocator
) -> Result<()>
Wrapper for
VirtMemAllocator::restore_from_snapshot
borrowing the address space currently in use.
sourcepub fn read(&self, addr: u64, buf: &mut [u8]) -> Result<usize>
pub fn read(&self, addr: u64, buf: &mut [u8]) -> Result<usize>
Wrapper for VirtMemAllocator::read
borrowing
the address space currently in use.
sourcepub fn read_byte(&self, addr: u64) -> Result<u8>
pub fn read_byte(&self, addr: u64) -> Result<u8>
Wrapper for VirtMemAllocator::read_byte
borrowing the address space currently in use.
sourcepub fn read_word(&self, addr: u64) -> Result<u16>
pub fn read_word(&self, addr: u64) -> Result<u16>
Wrapper for VirtMemAllocator::read_word
borrowing the address space currently in use.
sourcepub fn read_dword(&self, addr: u64) -> Result<u32>
pub fn read_dword(&self, addr: u64) -> Result<u32>
Wrapper for VirtMemAllocator::read_dword
borrowing the address space currently in use.
sourcepub fn read_qword(&self, addr: u64) -> Result<u64>
pub fn read_qword(&self, addr: u64) -> Result<u64>
Wrapper for VirtMemAllocator::read_qword
borrowing the address space currently in use.
sourcepub fn read_cstring(&self, addr: u64) -> Result<String>
pub fn read_cstring(&self, addr: u64) -> Result<String>
Wrapper for
VirtMemAllocator::read_cstring
borrowing
the address space currently in use.
sourcepub fn write(&mut self, addr: u64, buf: &[u8]) -> Result<usize>
pub fn write(&mut self, addr: u64, buf: &[u8]) -> Result<usize>
Wrapper for VirtMemAllocator::write
borrowing
the address space currently in use.
sourcepub fn write_byte(&mut self, addr: u64, data: u8) -> Result<usize>
pub fn write_byte(&mut self, addr: u64, data: u8) -> Result<usize>
Wrapper for VirtMemAllocator::write_byte
borrowing the address space currently in use.
sourcepub fn write_word(&mut self, addr: u64, data: u16) -> Result<usize>
pub fn write_word(&mut self, addr: u64, data: u16) -> Result<usize>
Wrapper for VirtMemAllocator::write_word
borrowing the address space currently in use.
sourcepub fn write_dword(&mut self, addr: u64, data: u32) -> Result<usize>
pub fn write_dword(&mut self, addr: u64, data: u32) -> Result<usize>
Wrapper for VirtMemAllocator::write_dword
borrowing the address space currently in use.
sourcepub fn write_qword(&mut self, addr: u64, data: u64) -> Result<usize>
pub fn write_qword(&mut self, addr: u64, data: u64) -> Result<usize>
Wrapper for VirtMemAllocator::write_qword
borrowing the address space currently in use.
sourcepub fn write_cstring(&mut self, addr: u64, s: &str) -> Result<usize>
pub fn write_cstring(&mut self, addr: u64, s: &str) -> Result<usize>
Wrapper for
VirtMemAllocator::write_cstring
borrowing the address space currently in use.
sourcepub fn write_dirty(&mut self, addr: u64, buf: &[u8]) -> Result<usize>
pub fn write_dirty(&mut self, addr: u64, buf: &[u8]) -> Result<usize>
Wrapper for VirtMemAllocator::write_dirty
borrowing the address space currently in use.
sourcepub fn write_byte_dirty(&mut self, addr: u64, data: u8) -> Result<usize>
pub fn write_byte_dirty(&mut self, addr: u64, data: u8) -> Result<usize>
Wrapper for
VirtMemAllocator::write_byte_dirty
borrowing the address space currently in use.
sourcepub fn write_word_dirty(&mut self, addr: u64, data: u16) -> Result<usize>
pub fn write_word_dirty(&mut self, addr: u64, data: u16) -> Result<usize>
Wrapper for
VirtMemAllocator::write_word_dirty
borrowing the address space currently in use.
sourcepub fn write_dword_dirty(&mut self, addr: u64, data: u32) -> Result<usize>
pub fn write_dword_dirty(&mut self, addr: u64, data: u32) -> Result<usize>
Wrapper for
VirtMemAllocator::write_dword_dirty
borrowing the address space currently in use.
sourcepub fn write_qword_dirty(&mut self, addr: u64, data: u64) -> Result<usize>
pub fn write_qword_dirty(&mut self, addr: u64, data: u64) -> Result<usize>
Wrapper for
VirtMemAllocator::write_qword_dirty
borrowing the address space currently in use.
sourcepub fn write_cstring_dirty(&mut self, addr: u64, s: &str) -> Result<usize>
pub fn write_cstring_dirty(&mut self, addr: u64, s: &str) -> Result<usize>
Wrapper for
VirtMemAllocator::write_cstring_dirty
borrowing the address space currently in use.