13 releases (7 stable)

Uses new Rust 2024

2.1.5 Sep 9, 2025
2.1.3 Mar 7, 2025
2.1.2 Feb 13, 2025
2.1.1 Sep 26, 2024
2.0.0-rc5.post1 Nov 25, 2021

#7 in Emulators

Download history 679/week @ 2026-01-17 354/week @ 2026-01-24 474/week @ 2026-01-31 528/week @ 2026-02-07 400/week @ 2026-02-14 391/week @ 2026-02-21 461/week @ 2026-02-28 1166/week @ 2026-03-07 922/week @ 2026-03-14 623/week @ 2026-03-21 1202/week @ 2026-03-28 2012/week @ 2026-04-04 1026/week @ 2026-04-11 1187/week @ 2026-04-18 703/week @ 2026-04-25 947/week @ 2026-05-02

4,086 downloads per month
Used in 6 crates

GPL-2.0 license

13MB
308K SLoC

C 290K SLoC // 0.1% comments Shell 6.5K SLoC // 0.0% comments Bitbake 6K SLoC Rust 5K SLoC // 0.0% comments Python 268 SLoC // 0.1% comments Zig 174 SLoC // 0.2% comments C++ 15 SLoC Assembly 8 SLoC // 0.5% comments

Unicorn-engine

Rust bindings for the Unicorn emulator with utility functions.

Checkout Unicorn2 source code at dev branch.

use unicorn_engine::{Arch, Mode, Prot, SECOND_SCALE, Unicorn, RegisterARM};

fn main() {
    let arm_code32: Vec<u8> = vec![0x17, 0x00, 0x40, 0xe2]; // sub r0, #23

    let mut emu = 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 write R0");
    emu.reg_write(RegisterARM::R5, 1337).expect("failed write R5");

    emu.emu_start(0x1000, (0x1000 + arm_code32.len()) as u64, 10 * SECOND_SCALE, 1000).expect("failed to start emulation");
    assert_eq!(emu.reg_read(RegisterARM::R0).unwrap(), 100);
    assert_eq!(emu.reg_read(RegisterARM::R5).unwrap(), 1337);
}

Further sample code can be found in tests.

Usage

Add this to your Cargo.toml:

[dependencies]
unicorn-engine = "2.1.1"

Acknowledgements

These bindings were once based on Sébastien Duquette's (@ekse) unicorn-rs. We picked up the project, as it is no longer maintained. Thanks to all contributors.

Dependencies