Thanks to visit codestin.com
Credit goes to github.com

Skip to content

tmfink/capstone-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

120 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

capstone-rs

Bindings to the capstone library disassembly framework.

There's an example in demo.rs, but as a sample:

extern crate capstone;

use capstone::prelude::*;

const CODE: &'static [u8] = b"\x55\x48\x8b\x05\xb8\x13\x00\x00";

fn example() -> CsResult<()> {
    let cs = Capstone::new()
        .x86()
        .mode(arch::x86::ArchMode::Mode64)
        .syntax(arch::x86::ArchSyntax::Att)
        .detail(true)
        .build()?;

    let insns = cs.disasm_all(CODE, 0x1000)?;
    println!("Got {} instructions", insns.len());
    for i in insns.iter() {
        println!("{}", i);
        println!("    read regs: {:?}", cs.read_registers(&i).unwrap());
        println!("    write regs: {:?}", cs.write_registers(&i).unwrap());
        println!("    insn groups: {:?}", cs.insn_groups(&i).unwrap());
    }
    Ok(())
}

fn main() {
    if let Err(err) = example() {
        println!("Error: {}", err);
    }
}

Produces:

Got 2 instructions
0x1000: pushq %rbp
    read regs: [44]
    write regs: [44]
    insn groups: [145]
0x1001: movq 0x13b8(%rip), %rax
    read regs: []
    write regs: []
    insn groups: []

Reporting Issues

Please open a Github issue

Demo

You can run:

cargo run --example=demo

To produce a short demonstration. More complex demos welcome!

Minimum Rust Version

capstone-rs requires Rust 1.20.0 or later.

Author

You may find a full list of contributors on Github.

License

Mit.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 98.6%
  • Other 1.4%