Struct bddisasm::operand::OperandsLookup
source · pub struct OperandsLookup<'a> { /* private fields */ }
Expand description
Operands lookup table.
This can be useful when needing to work with a specific operand without needing to iterate over the operands returned by operands(), and without needing to rely on the order of the operands.
§Examples
use bddisasm::{DecodedInstruction, DecodeMode, OperandsLookup, OpRegType};
// `PUSH rbx`
let ins = DecodedInstruction::decode(b"\x53", DecodeMode::Bits64).unwrap();
let operands = ins.operand_lookup();
// The first destination is the stack.
let first_destination = operands.dest(0);
assert!(first_destination.is_some());
let first_destination = first_destination.unwrap();
// And it is the same as the first memory operand.
let first_mem = operands.mem(0);
assert!(first_mem.is_some());
let first_mem = first_mem.unwrap();
assert_eq!(first_destination, first_mem);
// And the same as the stack operand.
let stack = operands.stack();
assert!(stack.is_some());
let stack = stack.unwrap();
assert_eq!(first_destination, stack);
assert!(first_destination.is_default);
assert!(first_destination.info.is_mem());
assert!(first_destination.info.as_mem().unwrap().is_stack);
// Although the source operand is the RBX register, it is not one of the default operands.
let rbx = operands.rbx();
assert!(rbx.is_none());
// There is only one destination operand.
let second_destination = operands.dest(1);
assert!(second_destination.is_none());
// The first source is RBX.
let first_source = operands.src(0);
assert!(first_source.is_some());
let first_source = first_source.unwrap();
assert_eq!(first_source.is_default, false);
assert!(first_source.info.is_reg());
let first_source = first_source.info.as_reg().unwrap();
assert_eq!(first_source.kind, OpRegType::Gpr);
assert_eq!(first_source.index, 3);
// There is only one source operand.
let second_source = operands.src(1);
assert!(second_source.is_none());
// There is no other memory operand.
let second_mem = operands.mem(1);
assert!(second_mem.is_none());
// The FLAGS register is not accessed.
let flags = operands.flags();
assert!(flags.is_none());
Implementations§
source§impl<'a> OperandsLookup<'a>
impl<'a> OperandsLookup<'a>
sourcepub fn dest(&self, index: usize) -> Option<Operand>
pub fn dest(&self, index: usize) -> Option<Operand>
Get one of the destination operands.
Most instructions have just one destination operand, but some will have two.
§Arguments
index
- The index of the destination operand. First destination operand has index 0, the second one has index 1, etc.
§Returns
- Some(Operand) if the requested destination operand exists.
None
if the requested destination operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn src(&self, index: usize) -> Option<Operand>
pub fn src(&self, index: usize) -> Option<Operand>
Get one of the source operands.
Most instructions have just one souce operand, but some can have up to 4.
§Arguments
index
- The index of the source operand. First source operand has index 0, the second one has index 1, etc.
§Returns
- Some(Operand) if the requested source operand exists.
None
if the requested source operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn mem(&self, index: usize) -> Option<Operand>
pub fn mem(&self, index: usize) -> Option<Operand>
Get one of the memory operands.
Most instructions have just one memory operand, but some will have two.
§Arguments
index
- The index of the memory operand. First memory operand has index 0, the second one has index 1, etc.
§Returns
- Some(Operand) if the requested memory operand exists.
None
if the requested memory operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn stack(&self) -> Option<Operand>
pub fn stack(&self) -> Option<Operand>
Get the stack operand.
§Returns
- Some(Operand) if a stack operand exists.
None
if a stack operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn flags(&self) -> Option<Operand>
pub fn flags(&self) -> Option<Operand>
Get the default flags register operand.
§Returns
- Some(Operand) if a flags register operand exists.
None
if a flags register operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn rip(&self) -> Option<Operand>
pub fn rip(&self) -> Option<Operand>
Get the default RIP operand.
§Returns
- Some(Operand) if a RIP operand exists.
None
if a RIP operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn cs(&self) -> Option<Operand>
pub fn cs(&self) -> Option<Operand>
Get the implicit CS operand.
§Returns
- Some(Operand) if a implicit CS operand exists.
None
if a implicit CS operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn ss(&self) -> Option<Operand>
pub fn ss(&self) -> Option<Operand>
Get the implicit SS operand.
§Returns
- Some(Operand) if a implicit SS operand exists.
None
if a implicit SS operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn rax(&self) -> Option<Operand>
pub fn rax(&self) -> Option<Operand>
Get the implicit RAX operand.
§Returns
- Some(Operand) if a implicit RAX operand exists.
None
if a implicit RAX operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn rcx(&self) -> Option<Operand>
pub fn rcx(&self) -> Option<Operand>
Get the implicit RCX operand.
§Returns
- Some(Operand) if a implicit RCX operand exists.
None
if a implicit RCX operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn rdx(&self) -> Option<Operand>
pub fn rdx(&self) -> Option<Operand>
Get the implicit RDX operand.
§Returns
- Some(Operand) if a implicit RDX operand exists.
None
if a implicit RDX operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn rbx(&self) -> Option<Operand>
pub fn rbx(&self) -> Option<Operand>
Get the implicit RBX operand.
§Returns
- Some(Operand) if a implicit RBX operand exists.
None
if a implicit RBX operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn rsp(&self) -> Option<Operand>
pub fn rsp(&self) -> Option<Operand>
Get the implicit RSP operand.
§Returns
- Some(Operand) if a implicit RSP operand exists.
None
if a implicit RSP operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn rbp(&self) -> Option<Operand>
pub fn rbp(&self) -> Option<Operand>
Get the implicit RBP operand.
§Returns
- Some(Operand) if a implicit RBP operand exists.
None
if a implicit RBP operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn rsi(&self) -> Option<Operand>
pub fn rsi(&self) -> Option<Operand>
Get the implicit RSI operand.
§Returns
- Some(Operand) if a implicit RSI operand exists.
None
if a implicit RSI operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
sourcepub fn rdi(&self) -> Option<Operand>
pub fn rdi(&self) -> Option<Operand>
Get the implicit RDI operand.
§Returns
- Some(Operand) if a implicit RDI operand exists.
None
if a implicit RDI operand does not exist.
§Panics
This function will panic if the result of the C library is unrecognized. This can not happen under normal circumstances.
Trait Implementations§
source§impl<'a> Clone for OperandsLookup<'a>
impl<'a> Clone for OperandsLookup<'a>
source§fn clone(&self) -> OperandsLookup<'a>
fn clone(&self) -> OperandsLookup<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more