#x86 #intel #xed

sys xed-sys

Rust FFI bindings for Intel XED

10 releases (5 breaking)

0.6.0+xed-2024.05.20 Jun 1, 2024
0.5.1+xed-2023.12.19 Jun 1, 2024
0.5.0+xed-2023.12.19 Jan 17, 2024
0.4.0 Jun 26, 2021
0.1.1 Oct 8, 2017

#503 in Encoding

Download history 19/week @ 2024-07-01 91/week @ 2024-07-29 16/week @ 2024-08-26 21/week @ 2024-09-02 6/week @ 2024-09-09 7/week @ 2024-09-16 84/week @ 2024-09-23 37/week @ 2024-09-30 8/week @ 2024-10-07 20/week @ 2024-10-14

149 downloads per month
Used in 2 crates (via rusty-xed)

Apache-2.0

4MB
81K SLoC

Python 35K SLoC // 0.2% comments Rust 26K SLoC // 0.0% comments C 19K SLoC // 0.1% comments C++ 847 SLoC // 0.1% comments Forge Config 467 SLoC // 0.8% comments Shell 29 SLoC // 0.2% comments Assembly 28 SLoC // 0.1% comments

Build Status docs.rs 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:

If you have the bindgen feature enabled then you will also 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