Crate capstone3 [] [src]

Bindings to the capstone library disassembly framework.

extern crate capstone;
const CODE: &'static [u8] = b"\x55\x48\x8b\x05\xb8\x13\x00\x00";
fn main() {
    match capstone::Capstone::new(capstone::Arch::X86) {
        Ok(cs) => {
            match cs.disassemble(CODE, 0x1000) {
                Ok(insns) => {
                    println!("Got {} instructions", insns.len());

                    for i in insns.iter() {
                        println!("{}", i);
                    }
                },
                Err(err) => {
                    println!("Error: {}", err)
                }
            }
        },
        Err(err) => {
            println!("Error: {}", err)
        }
    }
}

Produces:

Got 2 instructions
0x1000: push rbp
0x1001: mov rax, qword ptr [rip + 0x13b8]

NOTE if you want to compile for a different target, you should use the build_capstone feature.

Modules

error
instruction

Structs

Capstone

An instance of the capstone disassembler

Enums

Arch

Architectures for the disassembler

Mode

Disassembler modes