x86emu

Trait Cpu

Source
pub trait Cpu {
    type Error;

Show 17 methods // Required methods fn read_memory( &mut self, gva: u64, bytes: &mut [u8], is_user_mode: bool, ) -> impl Future<Output = Result<(), Self::Error>>; fn write_memory( &mut self, gva: u64, bytes: &[u8], is_user_mode: bool, ) -> impl Future<Output = Result<(), Self::Error>>; fn compare_and_write_memory( &mut self, gva: u64, current: &[u8], new: &[u8], is_user_mode: bool, ) -> impl Future<Output = Result<bool, Self::Error>>; fn read_io( &mut self, io_port: u16, bytes: &mut [u8], ) -> impl Future<Output = Result<(), Self::Error>>; fn write_io( &mut self, io_port: u16, bytes: &[u8], ) -> impl Future<Output = Result<(), Self::Error>>; fn gp(&mut self, reg: RegisterIndex) -> u64; fn gp_sign_extend(&mut self, reg: RegisterIndex) -> i64; fn set_gp(&mut self, reg: RegisterIndex, v: u64); fn xmm(&mut self, index: usize) -> u128; fn set_xmm(&mut self, index: usize, v: u128) -> Result<(), Self::Error>; fn rip(&mut self) -> u64; fn set_rip(&mut self, v: u64); fn segment(&mut self, index: Segment) -> SegmentRegister; fn efer(&mut self) -> u64; fn cr0(&mut self) -> u64; fn rflags(&mut self) -> RFlags; fn set_rflags(&mut self, v: RFlags);
}
Expand description

Trait for asynchronous callouts from the emulator to the VM.

Required Associated Types§

Source

type Error

The error type for IO access failures.

Required Methods§

Source

fn read_memory( &mut self, gva: u64, bytes: &mut [u8], is_user_mode: bool, ) -> impl Future<Output = Result<(), Self::Error>>

Performs a memory read of 1, 2, 4, or 8 bytes.

Source

fn write_memory( &mut self, gva: u64, bytes: &[u8], is_user_mode: bool, ) -> impl Future<Output = Result<(), Self::Error>>

Performs a memory write of 1, 2, 4, or 8 bytes.

Source

fn compare_and_write_memory( &mut self, gva: u64, current: &[u8], new: &[u8], is_user_mode: bool, ) -> impl Future<Output = Result<bool, Self::Error>>

Performs an atomic, sequentially-consistent compare exchange on a memory location.

The caller has already fetched current via read_memory, so the implementor only needs to perform an atomic compare+write if the memory could have mutated concurrently and supports atomic operation. This includes ordinary RAM, but does not include device registers.

Returns true if the exchange succeeded, false otherwise.

Source

fn read_io( &mut self, io_port: u16, bytes: &mut [u8], ) -> impl Future<Output = Result<(), Self::Error>>

Performs an io read of 1, 2, or 4 bytes.

Source

fn write_io( &mut self, io_port: u16, bytes: &[u8], ) -> impl Future<Output = Result<(), Self::Error>>

Performs an io write of 1, 2, or 4 bytes.

Source

fn gp(&mut self, reg: RegisterIndex) -> u64

Source

fn gp_sign_extend(&mut self, reg: RegisterIndex) -> i64

Source

fn set_gp(&mut self, reg: RegisterIndex, v: u64)

Source

fn xmm(&mut self, index: usize) -> u128

Source

fn set_xmm(&mut self, index: usize, v: u128) -> Result<(), Self::Error>

Source

fn rip(&mut self) -> u64

Source

fn set_rip(&mut self, v: u64)

Source

fn segment(&mut self, index: Segment) -> SegmentRegister

Source

fn efer(&mut self) -> u64

Source

fn cr0(&mut self) -> u64

Source

fn rflags(&mut self) -> RFlags

Source

fn set_rflags(&mut self, v: RFlags)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: Cpu + ?Sized> Cpu for &mut T

Source§

type Error = <T as Cpu>::Error

Source§

fn read_memory( &mut self, gva: u64, bytes: &mut [u8], is_user_mode: bool, ) -> impl Future<Output = Result<(), Self::Error>>

Source§

fn write_memory( &mut self, gva: u64, bytes: &[u8], is_user_mode: bool, ) -> impl Future<Output = Result<(), Self::Error>>

Source§

fn compare_and_write_memory( &mut self, gva: u64, current: &[u8], new: &[u8], is_user_mode: bool, ) -> impl Future<Output = Result<bool, Self::Error>>

Source§

fn read_io( &mut self, io_port: u16, bytes: &mut [u8], ) -> impl Future<Output = Result<(), Self::Error>>

Source§

fn write_io( &mut self, io_port: u16, bytes: &[u8], ) -> impl Future<Output = Result<(), Self::Error>>

Source§

fn gp(&mut self, reg: RegisterIndex) -> u64

Source§

fn gp_sign_extend(&mut self, reg: RegisterIndex) -> i64

Source§

fn set_gp(&mut self, reg: RegisterIndex, v: u64)

Source§

fn xmm(&mut self, index: usize) -> u128

Source§

fn set_xmm(&mut self, index: usize, v: u128) -> Result<(), Self::Error>

Source§

fn rip(&mut self) -> u64

Source§

fn set_rip(&mut self, v: u64)

Source§

fn segment(&mut self, index: Segment) -> SegmentRegister

Source§

fn efer(&mut self) -> u64

Source§

fn cr0(&mut self) -> u64

Source§

fn rflags(&mut self) -> RFlags

Source§

fn set_rflags(&mut self, v: RFlags)

Implementors§