Skip to main content

Insn

Struct Insn 

Source
pub struct Insn<'a> { /* private fields */ }
Expand description

A decoded instruction at its address, with the bytes it was decoded from.

Its Display is its text, as the native decoder writes it by default (see the crate documentation).

Implementations§

Source§

impl<'a> Insn<'a>

Source

pub fn from_x86( instruction: Instruction, mode: Mode, bytes: &'a [u8], address: u64, ) -> Self

The x86 instruction instruction, which a decode in mode made from bytes at address, as decode would give it: for code that keeps native instructions and asks them again, without decoding twice (binbun’s C API). bytes past the instruction’s length are left out.

Source

pub fn from_aarch64( instruction: Instruction, bytes: &'a [u8], address: u64, ) -> Self

The AArch64 instruction instruction, decoded from bytes at address, as decode would give it; see Insn::from_x86.

Source

pub const fn arch(&self) -> Arch

The architecture it was decoded for.

Source

pub const fn address(&self) -> u64

Its address.

Source

pub const fn len(&self) -> usize

Its length in bytes: 1 to 15 on x86, 4 on AArch64.

Source

pub const fn bytes(&self) -> &'a [u8]

The bytes it was decoded from, borrowed from the buffer decoded (AArch64’s are the word, little-endian).

Source

pub fn mnemonic(&self) -> &'static str

The mnemonic its text writes, lower case: on x86 the word after any prefix words (movsb of rep movsb; call far), on AArch64 after alias selection, with its suffix (mov, b.eq). The native mnemonics, XED’s iclass and Arm’s encoding mnemonic, are the native instruction’s.

Source

pub fn flow(&self) -> Flow

What it does to the flow of control at its address.

Source

pub fn registers_read(&self) -> Registers

The registers it may read; see Registers.

Source

pub fn registers_written(&self) -> Registers

The registers it may write; see Registers.

Source

pub const fn as_x86(&self) -> Option<&Instruction>

The x86 decoder’s instruction, if it is one.

Source

pub const fn as_aarch64(&self) -> Option<&Instruction>

The AArch64 decoder’s instruction, if it is one.

Trait Implementations§

Source§

impl<'a> Clone for Insn<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Insn<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Insn<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for Insn<'a>

Source§

impl<'a> PartialEq for Insn<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Insn<'a>

Auto Trait Implementations§

§

impl<'a> Forget for Insn<'a>

§

impl<'a> Freeze for Insn<'a>

§

impl<'a> Move for Insn<'a>

§

impl<'a> RefUnwindSafe for Insn<'a>

§

impl<'a> Send for Insn<'a>

§

impl<'a> Sync for Insn<'a>

§

impl<'a> Unpin for Insn<'a>

§

impl<'a> UnsafeUnpin for Insn<'a>

§

impl<'a> UnwindSafe for Insn<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.