GithubHelp home page GithubHelp logo

quadrupleslap-forks-things / unicorn-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unicorn-rs/unicorn-rs

0.0 2.0 0.0 279 KB

Rust bindings for the unicorn CPU emulator

License: GNU General Public License v2.0

Rust 99.52% Batchfile 0.48%

unicorn-rs's Introduction

unicorn-rs

Cargo Documentation

Rust bindings for the unicorn CPU emulator.

extern crate unicorn;

use unicorn::{Cpu, CpuX86};

fn main() {
    let x86_code32: Vec<u8> = vec![0x41, 0x4a]; // INC ecx; DEC edx

    let emu = CpuX86::new(unicorn::Mode::MODE_32).expect("failed to instantiate emulator");
    let _ = emu.mem_map(0x1000, 0x4000, unicorn::PROT_ALL);
    let _ = emu.mem_write(0x1000, &x86_code32);
    let _ = emu.reg_write_i32(unicorn::RegisterX86::ECX, -10);
    let _ = emu.reg_write_i32(unicorn::RegisterX86::EDX, -50);

    let _ = emu.emu_start(0x1000, (0x1000 + x86_code32.len()) as u64, 10 * unicorn::SECOND_SCALE, 1000);
    assert_eq!(emu.reg_read_i32(unicorn::RegisterX86::ECX), Ok((-9)));
    assert_eq!(emu.reg_read_i32(unicorn::RegisterX86::EDX), Ok((-51)));
}

Installation

This project has been tested on Linux, OS X and Windows. The bindings are built for version 1.0 of unicorn.

This package attempts to build unicorn if it is not already installed on the system. To build unicorn on Linux and OS X, the following tools are needed : gcc, make, git, python 2.7. Visual Studio is needed on Windows.

To use unicorn-rs, simply add it as dependency to the Cargo.toml of your program.

[dependencies]
unicorn = "0.7.0"

Changelog

0.7.0

Windows is now supported (thanks to kichristensen).

0.6.0

We now check if unicorn is installed on the system via pkg-tool and use that version if available. Otherwise unicorn is compiled when building the package.

0.4.0

unicorn is now compiled as part of the build process of unicorn-rs.

0.3.0

The handling of callbacks has been modified, callbacks should be implemented using closures. See the tests for examples.

  • added support for interrupt, in/out and sysenter callbacks

Contributing

Contributions to this project are super appreciated. Pull requests, bug reports, code review, tests, documentation or feedback on your use of the bindings, nothing is too small. Don't hesitate to open an issue if you have questions.

Contributors:

  • Sébastien Duquette (@ekse)
  • Israel Hallé (@isra17) for redesigning the callbacks API
  • Richo Healey (@richo)
  • Kim Christensen (@kichristensen) for the Windows support
  • petevine for reviewing the project and adding tests
  • jschievink for his help with the API design
  • m4b for the build.rs script

unicorn-rs's People

Contributors

ekse avatar isra17 avatar felberj avatar kichristensen avatar mthiesen avatar quadrupleslap avatar richo avatar gunyarakun avatar m4b avatar

Watchers

James Cloos 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.