Example Usage
use zydis::*;
#[rustfmt::skip]
static CODE: &'static [u8] = &[
0x51, 0x8D, 0x45, 0xFF, 0x50, 0xFF, 0x75, 0x0C, 0xFF, 0x75, 0x08,
0xFF, 0x15, 0xA0, 0xA5, 0x48, 0x76, 0x85, 0xC0, 0x0F, 0x88, 0xFC,
0xDA, 0x02, 0x00,
];
fn main() -> zydis::Result {
let fmt = Formatter::intel();
let dec = Decoder::new64();
// 0 is the address for our code.
for insn_info in dec.decode_all::<VisibleOperands>(CODE, 0) {
let (ip, _raw_bytes, insn) = insn_info?;
// We use Some(ip) here since we want absolute addressing based on the given
// instruction pointer. If we wanted relative addressing, we'd use `None` instead.
println!("0x{:016X} {}", ip, fmt.format(Some(ip), &insn)?);
}
Ok(())
}