Struct libafl_qemu::emu::Emulator

source ·
pub struct Emulator { /* private fields */ }

Implementations§

source§

impl Emulator

source

pub fn new( args: &[String], env: &[(String, String)] ) -> Result<Emulator, EmuError>

source

pub fn mappings(&self) -> GuestMaps

This function gets the memory mappings from the emulator.

source

pub fn num_cpus(&self) -> usize

source

pub fn current_cpu(&self) -> Option<CPU>

source

pub fn cpu_from_index(&self, index: usize) -> CPU

source

pub fn page_from_addr(addr: GuestAddr) -> GuestAddr

source

pub fn g2h<T>(&self, addr: GuestAddr) -> *mut T

source

pub fn h2g<T>(&self, addr: *const T) -> GuestAddr

source

pub unsafe fn write_mem(&self, addr: GuestAddr, buf: &[u8])

source

pub unsafe fn read_mem(&self, addr: GuestAddr, buf: &mut [u8])

source

pub fn num_regs(&self) -> i32

source

pub fn write_reg<R, T>(&self, reg: R, val: T) -> Result<(), String>where T: Num + PartialOrd + Copy, R: Into<i32>,

source

pub fn read_reg<R, T>(&self, reg: R) -> Result<T, String>where T: Num + PartialOrd + Copy, R: Into<i32>,

source

pub fn set_breakpoint(&self, addr: GuestAddr)

source

pub fn remove_breakpoint(&self, addr: GuestAddr)

source

pub fn set_hook( &self, addr: GuestAddr, callback: extern "C" fn(_: GuestAddr, _: u64), data: u64, invalidate_block: bool ) -> usize

source

pub fn remove_hook(&self, addr: GuestAddr, invalidate_block: bool) -> usize

source

pub unsafe fn run(&self)

This function will run the emulator until the next breakpoint, or until finish.

Safety

Should, in general, be safe to call. Of course, the emulated target is not contained securely and can corrupt state or interact with the operating system.

source

pub fn binary_path<'a>(&self) -> &'a str

source

pub fn load_addr(&self) -> GuestAddr

source

pub fn get_brk(&self) -> GuestAddr

source

pub fn set_brk(&self, brk: GuestAddr)

source

pub fn get_mmap_start(&self) -> GuestAddr

source

pub fn set_mmap_start(&self, start: GuestAddr)

source

pub fn map_private( &self, addr: GuestAddr, size: usize, perms: MmapPerms ) -> Result<GuestAddr, String>

source

pub fn map_fixed( &self, addr: GuestAddr, size: usize, perms: MmapPerms ) -> Result<GuestAddr, String>

source

pub fn mprotect( &self, addr: GuestAddr, size: usize, perms: MmapPerms ) -> Result<(), String>

source

pub fn unmap(&self, addr: GuestAddr, size: usize) -> Result<(), String>

source

pub fn flush_jit(&self)

source

pub fn add_edge_hooks( &self, gen: Option<extern "C" fn(_: GuestAddr, _: GuestAddr, _: u64) -> u64>, exec: Option<extern "C" fn(_: u64, _: u64)>, data: u64 )

source

pub fn add_block_hooks( &self, gen: Option<extern "C" fn(_: GuestAddr, _: u64) -> u64>, exec: Option<extern "C" fn(_: u64, _: u64)>, data: u64 )

source

pub fn add_read_hooks( &self, gen: Option<extern "C" fn(_: GuestAddr, _: MemAccessInfo, _: u64) -> u64>, exec1: Option<extern "C" fn(_: u64, _: GuestAddr, _: u64)>, exec2: Option<extern "C" fn(_: u64, _: GuestAddr, _: u64)>, exec4: Option<extern "C" fn(_: u64, _: GuestAddr, _: u64)>, exec8: Option<extern "C" fn(_: u64, _: GuestAddr, _: u64)>, exec_n: Option<extern "C" fn(_: u64, _: GuestAddr, _: usize, _: u64)>, data: u64 )

source

pub fn add_write_hooks( &self, gen: Option<extern "C" fn(_: GuestAddr, _: MemAccessInfo, _: u64) -> u64>, exec1: Option<extern "C" fn(_: u64, _: GuestAddr, _: u64)>, exec2: Option<extern "C" fn(_: u64, _: GuestAddr, _: u64)>, exec4: Option<extern "C" fn(_: u64, _: GuestAddr, _: u64)>, exec8: Option<extern "C" fn(_: u64, _: GuestAddr, _: u64)>, exec_n: Option<extern "C" fn(_: u64, _: GuestAddr, _: usize, _: u64)>, data: u64 )

source

pub fn add_cmp_hooks( &self, gen: Option<extern "C" fn(_: GuestAddr, _: usize, _: u64) -> u64>, exec1: Option<extern "C" fn(_: u64, _: u8, _: u8, _: u64)>, exec2: Option<extern "C" fn(_: u64, _: u16, _: u16, _: u64)>, exec4: Option<extern "C" fn(_: u64, _: u32, _: u32, _: u64)>, exec8: Option<extern "C" fn(_: u64, _: u64, _: u64, _: u64)>, data: u64 )

source

pub fn add_backdoor_hook( &self, exec: extern "C" fn(_: GuestAddr, _: u64), data: u64 )

source

pub fn set_on_thread_hook(&self, hook: extern "C" fn(tid: u32))

source

pub fn set_pre_syscall_hook( &self, hook: extern "C" fn(_: i32, _: u64, _: u64, _: u64, _: u64, _: u64, _: u64, _: u64, _: u64) -> SyscallHookResult )

source

pub fn set_post_syscall_hook( &self, hook: extern "C" fn(_: u64, _: i32, _: u64, _: u64, _: u64, _: u64, _: u64, _: u64, _: u64, _: u64) -> u64 )

source

pub fn add_gdb_cmd(&self, callback: Box<dyn FnMut(&Self, &str) -> bool>)

source

pub fn gdb_reply(&self, output: &str)

Trait Implementations§

source§

impl Clone for Emulator

source§

fn clone(&self) -> Emulator

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Emulator

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<Tail, T> Prepend<T> for Tail

§

type PreprendResult = Tail

The Resulting [TupleList], of an Prepend::prepend() call, including the prepended entry.
source§

fn prepend(self, value: T) -> (T, <Tail as Prepend<T>>::PreprendResult)

Prepend a value to this tuple, returning a new tuple with prepended value.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.