3 releases

new 0.9.4-1 May 4, 2025
0.9.3 May 1, 2025
0.9.3-1 May 4, 2025
0.9.2 Apr 30, 2025

#20 in #reverse-engineering

Download history 222/week @ 2025-04-27

222 downloads per month
Used in hex-patch

GPL-2.0 license

22MB
309K SLoC

Bitbake 236K SLoC // 0.0% comments C++ 67K SLoC // 0.1% comments C 3.5K SLoC // 0.1% comments Python 2K SLoC // 0.3% comments Rust 322 SLoC Shell 274 SLoC // 0.2% comments Batch 53 SLoC // 0.2% comments

Hexpatch Keystone

Rust bindings for the keystone engine. These bindings are for a custom version of keystone

Sample

extern crate keystone;
use keystone::*;

fn main() {
    let engine = Keystone::new(Arch::X86, Mode::MODE_32)
        .expect("Could not initialize Keystone engine");

    engine.option(OptionType::SYNTAX, OptionValue::SYNTAX_NASM)
        .expect("Could not set option to nasm syntax");

    let result = engine.asm("mov ah, 0x80".to_string(), 0)
        .expect("Could not assemble");

    println!("ASM result: {}", result);

    if let Err(err) = engine.asm("INVALID".to_string(), 0) {
        println!("Error: {}", err);
    }
}

Installation

Add a dependency line into Cargo.toml.

[dependencies]
keystone = "0.9.2"

This package attempts to build keystone. That requires cmake and c/c++ compiler.

If you want to use keystone already installed in the system, specify use_system_keystone feature on Cargo.toml.

[dependencies.keystone]
version = "0.9.2"
default-features = false
features = ["use_system_keystone"]

Testing

cargo test

Contributors

  • Remco Verhoef (@remco_verhoef)
  • Tasuku SUENAGA a.k.a. gunyarakun (@tasukuchan)

Special thanks to:

  • Sébastien Duquette (@ekse) for his unicorn-rs binding

Dependencies