Struct unicorn::Unicorn [] [src]

pub struct Unicorn {
    // some fields omitted
}

Internal : A Unicorn emulator instance, use one of the Cpu structs instead.

Methods

impl Unicorn
[src]

fn new(arch: Arch, mode: Mode) -> Result<UnicornError>

Create a new instance of the unicorn engine for the specified architecture and hardware mode.

fn reg_write(&self, regid: i32, value: u64) -> Result<()Error>

Write an unsigned value register.

Note : The register is defined as an i32 to be able to support the different register types (RegisterX86, RegisterARM, RegisterMIPS etc.). You need to cast the register with as i32.

fn reg_write_i32(&self, regid: i32, value: i32) -> Result<()Error>

Write a signed 32-bit value to a register.

Note : The register is defined as an i32 to be able to support the different register types (RegisterX86, RegisterARM, RegisterMIPS etc.). You need to cast the register with as i32.

fn reg_read(&self, regid: i32) -> Result<u64Error>

Read an unsigned value from a register.

Note : The register is defined as an i32 to be able to support the different register types (RegisterX86, RegisterARM, RegisterMIPS etc.). You need to cast the register with as i32.

fn reg_read_i32(&self, regid: i32) -> Result<i32Error>

Read a signed 32-bit value from a register.

Note : The register is defined as an i32 to be able to support the different register types (RegisterX86, RegisterARM, RegisterMIPS etc.). You need to cast the register with as i32.

fn mem_map(&self, address: u64, size: size_t, perms: Protection) -> Result<()Error>

Map a memory region in the emulator at the specified address.

address must be aligned to 4kb or this will return Error::ARG. size must be a multiple of 4kb or this will return Error::ARG.

fn mem_unmap(&self, address: u64, size: size_t) -> Result<()Error>

Unmap a memory region.

address must be aligned to 4kb or this will return Error::ARG. size must be a multiple of 4kb or this will return Error::ARG.

fn mem_write(&self, address: u64, bytes: &[u8]) -> Result<()Error>

Write a range of bytes to memory at the specified address.

fn mem_read(&self, address: u64, size: usize) -> Result<Vec<u8>, Error>

Read a range of bytes from memory at the specified address.

fn mem_protect(&self, address: u64, size: usize, perms: Protection) -> Result<()Error>

Set the memory permissions for an existing memory region.

address must be aligned to 4kb or this will return Error::ARG. size must be a multiple of 4kb or this will return Error::ARG.

fn mem_regions(&self) -> Result<Vec<MemRegion>, Error>

Returns a vector with the memory regions that are mapped in the emulator.

fn emu_start(&self, begin: u64, until: u64, timeout: u64, count: usize) -> Result<()Error>

Emulate machine code for a specified duration.

begin is the address where to start the emulation. The emulation stops if until is hit. timeout specifies a duration in microseconds after which the emulation is stopped (infinite execution if set to 0). count is the maximum number of instructions to emulate (emulate all the available instructions if set to 0).

fn emu_stop(&self) -> Result<()Error>

Stop the emulation.

This is usually called from callback function in hooks. NOTE: For now, this will stop the execution only after the current block.

fn add_code_hook(&self, hook_type: HookType, begin: u64, end: u64, callback: extern fn(engine: uc_handle, address: u64, size: u32, user_data: *mut u64)) -> Result<uc_hookError>

Add a code hook.

fn add_mem_hook(&self, hook_type: HookType, begin: u64, end: u64, callback: extern fn(engine: uc_handle, mem_type: MemType, address: u64, size: i32, value: i64, user_data: *mut u64)) -> Result<uc_hookError>

Add a memory hook.

fn remove_hook(&self, hook: uc_hook) -> Result<()Error>

Remove a hook.

hook is the value returned by either add_code_hook or add_mem_hook.

fn errno(&self) -> Error

Return the last error code when an API function failed.

Like glibc errno(), this function might not retain its old value once accessed.

fn query(&self, query: Query) -> Result<usizeError>

Query the internal status of the engine.

Supported queries :

  • Query::PAGE_SIZE : the page size used by the emulator.
  • Query::MODE : the current hardware mode.

Trait Implementations

impl Drop for Unicorn
[src]

fn drop(&mut self)

A method called when the value goes out of scope. Read more