[][src]Struct iced_x86::InstructionInfoFactory

pub struct InstructionInfoFactory { /* fields omitted */ }

Creates InstructionInfos.

If you don't need to know register and memory usage, it's faster to call Instruction and Code methods such as Instruction::flow_control() instead of getting that info from this struct.

Implementations

impl InstructionInfoFactory[src]

#[must_use]pub fn new() -> Self[src]

Creates a new instance.

If you don't need to know register and memory usage, it's faster to call Instruction and Code methods such as Instruction::flow_control() instead of getting that info from this struct.

Examples

use iced_x86::*;

// add [rdi+r12*8-5AA5EDCCh],esi
let bytes = b"\x42\x01\xB4\xE7\x34\x12\x5A\xA5";
let mut decoder = Decoder::new(64, bytes, DecoderOptions::NONE);

// This allocates two vectors but they get re-used every time you call info() and info_options().
let mut info_factory = InstructionInfoFactory::new();

for instr in &mut decoder {
    // There's also info_options() if you only need reg usage or only mem usage.
    // info() returns both.
    let info = info_factory.info(&instr);
    for mem_info in info.used_memory().iter() {
        println!("{:?}", mem_info);
    }
    for reg_info in info.used_registers().iter() {
        println!("{:?}", reg_info);
    }
}

#[must_use]pub fn info(&mut self, instruction: &Instruction) -> &InstructionInfo[src]

Creates a new InstructionInfo, see also info_options() if you only need register usage but not memory usage or vice versa.

If you don't need to know register and memory usage, it's faster to call Instruction and Code methods such as Instruction::flow_control() instead of getting that info from this struct.

Arguments

  • instruction: The instruction that should be analyzed

Examples

use iced_x86::*;

// add [rdi+r12*8-5AA5EDCCh],esi
let bytes = b"\x42\x01\xB4\xE7\x34\x12\x5A\xA5";
let mut decoder = Decoder::new(64, bytes, DecoderOptions::NONE);
let mut info_factory = InstructionInfoFactory::new();

let instr = decoder.decode();
let info = info_factory.info(&instr);

assert_eq!(1, info.used_memory().len());
let mem = info.used_memory()[0];
assert_eq!(Register::DS, mem.segment());
assert_eq!(Register::RDI, mem.base());
assert_eq!(Register::R12, mem.index());
assert_eq!(8, mem.scale());
assert_eq!(0xFFFFFFFFA55A1234, mem.displacement());
assert_eq!(MemorySize::UInt32, mem.memory_size());
assert_eq!(OpAccess::ReadWrite, mem.access());

let regs = info.used_registers();
assert_eq!(3, regs.len());
assert_eq!(Register::RDI, regs[0].register());
assert_eq!(OpAccess::Read, regs[0].access());
assert_eq!(Register::R12, regs[1].register());
assert_eq!(OpAccess::Read, regs[1].access());
assert_eq!(Register::ESI, regs[2].register());
assert_eq!(OpAccess::Read, regs[2].access());

#[must_use]pub fn info_options(
    &mut self,
    instruction: &Instruction,
    options: u32
) -> &InstructionInfo
[src]

Creates a new InstructionInfo, see also info().

If you don't need to know register and memory usage, it's faster to call Instruction and Code methods such as Instruction::flow_control() instead of getting that info from this struct.

Arguments

Trait Implementations

impl Debug for InstructionInfoFactory[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.