https://github.com/rust-xed/xed-sys
Rust FFI bindings for Intel XED
https://github.com/rust-xed/xed-sys
decoder encoder encoder-decoder intel intel-xed rust rust-ffi rust-ffi-bindings rust-lang rust-language x86 x86-64
Last synced: 11 months ago
JSON representation
Rust FFI bindings for Intel XED
- Host: GitHub
- URL: https://github.com/rust-xed/xed-sys
- Owner: rust-xed
- License: apache-2.0
- Created: 2018-11-13T23:55:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-12-20T18:38:10.000Z (about 1 year ago)
- Last Synced: 2025-04-02T02:24:55.160Z (11 months ago)
- Topics: decoder, encoder, encoder-decoder, intel, intel-xed, rust, rust-ffi, rust-ffi-bindings, rust-lang, rust-language, x86, x86-64
- Language: Rust
- Homepage:
- Size: 486 KB
- Stars: 21
- Watchers: 4
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/rust-xed/xed-sys/actions/workflows/build-and-test.yml)
[](https://docs.rs/xed-sys)
[](https://crates.io/crates/xed-sys)
# xed-sys
Rust FFI bindings for [Intel XED](https://intelxed.github.io/).
```rust
/// 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::::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:
* Python version 3.8 or later ([to build XED](https://intelxed.github.io/build-manual/)).
* A C compiler.
If you have the `bindgen` feature enabled then you will also need:
* clang [to run bindgen](https://rust-lang.github.io/rust-bindgen/requirements.html#requirements).
## 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
```