[][src]Crate unicorn

Bindings for the Unicorn emulator.

You most likely want to use one of the Cpu structs (CpuX86, CpuARM, etc.).

Example use

extern crate unicorn;

use unicorn::{Cpu, CpuX86, uc_handle};

fn main() {
   let x86_code32 : Vec<u8> = vec![0x41, 0x4a]; // INC ecx; DEC edx

   let mut emu = CpuX86::new(unicorn::Mode::MODE_32).expect("failed to instantiate emulator");
   emu.mem_map(0x1000, 0x4000, unicorn::Protection::ALL);
   emu.mem_write(0x1000, &x86_code32);
   emu.reg_write_i32(unicorn::RegisterX86::ECX, -10);
   emu.reg_write_i32(unicorn::RegisterX86::EDX, -50);

   emu.emu_start(0x1000, (0x1000 + x86_code32.len()) as u64, 10 * unicorn::SECOND_SCALE, 1000);
   assert_eq!(emu.reg_read_i32(unicorn::RegisterX86::ECX), Ok((-9)));
   assert_eq!(emu.reg_read_i32(unicorn::RegisterX86::EDX), Ok((-51)));
}

Modules

unicorn_const

Structs

Context
CpuARM

An ARM emulator instance.

CpuARM64

An ARM64 emulator instance.

CpuM68K

A M68K emulator instance.

CpuMIPS

A MIPS emulator instance.

CpuSPARC

A SPARC emulator instance.

CpuX86

An X86 emulator instance.

MemRegion
Protection
Unicorn

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

UnicornHook

Struct to bind a unicorn instance to a callback.

X86Mmr

Enums

Arch
CodeHookType
Error
HookType
InsnSysX86
InsnX86
MemHookType
MemType
Mode
Query
RegisterARM
RegisterARM64
RegisterM68K
RegisterMIPS
RegisterSPARC
RegisterX86

Constants

BINDINGS_MAJOR
BINDINGS_MINOR
MILISECOND_SCALE
PROT_ALLDeprecated

Use Protection::ALL instead.

PROT_EXECDeprecated

Use Protection::EXEC instead.

PROT_NONEDeprecated

Use Protection::NONE instead.

PROT_READDeprecated

Use Protection::READ instead.

PROT_WRITEDeprecated

Use Protection::WRITE instead.

SECOND_SCALE

Traits

Cpu
Register

Functions

arch_supported

Returns true if the architecture is supported by this build of unicorn.

bindings_version

Returns a tuple (major, minor) for the bindings version number.

uc_arch_supported
uc_close
uc_context_alloc
uc_context_restore
uc_context_save
uc_emu_start
uc_emu_stop
uc_errno
uc_free
uc_hook_add
uc_hook_del
uc_mem_map
uc_mem_map_ptr
uc_mem_protect
uc_mem_read
uc_mem_regions
uc_mem_unmap
uc_mem_write
uc_open
uc_query
uc_reg_read
uc_reg_write
uc_strerror
uc_version
unicorn_version

Returns a tuple (major, minor) for the unicorn version number.

Type Definitions

uc_context
uc_handle
uc_hook