1 个不稳定版本

0.1.0 2021年8月13日

#6 in #emu

GPL-2.0 许可证

7MB
173K SLoC

C 133K SLoC // 0.1% comments · Rust 包仓库 Python 11K SLoC // 0.1% comments · Rust 包仓库 Visual Studio Project 6K SLoC · Rust 包仓库 Java 4K SLoC // 0.2% comments · Rust 包仓库 Go 3K SLoC // 0.0% comments · Rust 包仓库 Ruby 3K SLoC // 0.1% comments · Rust 包仓库 F# 3K SLoC // 0.0% comments · Rust 包仓库 Pascal 2.5K SLoC // 0.1% comments · Rust 包仓库 Rust 2K SLoC // 0.0% comments · Rust 包仓库 VB6 1.5K SLoC // 0.6% comments · Rust 包仓库 Haskell 1.5K SLoC // 0.2% comments · Rust 包仓库 C# 472 SLoC // 0.1% comments · Rust 包仓库 Visual Studio Solution 418 SLoC · Rust 包仓库 C++ 298 SLoC // 0.2% comments · Rust 包仓库 Shell 195 SLoC // 0.2% comments · Rust 包仓库 GNU Style Assembly 193 SLoC // 0.0% comments · Rust 包仓库 Batch 74 SLoC // 0.2% comments · Rust 包仓库 Cabal 38 SLoC // 0.1% comments · Rust 包仓库 Assembly 9 SLoC // 0.5% comments · Rust 包仓库 NuGet Config 4 SLoC · Rust 包仓库 Forge Config 2 SLoC · Rust 包仓库

包含 (ELF 可执行文件/库, 1KB) x86_self_modifying.elf

Unicorn仿真器的绑定。

示例使用


use unicorn::RegisterARM;
use unicorn::unicorn_const::{Arch, Mode, Permission, SECOND_SCALE};

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

    let mut unicorn = 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 as i32, 123).expect("failed write R0");
    emu.reg_write(RegisterARM::R5 as i32, 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 as i32), Ok(100));
    assert_eq!(emu.reg_read(RegisterARM::R5 as i32), Ok(1337));
}

依赖项