Skip to content

Commit

Permalink
add get_version function
Browse files Browse the repository at this point in the history
  • Loading branch information
tathanhdinh committed Aug 30, 2018
1 parent ea64a90 commit d0cce2b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,22 @@ pub use mnemonic::*;
pub use register::*;
pub use status::*;
pub use utils::*;

/// Returns the version of the zydis C library as a quadruple `(major, minor, patch, build)`
///
/// # Examples
/// ```
/// use zydis;
/// let (major, minor, patch, build) = zydis::get_version();
/// println!("Zydis version: {}.{}.{}.{}", major, minor, patch, build);
/// ```
pub fn get_version() -> (u16, u16, u16, u16) {
let combined_ver = unsafe {
gen::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)
}

0 comments on commit d0cce2b

Please sign in to comment.