Struct iced_x86::InstructionInfoFactory[][src]

pub struct InstructionInfoFactory { /* fields omitted */ }
Expand description

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

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);
    }
}

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

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

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.