Rust bindings for the Unicorn emulator with utility functions.
Checkout Unicorn2 source code at dev branch.
```rust use unicornengine::{Unicorn, RegisterARM}; use unicornengine::unicornconst::{Arch, Mode, Permission, SECONDSCALE};
fn main() {
let arm_code32: Vec
let mut unicorn = Unicorn::new(Arch::ARM, Mode::LITTLE_ENDIAN).expect("failed to initialize Unicorn instance");
let mut emu = unicorn.borrow();
emu.mem_map(0x1000, 0x4000, Permission::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 write R0");
emu.reg_write(RegisterARM::R5, 1337).expect("failed write R5");
let _ = emu.emu_start(0x1000, (0x1000 + arm_code32.len()) as u64, 10 * SECOND_SCALE, 1000);
assert_eq!(emu.reg_read(RegisterARM::R0, Ok(100));
assert_eq!(emu.reg_read(RegisterARM::R5, Ok(1337));
}
Further sample code can be found in
tests/unicorn.rs```.
Add this to your Cargo.toml
:
[dependencies]
unicorn-engine = "2.0.0-rc3"
These bindings are based on Sébastien Duquette's (@ekse) unicorn-rs. We picked up the project, as it is no longer maintained. Thanks to all contributors.