Giter Club home page Giter Club logo

binutils-rs's Introduction

binutils-rs

A Rust library that ease interacting with the binutils disassembly engine with a high-level API. Its main goal is to simplify disassembling raw buffers into instructions.

crates.io badge doc.rs badge

Usage

You need to add the following lines to your Cargo.toml:

[dependencies]
binutils = "0.1.1"

and make sure that your are using it in your code:

extern crate binutils;

Note: By default, all architectures supported by binutils will be built by cargo. The resulting library will be over 60MB. When size is an issue, the TARGETS environment variable can be set to only build specific architectures (i.e. TARGETS=arm-linux,mep) as defined in bfd/config.bfd.

Examples

Here is how to disassemble a buffer containing x86 instructions while being gentle with errors:

extern crate binutils;
use binutils::utils::disassemble_buffer;
use binutils::opcodes::DisassembleInfo;

// Prepare the disassembler
let mut info = disassemble_buffer("i386", &[0xc3, 0x90, 0x66, 0x90], 0x2800)
    .unwrap_or(DisassembleInfo::empty());

// Iterate over the instructions
loop {
    match info.disassemble()
        .ok_or(2807)
        .map(|i| Some(i.unwrap()))
        .unwrap_or(None)
    {
        Some(instruction) => println!("{}", instruction),
        None => break,
    }
}

Other examples are located in the examples/ directory, and be used with cargo run --example.

Resources

Examples in C and archived documentations are available in the resources/ directory.

Roadmap

  • add Travis support: test and rustfmt
  • code coverage with tarpaulin
  • write more tests
  • investigate stripping libraries
  • convert check_null_pointer() to a macro to add file and line numbers to the Error
  • fuzz the disassembler
  • generate mach.rs with build.rs
  • generate documentation from comments
  • use the error_chain crate
  • investigate info->stop_vma
  • rewrite copy_buffer in Rust

binutils-rs's People

Contributors

guedou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.