Expand description
Bindings for the Unicorn emulator.
§Example use
use unicorn_engine::{
RegisterARM,
unicorn_const::{Arch, Mode, Prot, SECOND_SCALE},
};
fn emulate() {
let arm_code32 = [0x17, 0x00, 0x40, 0xe2]; // sub r0, #23
let mut emu = unicorn_engine::Unicorn::new(Arch::ARM, Mode::LITTLE_ENDIAN)
.expect("failed to initialize Unicorn instance");
emu.mem_map(0x1000, 0x4000, Prot::ALL)
.expect("failed to map code page");
emu.mem_write(0x1000, &arm_code32)
.expect("failed to write instructions");
emu.reg_write(RegisterARM::R0, 123)
.expect("failed to write to R0");
emu.reg_write(RegisterARM::R5, 1337)
.expect("failed to write to R5");
emu.emu_start(
0x1000,
(0x1000 + arm_code32.len()) as u64,
10 * SECOND_SCALE,
1000,
)
.unwrap();
assert_eq!(emu.reg_read(RegisterARM::R0), Ok(100));
assert_eq!(emu.reg_read(RegisterARM::R5), Ok(1337));
}
Re-exports§
pub use unicorn_const::*;
Modules§
Structs§
- Context
- Mmio
Callback Scope - UcHook
Id - Unicorn
- A Unicorn emulator instance.
- Unicorn
Inner