1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// The doc-test in README.md needs formatter
#![cfg_attr(feature = "formatter", doc = include_str!("../README.md"))]
#![cfg_attr(not(feature = "std"), no_std)]

//! ## Navigation
//!
//! - [Decode instructions and process them programmatically][`Decoder`]
//! - [Format instructions to human-readable text][`Formatter`]
//! - [Decode, change and re-encode instructions][`EncoderRequest`]
//! - [Encode new instructions from scratch][`EncoderRequest`]

#[cfg(feature = "alloc")]
extern crate alloc;

#[macro_use]
mod status;
mod decoder;
#[cfg(feature = "encoder")]
mod encoder;
mod enums;
pub mod ffi;
#[cfg(feature = "formatter")]
mod formatter;

pub use decoder::*;
#[cfg(feature = "encoder")]
pub use encoder::*;
pub use enums::*;
#[cfg(feature = "formatter")]
pub use formatter::*;
pub use status::*;

/// Returns the version of the zydis C library as a quadruple
/// `(major, minor, patch, build)`.
///
/// # Examples
///
/// ```
/// let (major, minor, patch, build) = zydis::get_version();
/// println!("Zydis version: {}.{}.{}.{}", major, minor, patch, build);
/// assert_eq!(major, 4);
/// ```
pub fn version() -> (u16, u16, u16, u16) {
    let combined_ver = unsafe { ffi::ZydisGetVersion() };
    let major = ((combined_ver << 0) >> 48) as u16;
    let minor = ((combined_ver << 16) >> 48) as u16;
    let patch = ((combined_ver << 32) >> 48) as u16;
    let build = ((combined_ver << 48) >> 48) as u16;
    (major, minor, patch, build)
}

#[doc(hidden)]
#[deprecated(since = "4.0.0", note = "use `version()` instead")]
pub fn get_version() -> (u16, u16, u16, u16) {
    version()
}