Expand description
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§
Structs§
- Context
- CpuARM
- An ARM emulator instance.
- CpuAR
M64 - 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.
- Unicorn
Hook - Struct to bind a unicorn instance to a callback.
- X86Mmr
Enums§
- Arch
- Code
Hook Type - Error
- Hook
Type - Insn
SysX86 - InsnX86
- MemHook
Type - MemType
- Mode
- Query
- RegisterARM
- RegisterAR
M64 - Register
M68K - RegisterMIPS
- RegisterSPARC
- Register
X86
Constants§
- BINDINGS_
MAJOR - BINDINGS_
MINOR - MILISECOND_
SCALE - PROT_
ALL Deprecated - Use Protection::ALL instead.
- PROT_
EXEC Deprecated - Use Protection::EXEC instead.
- PROT_
NONE Deprecated - Use Protection::NONE instead.
- PROT_
READ Deprecated - Use Protection::READ instead.
- PROT_
WRITE Deprecated - Use Protection::WRITE instead.
- SECOND_
SCALE
Traits§
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.