#intel #x86 #x86-64 #xed

sys xed-sys

Rust FFI bindings for Intel XED

7 unstable releases

0.4.0 Jun 26, 2021
0.3.0 May 23, 2020
0.2.4 Nov 1, 2019
0.2.3 Jul 6, 2019
0.1.1 Oct 8, 2017

#556 in Encoding

Download history 1/week @ 2022-01-24 3/week @ 2022-02-07 1/week @ 2022-02-14 10/week @ 2022-02-21 3/week @ 2022-02-28 3/week @ 2022-03-07 27/week @ 2022-03-14 29/week @ 2022-03-21 1/week @ 2022-03-28 2/week @ 2022-04-18 52/week @ 2022-04-25 73/week @ 2022-05-02 10/week @ 2022-05-09

137 downloads per month

Apache-2.0

2.5MB
54K SLoC

Python 33K SLoC // 0.2% comments C 18K SLoC // 0.1% comments Rust 2.5K SLoC // 0.0% comments C++ 846 SLoC // 0.1% comments Assembly 28 SLoC // 0.1% comments

Build Status Build status Crates.io

xed-sys

Rust FFI bindings for Intel XED.

/// Similar to `examples/xed-min.c` from official Intel XED repository.
use xed_sys::*;

fn main() {
    unsafe {
        let (mmode, stack_addr_width) = (XED_MACHINE_MODE_LEGACY_32, XED_ADDRESS_WIDTH_32b);

        xed_tables_init();

        let itext: [u8; 15] = [
            0xf, 0x85, 0x99, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        ];

        for bytes in 0..16 {
            let mut xedd = ::std::mem::MaybeUninit::<xed_decoded_inst_t>::uninit();
            xed_decoded_inst_zero(xedd.as_mut_ptr());
            xed_decoded_inst_set_mode(xedd.as_mut_ptr(), mmode, stack_addr_width);

            let xed_error: xed_error_enum_t = xed_decode(xedd.as_mut_ptr(), itext.as_ptr(), bytes);
            let desc = std::ffi::CStr::from_ptr(xed_error_enum_t2str(xed_error)).to_string_lossy();
            println!("bytes={} error={}", bytes, desc);
        }
    }
}

Building

In order to build this crate, you need:

Examples

You can find usage examples in the examples/ directory.

These examples are meant to be executed with cargo. For instance, to run the example named xed_min:

# cd to the crate's root directory
cargo run --example xed_min

No runtime deps