3.1.4. instruction – Instruction module

This module exposes a number of tools for interacting with an instruction defined within the database. There are three types of tools within this module and each can be distinguished by their prefixes which can be used to decode the operands for an instruction. At the present time, only the Intel, AArch32/AArch64 (ARM), and the MIPS32/MIPS64 architectures are currently supported.

Although IDA internally uses the idaapi.insn_t and idaapi.op_t to represent an instruction and its operands, this module’s base argument type is typically an address or an operand index. When dealing with an instruction’s operands, the ops_ prefix represents all of the instructions operands and typically will take only an address. Likewise when dealing with a single operand, the op_ prefix is used and will take an address and the operand index.

To request the actual IDA types (idaapi.insn_t and idaapi.op_t) there are two tools that are provided. The instruction.at tool will take an address and return an idaapi.insn_t. To get an operand type (idaapi.op_t), a user can use instruction.operand. This will take an address and an operand index and return the desired type.

Some globals are also defined for the given architecture which can be used to query or access the registers that are currently available. Once IDA has determined the architecture for the database the register_t class is instantiated for each available register. This object allows one to reference any register that is defined for the architecture.

Another object that is created is the architecture_t object. Searching for a register can be done by index and size or simply by its name. This object also allows one to promote or demote a register between its various sizes. This allows one to navigate between the 8-bit, 16-bit, 32-bit, or 64-bit versions of a register available in the architecture.

3.1.4.1. Function list

The functions that are available in this module use multicased functions and aliases. For more information on this, please see Aliases and Multicased functions.

instruction.at()

Returns the idaapi.insn_t instance at the current address.

instruction.at(ea)

Returns the idaapi.insn_t instance at the address ea.

Parameters:ea (int or long) – the address of an instruction
instruction.mnemonic()

Returns the mnemonic of the instruction at the current address.

Aliases: instruction.mnem

instruction.mnemonic(ea)

Returns the mnemonic of the instruction at the address ea.

Aliases: instruction.mnem

Parameters:ea (int or long) – the address of an instruction
instruction.op(opnum)

Decodes the operand opnum for the current instruction.

Aliases: instruction.op_value, instruction.op_decode

Parameters:opnum (int or long) – the operand number of the current instruction to decode
instruction.op(reference)

Decodes the operand pointed to by reference.

Aliases: instruction.op_value, instruction.op_decode

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand to decode
instruction.op(ea, opnum)

Decodes the operand opnum for the instruction at the address ea.

Aliases: instruction.op_value, instruction.op_decode

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction to decode
instruction.op_binary(opnum)

Set the type for operand opnum at the current instruction to binary and return it.

Aliases: instruction.op_bin

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_binary(reference)

Set the type for the operand pointed to by reference to binary and return it.

Aliases: instruction.op_bin

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_binary(ea, opnum)

Set the type for operand opnum belonging to the instruction at ea to binary and return it.

Aliases: instruction.op_bin

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_bits(opnum)

Returns the size (in bits) for the operand opnum belonging to the current instruction.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_bits(reference)

Returns the size (in bits) for the operand pointed to by reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_bits(ea, opnum)

Returns the size (in bits) for the operand opnum belonging to the instruction at the address ea.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_character(opnum)

Set the type for operand opnum at the current instruction to a character and return it.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_character(reference)

Set the type for the operand pointed to by reference to a character and return it.

Aliases: instruction.op_char, instruction.op_chr

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_character(ea, opnum)

Set the type for operand opnum belonging to the instruction at ea to a character and return it.

Aliases: instruction.op_char, instruction.op_chr

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_decimal(opnum)

Set the type for operand opnum at the current instruction to decimal and return it.

Aliases: instruction.op_dec

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_decimal(reference)

Set the type for the operand pointed to by reference to decimal and return it.

Aliases: instruction.op_dec

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_decimal(ea, opnum)

Set the type for operand opnum belonging to the instruction at ea to decimal and return it.

Aliases: instruction.op_dec

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_decoder(opnum)

Returns the name of the decoder that will be used when decoding the operand opnum belonging to the current instruction.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_decoder(reference)

Returns the name of the decoder that will be used when decoding the operand pointed to by reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_decoder(ea, opnum)

Returns the name of the decoder that will be used when decoding the operand opnum belonging to the instruction at the address ea.

The string that is returned is dependent on the processor module used by the database.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_enumeration(opnum)

Return the enumeration member id for the operand opnum belonging to the current instruction.

Aliases: instruction.op_enum

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_enumeration(reference)

Return the enumeration member id for the operand pointed to by reference.

Aliases: instruction.op_enum

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_enumeration(ea, opnum)

Return the enumeration member id for the operand opnum belonging to the instruction at ea.

Aliases: instruction.op_enum

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_enumeration(opnum, name)

Apply the enumeration name to operand opnum for the current instruction.

Aliases: instruction.op_enum

Parameters:
  • opnum (int or long) – the operand number of the current instruction
  • name (str) – the name of the enumeration to apply
instruction.op_enumeration(reference, name_or_id)

Apply the enumeration name_or_id to the operand pointed to by reference.

Aliases: instruction.op_enum

Parameters:
  • reference (interface.opref_t) – the opref_t of the instruction and operand
  • name_or_id – the enumeration name or identifier to apply
instruction.op_enumeration(ea, opnum, name)

Apply the enumeration name to operand opnum for the instruction at ea.

Aliases: instruction.op_enum

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • name (str) – the name of the enumeration to apply
instruction.op_enumeration(ea, opnum, id)

Apply the enumeration id to operand opnum of the instruction at ea.

Aliases: instruction.op_enum

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • id (int or long or tuple or list) – the identifer of an enumeration to apply
instruction.op_float(opnum)

Set the type for operand opnum at the current instruction to floating-point and return it.

Aliases: instruction.op_flt

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_float(reference)

Set the type for the operand pointed to by reference to floating-point and return it.

Aliases: instruction.op_flt

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_float(ea, opnum)

Set the type for operand opnum belonging to the instruction at ea to floating-point and return it.

Aliases: instruction.op_flt

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_hexadecimal(opnum)

Set the type for operand opnum at the current instruction to hexadecimal and return it.

Aliases: instruction.op_hex

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_hexadecimal(reference)

Set the type for the operand pointed to by reference to hexadecimal and return it.

Aliases: instruction.op_hex

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_hexadecimal(ea, opnum)

Set the type for operand opnum belonging to the instruction at ea to hexadecimal and return it.

Aliases: instruction.op_hex

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_modified(opnum)

Return whether the operand opnum belonging to the current instruction is being modified (written to).

Aliases: instruction.op_write, instruction.op_written

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_modified(reference)

Return whether the operand pointed to by reference is being modified (written to).

Aliases: instruction.op_write, instruction.op_written

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_modified(ea, opnum)

Return whether the operand opnum belonging to the instruction at the address ea is being modified (written to).

Aliases: instruction.op_write, instruction.op_written

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_number(opnum)

Set the type for operand opnum at the current instruction to a number and return it.

Aliases: instruction.op_num

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_number(reference)

Set the type for the operand pointed to by reference to a number and return it.

Aliases: instruction.op_num

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_number(ea, opnum)

Set the type for operand opnum belonging to the instruction at ea to a number and return it.

Aliases: instruction.op_num

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_octal(opnum)

Set the type for operand opnum at the current instruction to octal and return it.

Aliases: instruction.op_oct

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_octal(reference)

Set the type for the operand pointed to by reference to octal and return it.

Aliases: instruction.op_oct

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_octal(ea, opnum)

Set the type for operand opnum belonging to the instruction at ea to octal and return it.

Aliases: instruction.op_oct

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_read(opnum)

Return whether the operand opnum belonging to the current instruction is only being read from.

Aliases: instruction.op_used

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_read(reference)

Return whether the operand pointed to by reference is only being read from.

Aliases: instruction.op_used

Parameters:reference (interface.opref_t) –
instruction.op_read(ea, opnum)

Return whether the operand opnum belonging to the instruction at the address ea is only being read from.

Aliases: instruction.op_used

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_reference(opnum)

Return the address being referenced by the operand opnum belonging to the instruction at the current address.

Parameters:opnum (int or long) –
instruction.op_reference(reference)

Return the address being referenced by the operand pointed to by reference.

Parameters:reference (interface.opref_t) –
instruction.op_reference(ea, opnum)

Return the address being referenced by the operand opnum belonging to the instruction at the address ea.

Parameters:
  • ea (int or long) –
  • opnum (int or long) –
instruction.op_refinfo(opnum)

Return the idaapi.refinfo_t for the operand opnum belonging to the instruction at the current address.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_refinfo(reference)

Return the idaapi.refinfo_t for the operand pointed to by reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand to fetch the idaapi.refinfo_t from
instruction.op_refinfo(ea, opnum)

Return the idaapi.refinfo_t for the operand opnum belonging to the instruction at the address ea.

Parameters:
  • ea (int or long) – the address of an instruction to fetch the idaapi.refinfo_t from
  • opnum (int or long) – the operand number of the instruction
instruction.op_refs(opnum)

Returns the (address, opnum, type) of all the instructions that reference the operand opnum for the current instruction.

Aliases: instruction.op_ref

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_refs(reference)

Returns the (address, opnum, type) of all the instructions that reference the operand pointed to by reference.

Aliases: instruction.op_ref

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand to return references for
instruction.op_refs(ea, opnum)

Returns the (address, opnum, type) of all the instructions that reference the operand opnum for the instruction at ea.

Aliases: instruction.op_ref

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_repr(opnum)

Returns the representation for the operand opnum belonging to the instruction at the current address.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_repr(reference)

Returns the representation for the operand pointed to by reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_repr(ea, opnum)

Returns the representation for the operand opnum belonging to the instruction at the address ea.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_segment(opnum)

Returns the segment register used by the operand opnum for the instruction at the current address.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_segment(reference)

Returns the segment register used by the operand pointed to by reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_segment(ea, opnum)

Returns the segment register used by the operand opnum for the instruction at the address ea.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_size(opnum)

Returns the size for the operand opnum belonging to the current instruction.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_size(reference)

Returns the size for the operand pointed to by reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_size(ea, opnum)

Returns the size for the operand opnum belonging to the instruction at the address ea.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_stackvar(opnum)

Set the type for operand opnum at the current instruction to a stack variable and return it.

Aliases: instruction.op_stack, instruction.op_stkvar

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_stackvar(reference)

Set the type for the operand pointed to by reference to a stack variable and return it.

Aliases: instruction.op_stack, instruction.op_stkvar

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_stackvar(ea, opnum)

Set the type for operand opnum belonging to the instruction at ea to a stack variable and return it.

Aliases: instruction.op_stack, instruction.op_stkvar

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_state(opnum)

Returns the modification state for the operand opnum belonging to the current instruction.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_state(reference)

Returns the modification state for the operand pointed to by reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_state(ea, opnum)

Returns the modification state for the operand opnum belonging to the instruction at the address ea.

The returned state is a string that can be “r”, “w”, or “rw” depending on whether the operand is being read from, written to, or modified (both).

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_string(opnum)

Return the string type of operand opnum for the current instruction.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_string(reference)

Return the string type (idaapi.STRTYPE_) of the operand pointed to by reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_string(ea, opnum)

Return the string type (idaapi.STRTYPE_) of operand opnum for the instruction at ea.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_string(reference, strtype)

Set the string type used by operand pointed to by reference to strtype.

Parameters:
  • reference (interface.opref_t) – the opref_t of the instruction and operand
  • strtype (int or long) – an IDA string type to apply to the operand
instruction.op_string(ea, opnum, strtype)

Set the string type used by operand opnum for the instruction at ea to strtype.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • strtype (int or long) – an IDA string type to apply to the operand
instruction.op_structure(opnum)

Return the structure and members for operand opnum at the current instruction.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_structure(reference)

Return the structure and members for the operand pointed to by reference.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_structure(ea, opnum)

Return the structure and members for the operand opnum at the instruction ea.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_structure(opnum, structure, *path)

Apply the specified structure along with any members in path to the instruction operand opnum at the current address.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • opnum (int or long) – the operand number of the current instruction
  • structure (structure_t or idaapi.struc_t or str) – the structure_t to apply
  • *path – any structure members, names, or integers that is used to specify the path to apply to the operand
instruction.op_structure(opnum, member, *path)

Apply the specified member along with any members in path to the instruction operand opnum at the current address.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • opnum (int or long) – the operand number of the current instruction
  • member (member_t or idaapi.member_t) – the member_t to apply
  • *path – any structure members, names, or integers that is used to specify the path to apply to the operand
instruction.op_structure(ea, opnum, structure, *path)

Apply the specified structure along with the members in path to the instruction operand opnum at the address ea.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • structure (structure_t or idaapi.struc_t or str) – the structure_t to apply
  • *path – any structure members, names, or integers that is used to specify the path to apply to the operand
instruction.op_structure(ea, opnum, member, *path)

Apply the specified member to the instruction operand opnum at the address ea.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • member (member_t or idaapi.member_t) –
  • *path – any structure members, names, or integers that is used to specify the path to apply to the operand
instruction.op_structure(reference, structure, *path)

Apply the specified structure along with the members in path to the operand pointed to by reference.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • reference (interface.opref_t) – the opref_t of the instruction and operand
  • structure (structure_t or idaapi.struc_t or str) – the structure to apply as a type or a name
  • *path – any structure members, names, or integers that is used to specify the path to apply to the operand
instruction.op_structure(reference, member, *path)

Apply the specified member along with the members in path to the instruction operand pointed to by reference.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • reference (interface.opref_t) – the opref_t of the instruction and operand
  • member (member_t or idaapi.member_t) –
  • *path – an iterable containing structures, members, or integers that is used to specify the path to apply to the operand
instruction.op_structure(reference, path)

Apply the structure members in path to the instruction operand pointed to by reference.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • reference (interface.opref_t) – the opref_t of the instruction and operand
  • path (tuple or list) – an iterable containing structures, members, or integers that is used to specify the path to apply to the operand
instruction.op_structure(ea, opnum, path)

Apply the structure members in path to the instruction operand opnum at the address ea.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • path (tuple or list) – an iterable containing structures, members, or integers that is used to specify the path to apply to the operand
instruction.op_structure(ea, opnum, sptr, path)

Apply the structure identified by sptr along with the members in path to the instruction operand opnum at the address ea.

Aliases: instruction.op_struct, instruction.op_struc

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the current instruction
  • sptr (idaapi.struc_t) – the idaapi.struc_t to apply
  • path (tuple or list) – an iterable containing any structure members, names, or integers that is used to specify the path to apply to the operand
instruction.op_structurepath(opnum)

Return the structure and members for operand opnum at the current instruction.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_structurepath(reference)

Return the structure and members for the operand pointed to by reference.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_structurepath(ea, opnum)

Return the structure and members for the operand opnum at the instruction ea.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.op_structurepath(opnum, structure, *path, **delta)

Apply the specified structure along with any members in path to the instruction operand opnum at the current address.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • opnum (int or long) – the operand number of the current instruction
  • structure (structure_t or idaapi.struc_t or str) – the structure_t to apply
  • *path – any structure members, names, or integers that describes the full path to the member that gets applied to the operand
  • **delta
instruction.op_structurepath(opnum, member, *path, **delta)

Apply the specified member along with any members in path to the instruction operand opnum at the current address.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • opnum (int or long) – the operand number of the current instruction
  • member (member_t or idaapi.member_t) – the member_t to apply
  • *path – any structure members, names, or integers that describes the full path to the member that gets applied to the operand
  • **delta
instruction.op_structurepath(ea, opnum, structure, *path, **delta)

Apply the specified structure along with the members in path to the instruction operand opnum at the address ea.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • structure (structure_t or idaapi.struc_t or str) – the structure_t to apply
  • *path – any structure members, names, or integers that describes the full path to the member that gets applied to the operand
  • **delta
instruction.op_structurepath(ea, opnum, member, *path, **delta)

Apply the specified member to the instruction operand opnum at the address ea.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • member (member_t or idaapi.member_t) –
  • *path – any structure members, names, or integers that describes the full path to the member that gets applied to the operand
  • **delta
instruction.op_structurepath(reference, structure, *path, **delta)

Apply the specified structure along with the members in path to the operand pointed to by reference.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • reference (interface.opref_t) – the opref_t of the instruction and operand
  • structure (structure_t or idaapi.struc_t or str) – the structure to apply as a type or a name
  • *path – any structure members, names, or integers that describes the full path to the member that gets applied to the operand
  • **delta
instruction.op_structurepath(reference, member, *path, **delta)

Apply the specified member along with the members in path to the instruction operand pointed to by reference.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • reference (interface.opref_t) – the opref_t of the instruction and operand
  • member (member_t or idaapi.member_t) –
  • *path – an iterable containing structures, members, or integers that describes the full path to the member that gets applied to the operand
  • **delta
instruction.op_structurepath(reference, path)

Apply the structure members in path to the instruction operand pointed to by reference.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • reference (interface.opref_t) – the opref_t of the instruction and operand
  • path (tuple or list) – an iterable containing structures, members, or integers that describes the full path to the member that gets applied to the operand
instruction.op_structurepath(ea, opnum, path)

Apply the structure members in path to the instruction operand opnum at the address ea.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • path (tuple or list) – an iterable containing structures, members, or integers that describes the full path to the member that gets applied to the operand
instruction.op_structurepath(ea, opnum, sptr, path)

Apply the structure identified by sptr along with the members in path to the instruction operand opnum at the address ea.

Aliases: instruction.op_strpath, instruction.op_strucpath

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the current instruction
  • sptr (idaapi.struc_t) – the idaapi.struc_t to apply
  • path (tuple or list) – an iterable containing any structure members, names, or integers that describes the full path to the member that gets applied to the operand
instruction.op_type(opnum)

Returns the pythonic type of the operand opnum belonging to the current instruction.

Aliases: instruction.opt

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.op_type(reference)

Returns the pythonic type of the operand pointed to by reference.

Aliases: instruction.opt

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand
instruction.op_type(ea, opnum)

Returns the pythonic type of the operand opnum belonging to the instruction at the address ea.

Aliases: instruction.opt

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.operand(opnum)

Returns the idaapi.op_t for the operand opnum belonging to the instruction at the current address.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.operand(reference)

Returns the idaapi.op_t for the operand pointed to by reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand to return the idaapi.op_t for
instruction.operand(ea, opnum)

Returns the idaapi.op_t for the operand opnum belonging to the instruction at the address ea.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.operands()

Returns all of the idaapi.op_t instances for the instruction at the current address.

instruction.operands(ea)

Returns all of the idaapi.op_t instances for the instruction at the address ea.

Parameters:ea (int or long) – the address of an instruction
instruction.opinfo(opnum)

Returns the idaapi.opinfo_t for the operand opnum belonging to the instruction at the current address.

Parameters:opnum (int or long) – the operand number of the current instruction
instruction.opinfo(opnum, info, **flags)

Set the opinfo for the operand opnum at the current address to the idaapi.opinfo_t provided by info.

Parameters:
  • opnum (int or long) – the operand number of the current instruction
  • info (idaapi.opinfo_t) – the idaapi.opinfo_t to assign to the operand
  • **flags – any operand information flags to assign
instruction.opinfo(reference)

Returns the idaapi.opinfo_t for the operand pointed to by the provided reference.

Parameters:reference (interface.opref_t) – the opref_t of the instruction and operand to return the idaapi.opinfo_t for
instruction.opinfo(ea, opnum)

Returns the idaapi.opinfo_t for the operand opnum belonging to the instruction at the address ea.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
instruction.opinfo(reference, info, **flags)

Set the operand info for the operand specified by reference to the idaapi.opinfo_t provided by info.

Parameters:
  • reference (interface.opref_t) – the opref_t of the instruction and operand to set the idaapi.opinfo_t for
  • info (idaapi.opinfo_t) – the idaapi.opinfo_t to assign to the operand
  • **flags – any operand information flags to assign
instruction.opinfo(ea, opnum, info, **flags)

Set the operand info for the operand opnum at the address ea to the idaapi.opinfo_t provided by info.

If any flags have been specified, then also set the operand’s flags to the provided value.

Parameters:
  • ea (int or long) – the address of an instruction
  • opnum (int or long) – the operand number of the instruction
  • info (idaapi.opinfo_t) – the idaapi.opinfo_t to assign to the operand
  • **flags – any operand information flags to assign
instruction.ops()

Returns a tuple of all the operands for the instruction at the current address.

Aliases: instruction.ops_value

instruction.ops(ea)

Returns a tuple of all the operands for the instruction at the address ea.

Aliases: instruction.ops_value

Parameters:ea (int or long) – the address of an instruction
instruction.ops_constant()

Return the operands that are being written to by the instruction at the current address.

Aliases: instruction.ops_const

instruction.ops_constant(ea)

Return the operands that are being written to by the instruction at the current address.

Aliases: instruction.ops_const

Parameters:ea (int or long) – the address of an instruction
instruction.ops_count()

Returns the number of operands of the instruction at the current address.

instruction.ops_count(ea)

Returns the number of operands of the instruction at the address ea.

Parameters:ea (int or long) – the address of an instruction
instruction.ops_decoder()

Return a tuple of the names of the decoders that will be used for all the operands in the instruction at the current address.

instruction.ops_decoder(ea)

Return a tuple of the names of the decoders that will be used for all the operands in the instruction at the address ea.

Parameters:ea (int or long) –
instruction.ops_read()

Return the operands that are being read from by the instruction at the current address.

instruction.ops_read(ea)

Return the operands that are being read from by the instruction at the current address.

Parameters:ea (int or long) – the address of an instruction
instruction.ops_refinfo()

Returns the idaapi.refinfo_t for the instruction at the current address.

instruction.ops_refinfo(ea)

Returns the idaapi.refinfo_t for the instruction at the address ea.

Parameters:ea (int or long) – the address in the database to fetch the idaapi.refinfo_t from
instruction.ops_register(**modifiers)

Returns each register operand in the instruction at the current address.

Aliases: instruction.ops_regs, instruction.ops_reg, instruction.ops_registers

Parameters:**modifiers – if write is specified, then only return operands that write to any registers. if read is specified then do the same but for operands that read from them.
instruction.ops_register(ea, **modifiers)

Returns each register operand in the instruction at the current address.

Aliases: instruction.ops_regs, instruction.ops_reg, instruction.ops_registers

Parameters:
  • ea (int or long) – the address of an instruction
  • **modifiers – if write is specified, then only return operands that write to any registers. if read is specified then do the same but for operands that read from them.
instruction.ops_register(reg, *regs, **modifiers)

Returns each register operand in the instruction at the current address that is reg or any one of the registers in regs.

Aliases: instruction.ops_regs, instruction.ops_reg, instruction.ops_registers

Parameters:
  • reg (str or register_t) – the register to search the operands for
  • *regs – any other registers to include
  • **modifiers – if write is specified, then only return operands that write to the specified registers. if read is specified then do the same but for operands that read from them.
instruction.ops_register(ea, reg, *regs, **modifiers)

Returns each register operand in the instruction at the address ea that is reg or any one of the registers in regs.’’’

If the keyword write is true, then only return the result if it’s writing to the register.

Aliases: instruction.ops_regs, instruction.ops_reg, instruction.ops_registers

Parameters:
  • ea (int or long) – the address of an instruction
  • reg (str or register_t) – the register to search the operands for
  • *regs – any other registers to include
  • **modifiers – if write is specified, then only return operands that write to the specified registers. if read is specified then do the same but for operands that read from them.
instruction.ops_repr()

Returns a tuple of the op_repr of all the operands for the instruction at the current address.

instruction.ops_repr(ea)

Returns a tuple of the op_repr of all the operands for the instruction at the address ea.

Parameters:ea (int or long) – the address of an instruction
instruction.ops_size()

Returns a tuple with all the sizes of each operand for the instruction at the current address.

instruction.ops_size(ea)

Returns a tuple with all the sizes of each operand for the instruction at the address ea.

Parameters:ea (int or long) – the address of an instruction
instruction.ops_state()

Returns a tuple for all the operands containing one of the states “r”, “w”, or “rw”

instruction.ops_state(ea)

Returns a tuple of for all the operands containing one of the states “r”, “w”, or “rw” describing how the operands are modified for the instruction at address ea.

Parameters:ea (int or long) – the address of an instruction
instruction.ops_write()

Return the operands that are being written to by the instruction at the current address.

instruction.ops_write(ea)

Return the operands that are being written to by the instruction at the current address.

Parameters:ea (int or long) – the address of an instruction
instruction.opsi_constant()

Return the indices of any operands in the current instruction that are constants.

Aliases: instruction.opsi_const

instruction.opsi_constant(ea)

Return the indices of any operands in the instruction at ea that are constants.

Aliases: instruction.opsi_const

Parameters:ea (int or long) – the address of an instruction
instruction.opsi_read()

Returns the indices of any operands that are being read from by the instruction at the current address.

instruction.opsi_read(ea)

Returns the indices of any operands that are being read from by the instruction at the address ea.

Parameters:ea (int or long) – the address of an instruction
instruction.opsi_register(**modifiers)

Returns the index of each operand in the instruction at the current address which uses a register.

Aliases: instruction.opsi_regs, instruction.opsi_regi, instruction.opsi_registers, instruction.opsi_reg

Parameters:**modifiers – if write is specified, then only return operands that write to any registers. if read is specified then do the same but for operands that read from them.
instruction.opsi_register(ea, **modifiers)

Returns the index of each operand in the instruction at the address ea which uses a register.

Aliases: instruction.opsi_regs, instruction.opsi_regi, instruction.opsi_registers, instruction.opsi_reg

Parameters:
  • ea (int or long) – the address of an instruction
  • **modifiers – if write is specified, then only return operands that write to any registers. if read is specified then do the same but for operands that read from them.
instruction.opsi_register(reg, *regs, **modifiers)

Returns the index of each operand in the instruction at the current address that uses reg or any one of the registers in regs.

Aliases: instruction.opsi_regs, instruction.opsi_regi, instruction.opsi_registers, instruction.opsi_reg

Parameters:
  • reg (str or register_t) – the register to search the operands for
  • *regs – any other registers to include
  • **modifiers – if write is specified, then only return operands that write to any registers. if read is specified then do the same but for operands that read from them.
instruction.opsi_register(ea, reg, *regs, **modifiers)

Returns the index of each operand in the instruction at address ea that uses reg or any one of the registers in regs.

If the keyword write is true, then only return the result if it’s writing to the register.

Aliases: instruction.opsi_regs, instruction.opsi_regi, instruction.opsi_registers, instruction.opsi_reg

Parameters:
  • ea (int or long) – the address of an instruction
  • reg (str or register_t) – the register to search the operands for
  • *regs – any other registers to include
  • **modifiers – if write is specified, then only return operands that write to any registers. if read is specified then do the same but for operands that read from them.
instruction.opsi_write()

Returns the indices of the operands that are being written to by the instruction at the current address.

instruction.opsi_write(ea)

Returns the indices of the operands that are being written to by the instruction at the address ea.

Parameters:ea (int or long) – the address of an instruction
instruction.opts()

Returns a tuple of the pythonic types for all the operands in the instruction at the current address.

Aliases: instruction.ops_type

instruction.opts(ea)

Returns a tuple of the pythonic types for all the operands in the instruction at the address ea.

Aliases: instruction.ops_type

Parameters:ea (int or long) – the address of an instruction
instruction.size()

Returns the length of the instruction at the current address.

instruction.size(ea)

Returns the length of the instruction at the address ea.

Parameters:ea (int or long) – the address of an instruction

3.1.4.2. Namespace list

These are the namespaces available within this module. Namespaces group similar functions that can be used typically for the same concept. Please see Classes as namespaces for more information on namespaces. For more information on multicase functions or aliases, please see Multicased functions or Aliases.

3.1.4.2.1. instruction.armops

This internal namespace contains the different operand types that can be returned for the AArch32 and AArch64 architectures.

3.1.4.2.1.1. armops.condition_t

class armops.condition_t

Bases: symbol_t

A symbol for representing a condition operand on either the AArch32 or AArch64 architectures.

flags
Parameters:getter – Return the required flags for the current condition to be true.
name
Parameters:getter
symbols
Parameters:getter – A condition_t is actually a symbol that yields itself.

3.1.4.2.1.2. armops.flex

class armops.flex

Bases: namedtuple, symbol_t

A tuple representing a flexible operand type that can be decoded on either the AArch32 or AArch64 architectures.

Has the format (Rn, shift, n) which allows the architecture to apply a binary shift or rotation to the value of a register Rn.

symbols
Parameters:getter – Yield the Rn register from the tuple.

3.1.4.2.1.3. armops.immediatephrase

class armops.immediatephrase

Bases: interface.integerish, symbol_t

A tuple representing a memory displacement operand on either the AArch32 or AArch64 architectures.

Has the format (Rn, Offset) where Rn is a register and Offset is the integer that is added to the register.

symbols
Parameters:getter – Yield the Rn register from the tuple.

3.1.4.2.1.4. armops.list

class armops.list

Bases: namedtuple, symbol_t

A tuple representing a register list operand on either the AArch32 or AArch64 architectures.

Has the simple format (reglist) where reglist is a set of registers that can be explicitly tested as a set for membership.

symbols
Parameters:getter – Yield any of the registers within the reglist field belonging to the tuple.

3.1.4.2.1.5. armops.memory

class armops.memory

Bases: namedtuple, symbol_t

A tuple for representing a memory operand on either the AArch32 or AArch64 architectures.

Has the format (address, value) where address is the actual value stored in the operand and value is the value that would be dereferenced.

symbols
Parameters:getter – This operand type is not composed of any symbols.

3.1.4.2.1.6. armops.registerphrase

class armops.registerphrase

Bases: namedtuple, symbol_t

A tuple for representing a memory phrase on either the AArch32 or AArch64 architectures.

Has the format (Rn, Rm) where both values are registers that compose the phrase.

symbols
Parameters:getter – Yield the Rn and Rm registers from the tuple.

3.1.4.2.2. instruction.intelops

This internal namespace contains the different operand types that can be returned for the Intel architecture.

3.1.4.2.2.1. intelops.OffsetBaseIndexScale

class intelops.OffsetBaseIndexScale

Bases: interface.integerish, symbol_t

A tuple representing a memory phrase for the Intel architecture.

Has the format (offset, base, index, scale) where both base and index are both optional registers.

symbols
Parameters:getter – Yield the base, and the index registers from the tuple if they are defined.

3.1.4.2.2.2. intelops.SegmentOffset

class intelops.SegmentOffset

Bases: interface.integerish, symbol_t

A tuple representing an address with a segment register attached on the Intel architecture.

Has the format (segment, offset) where segment is a segment register.

symbols
Parameters:getter – Yield the segment register from the tuple if it is defined.

3.1.4.2.2.3. intelops.SegmentOffsetBaseIndexScale

class intelops.SegmentOffsetBaseIndexScale

Bases: interface.integerish, symbol_t

A tuple representing a memory phrase operand on the Intel architecture.

Has the format (segment, offset, base, index, scale) where segment includes the segment register and both the base and index registers are both optional.

symbols
Parameters:getter – Yield the segment, base, and the index registers from the tuple if they are defined.

3.1.4.2.3. instruction.mipsops

This internal namespace contains the different operand types that are used by the MIPS architectures.

3.1.4.2.3.1. mipsops.phrase

class mipsops.phrase

Bases: interface.integerish, symbol_t

A tuple for representing a memory phrase operand on the MIPS architectures.

Has the format (Rn, Offset) where Rn is the register and Offset is the immediate that is added to the Rn register.

symbols
Parameters:getter – Yield the Rn register from this tuple.

3.1.4.2.3.2. mipsops.trap

class mipsops.trap

Bases: namedtuple, symbol_t

A tuple for representing a trap code that can be encoded within certain instructions on the MIPS architectures.

Simply wraps the encoded integer in a single-element tuple with the format of (code).

symbols
Parameters:getter – This operand type is not composed of any symbols.

3.1.4.2.4. instruction.type

This namespace is for fetching information about the instruction type at a given address within the database. The functions within this namespace return a boolean based on whether the instruction at the given address fits a particular type.

It is prudent to note that the information that these functions expose are essentially flags for the instruction and is provided in order to allow a user to infer how IDA has processed the instruction. These flags are used by IDA in order to determine things such as whether or not it should continue disassembling, or if it should add the instruction’s operand to its queue in order to recursively disassemble code witin the database.

This namespace is also aliased as instruction.t.

Some examples of using this namespace are:

> print( instruction.type.is_return(ea) )
> print( instruction.type.is_jxx(ea) )
> print( instruction.type.is_call(ea) )
> print( instruction.type.is_branch(ea) )
type.feature()

Returns the feature bitmask of the instruction at the current address.

Aliases: instruction.feature

type.feature(ea)

Return the feature bitmask for the instruction at the address ea.

Aliases: instruction.feature

Parameters:ea (int or long) – the address of an instruction
type.feature(ea, mask)

Return the feature bitmask for the instruction at the address ea masked with mask.

Aliases: instruction.feature

Parameters:
  • ea (int or long) – the address of an instruction
  • mask (int or long) – a bitmask used to select specific bits from the instruction feature
type.is_branch()

Returns true if the current instruction is any kind of branch.

Aliases: instruction.type.branchQ, instruction.branchQ, instruction.is_branch, instruction.type.isbranch

type.is_branch(ea)

Returns true if the instruction at ea is any kind of branch.

Aliases: instruction.type.branchQ, instruction.branchQ, instruction.is_branch, instruction.type.isbranch

Parameters:ea (int or long) – the address of an instruction
type.is_call()

Returns true if the current instruction is a call.

Aliases: instruction.callQ, instruction.is_call, instruction.type.iscall, instruction.type.callQ

type.is_call(ea)

Returns true if the instruction at ea is a call.

Aliases: instruction.callQ, instruction.is_call, instruction.type.iscall, instruction.type.callQ

Parameters:ea (int or long) – the address of an instruction
type.is_calli()

Return true if the current instruction is an indirect call.

Aliases: instruction.is_calli, instruction.type.calliQ, instruction.calliQ, instruction.type.iscalli

type.is_calli(ea)

Returns true if the instruction at ea is an indirect call.

Aliases: instruction.is_calli, instruction.type.calliQ, instruction.calliQ, instruction.type.iscalli

Parameters:ea (int or long) – the address of an instruction
type.is_jmp()

Returns true if the current instruction is an immediate and indirect branch.

Aliases: instruction.type.isjmp, instruction.jmpQ, instruction.type.jmpQ, instruction.is_jmp

type.is_jmp(ea)

Returns true if the instruction at ea is an immediate and indirect branch.

Aliases: instruction.type.isjmp, instruction.jmpQ, instruction.type.jmpQ, instruction.is_jmp

Parameters:ea (int or long) – the address of an instruction
type.is_jmpi()

Returns true if the instruction at the current address is an indirect branch.

Aliases: instruction.jmpiQ, instruction.type.isjmpi, instruction.is_jmpi, instruction.type.jmpiQ

type.is_jmpi(ea)

Returns true if the instruction at ea is an indirect branch.

Aliases: instruction.jmpiQ, instruction.type.isjmpi, instruction.is_jmpi, instruction.type.jmpiQ

Parameters:ea (int or long) – the address of an instruction
type.is_jxx()

Returns true if the current instruction is a conditional branch.

Aliases: instruction.type.jxxQ, instruction.is_jxx, instruction.jxxQ, instruction.type.isjxx

type.is_jxx(ea)

Returns true if the instruction at ea is a conditional branch.

Aliases: instruction.type.jxxQ, instruction.is_jxx, instruction.jxxQ, instruction.type.isjxx

Parameters:ea (int or long) – the address of an instruction
type.is_return()

Returns true if the current instruction is a return-type instruction.

Aliases: instruction.type.returnQ, instruction.type.retQ, instruction.is_return, instruction.returnQ, instruction.retQ, instruction.type.isreturn

type.is_return(ea)

Returns true if the instruction at ea is a return-type instruction.

Aliases: instruction.type.returnQ, instruction.type.retQ, instruction.is_return, instruction.returnQ, instruction.retQ, instruction.type.isreturn

Parameters:ea (int or long) – the address of an instruction
type.is_sentinel()

Returns true if the current instruction is a sentinel-type instruction.

Aliases: instruction.type.issentinel, instruction.type.sentinelQ

type.is_sentinel(ea)

Returns true if the instruction at ea is a sentinel-type instruction.

Aliases: instruction.type.issentinel, instruction.type.sentinelQ

Parameters:ea (int or long) – the address of an instruction
type.is_shift()

Returns true if the current instruction is a bit-shifting instruction.

Aliases: instruction.type.shiftQ, instruction.shiftQ, instruction.is_shift, instruction.type.isshift

type.is_shift(ea)

Returns true if the instruction at ea is a bit-shifting instruction.

Aliases: instruction.type.shiftQ, instruction.shiftQ, instruction.is_shift, instruction.type.isshift

Parameters:ea (int or long) – the address of an instruction

3.1.4.3. Class list

Classes provide the definition necessary to instantiate an object. In most cases, a class is returned when calling one of the prior listed functions and thus have no need to be manually instantiated. Classes may also have aliases defined for them. Please refer to the documentation for the class to see what is available. For more information on aliases, please see Aliases.

3.1.4.3.1. AArch32

class instruction.AArch32

Bases: AArch

An implementation of all the registers available on the AArch32 (ARM) architecture.

This is used to locate or manage the different registers that are available.

An instance of this class can be accessed as instruction.architecture (or instruction.arch) when the current architecture of the database is AArch32.

3.1.4.3.2. AArch64

class instruction.AArch64

Bases: AArch

An implementation of all the registers available on the AArch64 (ARM) architecture.

This is used to locate or manage the different registers that are available.

An instance of this class can be accessed as instruction.architecture (or instruction.arch) when the current architecture of the database is AArch64.

3.1.4.3.3. Intel

class instruction.Intel

Bases: architecture_t

An implementation of all the registers available on the Intel architecture.

This keeps track of the relationships between registers to allow one to promote or demote a register to the different sizes that are available.

An instance of this class can be accessed as instruction.architecture (or instruction.arch) when the current architecture of the database is Intel.

by_control(self, index)

Return the desired control register by the specified index.

Parameters:index – the index of the control register
by_float(self, index)

Return the desired floating-point stack register by the specified index.

Parameters:index – the index of the floating-point register
by_mmx(self, index)

Return the desired MultiMedia eXtension register of the specified index.

Parameters:index – the index of the MMX register
by_xmm(self, index)

Return the desired SSE vector register of the specified index.

Parameters:index – the index of the XMM register
by_ymm(self, index)

Return the desired 256-bit Advanced Vector Extensions register of the specified index.

Parameters:index – the index of the YMM register
by_zmm(self, index)

Return the desired 512-bit Advanced Vector Extensions register of the specified index.

Parameters:index – the index of the ZMM register

3.1.4.3.4. MIPS32

class instruction.MIPS32

Bases: MIPS

An implementation of all the registers available on the MIPS32 architecture.

This includes the different coprocessor registers that are also available but are treated as special instructions by IDA.

An instance of this class can be accessed as instruction.architecture (or instruction.arch) when the current architecture of the database is MIPS.

3.1.4.3.5. MIPS64

class instruction.MIPS64

Bases: MIPS

An implementation of all the registers available on the MIPS64 architecture.

This includes the different coprocessor registers that are also available but are treated as special instructions by IDA.

An instance of this class can be accessed as instruction.architecture (or instruction.arch) when the current architecture of the database is MIPS.