Module index

Module ida_ua

Functions that deal with the disassembling of program instructions.

There are 2 kinds of functions: * functions that are called from the kernel to disassemble an instruction. These functions call IDP module for it. * functions that are called from IDP module to disassemble an instruction. We will call them 'helper functions'.

Disassembly of an instruction is made in three steps: 1. analysis: ana.cpp 2. emulation: emu.cpp 3. conversion to text: out.cpp

The kernel calls the IDP module to perform these steps. At first, the kernel always calls the analysis. The analyzer must decode the instruction and fill the insn_t instance that it receives through its callback. It must not change anything in the database.

The second step, the emulation, is called for each instruction. This step must make necessary changes to the database, plan analysis of subsequent instructions, track register values, memory contents, etc. Please keep in mind that the kernel may call the emulation step for any address in the program - there is no ordering of addresses. Usually, the emulation is called for consecutive addresses but this is not guaranteed.

The last step, conversion to text, is called each time an instruction is displayed on the screen. The kernel will always call the analysis step before calling the text conversion step. The emulation and the text conversion steps should use the information stored in the insn_t instance they receive. They should not access the bytes of the instruction and decode it again - this should only be done in the analysis step.

Global variables

var BINOPSTATE_DONE

have been generated

var BINOPSTATE_GO

being generated

var BINOPSTATE_NONE

not generated yet

var COMMSTATE_DONE

have been generated

var COMMSTATE_GO

being generated

var COMMSTATE_NONE

not generated yet

var CTXF_BINOP_STATE

opcode bytes state:

var CTXF_BIT_PREFIX

generate a line prefix with a bit offset, e.g.: 12345678.3

var CTXF_CMT_STATE

comment state:

var CTXF_CODE

display as code regardless of the database flags

var CTXF_DBLIND_OPND

an operand was printed with double indirection (e.g. =var in arm)

var CTXF_DEMANGLED_LABEL

generate only demangled label as comment

var CTXF_DEMANGLED_OK

the label has been demangled successfully

var CTXF_GEN_CMT

generate the comment along with the next line

var CTXF_GEN_XREFS

generate the xrefs along with the next line

var CTXF_HIDDEN_ADDR

To generate an hidden addr tag at the beginning of the line.

var CTXF_LABEL_OK

the label have been generated

var CTXF_MAIN

produce only the essential line(s)

var CTXF_MULTI

enable multi-line essential lines

var CTXF_NORMAL_LABEL

generate plain label (+demangled label as cmt)

var CTXF_OUTCTX_T

instance is, in fact, a outctx_t

var CTXF_OVSTORE_PRNT

out_value should store modified values

var CTXF_STACK

stack view (display undefined items as 2/4/8 bytes)

var CTXF_VOIDS

display void marks

var CTXF_XREF_STATE

xref state:

var FCBF_CONT

don't stop on decoding, or any other kind of error

var FCBF_DELIM

add the 'ash'-specified delimiters around the generated data. Note: if those are not defined and the INFFL_ALLASM is not set, format_charlit() will return an error

var FCBF_ERR_REPL

in case of an error, use a CP_REPLCHAR instead of a hex representation of the problematic byte

var FCBF_FF_LIT

in case of codepoints == 0xFF, use it as-is (i.e., LATIN SMALL LETTER Y WITH DIAERESIS). If both this, and FCBF_REPL are specified, this will take precedence

var GH_BYTESEX_HAS_HIGHBYTE

describe inf.is_wide_high_byte_first()

var GH_PRINT_ASM

selected assembler

var GH_PRINT_BYTESEX

byte sex

var GH_PRINT_HEADER

lines from ash.header

var GH_PRINT_PROC

processor name

var INSN_64BIT

belongs to 64bit segment?

var INSN_MACRO

macro instruction

var INSN_MODMAC

may modify the database to make room for the macro insn

var MAKELINE_BINPREF

allow display of binary prefix

var MAKELINE_STACK

allow display of sp trace prefix

var MAKELINE_VOID

allow display of '' marks

var OF_NO_BASE_DISP

base displacement doesn't exist. meaningful only for o_displ type. if set, base displacement (op_t::addr) doesn't exist.

var OF_NUMBER

the operand can be converted to a number only

var OF_OUTER_DISP

outer displacement exists. meaningful only for o_displ type. if set, outer displacement (op_t::value) exists.

var OF_SHOW

should the operand be displayed?

var OOFS_IFSIGN

output sign if needed

var OOFS_NEEDSIGN

always out sign (+-)

var OOFS_NOSIGN

don't output sign, forbid the user to change the sign

var OOFW_16

16 bit width

var OOFW_24

24 bit width

var OOFW_32

32 bit width

var OOFW_64

64 bit width

var OOFW_8

8 bit width

var OOFW_IMM

take from x.dtype

var OOF_ADDR

output x.addr, otherwise x.value

var OOF_ANYSERIAL

if enum: select first available serial

var OOF_LZEROES

print leading zeroes

var OOF_NOBNOT

prohibit use of binary not

var OOF_NO_LZEROES

do not print leading zeroes; if none of OOF_LZEROES and OOF_NO_LZEROES was specified, is_lzero() is used

var OOF_NUMBER

always as a number

var OOF_OUTER

output outer operand

var OOF_SIGNED

output as signed if < 0

var OOF_SIGNMASK

sign symbol (+/-) output

var OOF_SPACES

do not suppress leading spaces; currently works only for floating point numbers

var OOF_WIDTHMASK

width of value in bits

var OOF_ZSTROFF

meaningful only if is_stroff(F); append a struct field name if the field offset is zero? if AFL_ZSTROFF is set, then this flag is ignored.

var PACK_FORM_DEF

packed factor defined. (!o_reg + dt_packreal)

var STKVAR_VALID_SIZE

x.dtype contains correct variable type (for insns like 'lea' this bit must be off). in general, dr_O references do not allow to determine the variable size

var XREFSTATE_DONE

have been generated

var XREFSTATE_GO

being generated

var XREFSTATE_NONE

not generated yet

var dt_bitfild

bit field (mc680x0)

var dt_byte

8 bit integer

var dt_byte16

128 bit integer

var dt_byte32

256 bit integer

var dt_byte64

512 bit integer

var dt_code

ptr to code (not used?)

var dt_double

8 byte floating point

var dt_dword

32 bit integer

var dt_float

4 byte floating point

var dt_fword

48 bit

var dt_half

2-byte floating point

var dt_ldbl

long double (which may be different from tbyte)

var dt_packreal

packed real format for mc68040

var dt_qword

64 bit integer

var dt_string

pointer to asciiz string

var dt_tbyte

variable size ( processor_t::tbyte_size) floating point

var dt_unicode

pointer to unicode string

var dt_void

none

var dt_word

16 bit integer

var o_displ

Memory Ref [Base Reg + Index Reg + Displacement].

A memory reference using register contents with displacement. The displacement should be stored in the op_t::addr field. The rest of information is stored the same way as in o_phrase.

var o_far

Immediate Far Address (CODE).

If the current processor has a special addressing mode for inter-segment references, then this operand type should be used instead of o_near. If you want, you may use PR_CHK_XREF in processor_t::flag to disable inter-segment calls if o_near operand type is used. Currently only IBM PC uses this flag.

var o_idpspec0

processor specific type.

var o_idpspec1

processor specific type.

var o_idpspec2

processor specific type.

var o_idpspec3

processor specific type.

var o_idpspec4

processor specific type.

var o_idpspec5

processor specific type. (there can be more processor specific types)

var o_imm

Immediate Value.

Any operand consisting of only a number is represented by this operand type. The value should be stored in op_t::value. You may sign extend short (1-2 byte) values. In any case don't forget to specify op_t::dtype (should be set for all operand types).

var o_mem

Direct Memory Reference (DATA).

A direct memory data reference whose target address is known at compilation time. The target virtual address is stored in op_t::addr and the full address is calculated as to_ea( insn_t::cs, op_t::addr ). For the processors with complex memory organization the final address can be calculated using other segment registers. For flat memories, op_t::addr is the final address and insn_t::cs is usually equal to zero. In any case, the address within the segment should be stored in op_t::addr.

var o_near

Immediate Near Address (CODE).

A direct memory code reference whose target address is known at the compilation time. The target virtual address is stored in op_t::addr and the final address is always to_ea( insn_t::cs, op_t::addr). Usually this operand type is used for the branches and calls whose target address is known. If the current processor has 2 different types of references for inter-segment and intra-segment references, then this should be used only for intra-segment references.

If the above operand types do not cover all possible addressing modes, then use o_idpspec… operand types.

var o_phrase

Memory Ref [Base Reg + Index Reg].

A memory reference using register contents. Indexed, register based, and other addressing modes can be represented with the operand type. This addressing mode cannot contain immediate values (use o_displ instead). The phrase number should be stored in op_t::phrase. To denote the pre-increment and similar features please use additional operand fields like op_t::specflag… Usually op_t::phrase contains the register number and additional information is stored in op_t::specflags… Please note that this operand type cannot contain immediate values (except the scaling coefficients).

var o_reg

General Register (al,ax,es,ds…).

The register number should be stored in op_t::reg. All processor registers, including special registers, can be represented by this operand type.

var o_void

No Operand.

Functions

def calc_dataseg(insn: insn_t, n: int = -1, rgnum: int = -1)

calc_dataseg(insn, n=-1, rgnum=-1) -> ea_t Get data segment for the instruction operand. 'opnum' and 'rgnum' are meaningful only if the processor has segment registers.

@param insn: (C++: const insn_t &) an ida_ua.insn_t, or an address (C++: const insn_t &) @param n: (C++: int) @param rgnum: (C++: int)

def can_decode(ea: ea_t)

can_decode(ea) -> bool Can the bytes at address 'ea' be decoded as instruction?

@param ea: (C++: ea_t) linear address @return: whether or not the contents at that address could be a valid instruction

def construct_macro(*args) ‑> bool

construct_macro(_this, insn, enable) -> bool See ua.hpp's construct_macro().

@param _this: macro_constructor_t * @param insn: insn_t * @param enable: bool

construct_macro(insn, enable, build_macro) -> bool

@param insn: insn_t & @param enable: bool @param build_macro: PyObject *

def create_insn(ea: ea_t, out: insn_t = None)

create_insn(ea, out=None) -> int Create an instruction at the specified address. This function checks if an instruction is present at the specified address and will try to create one if there is none. It will fail if there is a data item or other items hindering the creation of the new instruction. This function will also fill the 'out' structure.

@param ea: (C++: ea_t) linear address @param out: (C++: insn_t *) the resulting instruction @return: the length of the instruction or 0

def create_outctx(ea: ea_t, F: flags64_t = 0, suspop: int = 0)

create_outctx(ea, F=0, suspop=0) -> outctx_base_t Create a new output context. To delete it, just use "delete pctx"

@param ea: (C++: ea_t) @param F: (C++: flags64_t) @param suspop: (C++: int)

def decode_insn(out: insn_t, ea: ea_t)

decode_insn(out, ea) -> int Analyze the specified address and fill 'out'. This function does not modify the database. It just tries to interpret the specified address as an instruction and fills the 'out' structure.

@param out: (C++: insn_t *) the resulting instruction @param ea: (C++: ea_t) linear address @return: the length of the (possible) instruction or 0

def decode_preceding_insn(out: insn_t, ea: ea_t)

decode_preceding_insn(out, ea) -> (int, int) Decodes the preceding instruction. Please check ua.hpp / decode_preceding_insn()

@param out: instruction storage @param ea: current ea @return: tuple(preceeding_ea or BADADDR, farref = Boolean)

def decode_prev_insn(out: insn_t, ea: ea_t)

decode_prev_insn(out, ea) -> ea_t Decode previous instruction if it exists, fill 'out'.

@param out: (C++: insn_t *) the resulting instruction @param ea: (C++: ea_t) the address to decode the previous instruction from @return: the previous instruction address (BADADDR-no such insn)

def get_dtype_by_size(size: asize_t)

get_dtype_by_size(size) -> int Get op_t::dtype from size.

@param size: (C++: asize_t)

def get_dtype_flag(dtype: op_dtype_t)

get_dtype_flag(dtype) -> flags64_t Get flags for op_t::dtype field.

@param dtype: (C++: op_dtype_t)

def get_dtype_size(dtype: op_dtype_t)

get_dtype_size(dtype) -> size_t Get size of opt_::dtype field.

@param dtype: (C++: op_dtype_t)

def get_immvals(ea: ea_t, n: int, F: flags64_t = 0)

get_immvals(ea, n, F=0) -> PyObject Get immediate values at the specified address. This function decodes instruction at the specified address or inspects the data item. It finds immediate values and copies them to 'out'. This function will store the original value of the operands in 'out', unless the last bits of 'F' are "…0 11111111", in which case the transformed values (as needed for printing) will be stored instead.

@param ea: (C++: ea_t) address to analyze @param n: (C++: int) 0..UA_MAXOP-1 operand number, OPND_ALL all the operands @param F: (C++: flags64_t) flags for the specified address @return: number of immediate values (0..2*UA_MAXOP)

def get_lookback() ‑> int

get_lookback() -> int Number of instructions to look back. This variable is not used by the kernel. Its value may be specified in ida.cfg: LOOKBACK = . IDP may use it as you like it. (TMS module uses it)

def get_printable_immvals(ea: ea_t, n: int, F: flags64_t = 0)

get_printable_immvals(ea, n, F=0) -> PyObject Get immediate ready-to-print values at the specified address

@param ea: (C++: ea_t) address to analyze @param n: (C++: int) 0..UA_MAXOP-1 operand number, OPND_ALL all the operands @param F: (C++: flags64_t) flags for the specified address @return: number of immediate values (0..2*UA_MAXOP)

def insn_add_cref(insn: insn_t, to: ea_t, opoff: int, type: cref_t)

insn_add_cref(insn, to, opoff, type)

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param to: ea_t @param opoff: int @param type: enum cref_t

def insn_add_dref(insn: insn_t, to: ea_t, opoff: int, type: dref_t)

insn_add_dref(insn, to, opoff, type)

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param to: ea_t @param opoff: int @param type: enum dref_t

def insn_add_off_drefs(insn: insn_t, x: op_t, type: dref_t, outf: int)

insn_add_off_drefs(insn, x, type, outf) -> ea_t

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param x: op_t const & @param type: enum dref_t @param outf: int

def insn_create_stkvar(insn: insn_t, x: op_t, v: adiff_t, flags: int)

insn_create_stkvar(insn, x, v, flags) -> bool

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param x: op_t const & @param v: adiff_t @param flags: int

def insn_t__from_ptrval__(ptrval: size_t)

insn_t__from_ptrval__(ptrval) -> insn_t

@param ptrval: size_t

def is_floating_dtype(dtype: op_dtype_t)

is_floating_dtype(dtype) -> bool Is a floating type operand?

@param dtype: (C++: op_dtype_t)

def map_code_ea(*args)

map_code_ea(insn, addr, opnum) -> ea_t

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param addr: ea_t @param opnum: int

map_code_ea(insn, op) -> ea_t

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param op: op_t const &

def map_data_ea(*args)

map_data_ea(insn, addr, opnum=-1) -> ea_t

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param addr: ea_t @param opnum: int

map_data_ea(insn, op) -> ea_t

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param op: op_t const &

def map_ea(*args)

map_ea(insn, op, iscode) -> ea_t

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param op: op_t const & @param iscode: bool

map_ea(insn, addr, opnum, iscode) -> ea_t

@param insn: an ida_ua.insn_t, or an address (C++: const insn_t &) @param addr: ea_t @param opnum: int @param iscode: bool

def op_t__from_ptrval__(ptrval: size_t)

op_t__from_ptrval__(ptrval) -> op_t

@param ptrval: size_t

def outctx_base_t__from_ptrval__(ptrval: size_t)

outctx_base_t__from_ptrval__(ptrval) -> outctx_base_t

@param ptrval: size_t

def outctx_t__from_ptrval__(ptrval: size_t)

outctx_t__from_ptrval__(ptrval) -> outctx_t

@param ptrval: size_t

def print_insn_mnem(ea: ea_t)

print_insn_mnem(ea) -> str Print instruction mnemonics.

@param ea: (C++: ea_t) linear address of the instruction @return: success

def print_operand(ea: ea_t, n: int, getn_flags: int = 0, newtype: printop_t = None)

print_operand(ea, n, getn_flags=0, newtype=None) -> bool Generate text representation for operand #n. This function will generate the text representation of the specified operand (includes color codes.)

@param ea: (C++: ea_t) the item address (instruction or data) @param n: (C++: int) 0..UA_MAXOP-1 operand number, meaningful only for instructions @param getn_flags: (C++: int) Name expression flags Currently only GETN_NODUMMY is accepted. @param newtype: (C++: struct printop_t *) if specified, print the operand using the specified type @return: success

def ua_mnem(ea: ea_t)

print_insn_mnem(ea) -> str Print instruction mnemonics.

@param ea: (C++: ea_t) linear address of the instruction @return: success

Classes

class insn_t

Proxy of C++ insn_t class.

init(self) -> insn_t

Instance variables

var Op1
var Op2
var Op3
var Op4
var Op5
var Op6
var Op7
var Op8
var auxpref : uint32

processor dependent field

var auxpref_u16 : uint16 [2]

auxpref_u16

var auxpref_u8 : uint8 [4]

auxpref_u8

var cs : ea_t

Current segment base paragraph. Initialized by the kernel.

var ea : ea_t

Linear address of the instruction. Initialized by the kernel.

var flags : int16

Instruction flags

var insnpref : char

processor dependent field

var ip : ea_t

Virtual address of the instruction (address within the segment). Initialized by the kernel.

var itype : uint16

Internal code of instruction (only for canonical insns - not user defined!). IDP should define its own instruction codes. These codes are usually defined in ins.hpp. The array of instruction names and features (ins.cpp) is accessed using this code.

var ops : wrapped_array_t< op_t,8 >

array of operands

var segpref : char

processor dependent field

var size : uint16

Size of instruction in bytes. The analyzer should put here the actual size of the instruction.

var thisown

The membership flag

Methods

def add_cref(self, to: ea_t, opoff: int, type: cref_t)

add_cref(self, to, opoff, type) Add a code cross-reference from the instruction.

@param to: (C++: ea_t) target linear address @param opoff: (C++: int) offset of the operand from the start of instruction. if the offset is unknown, then 0. @param type: (C++: cref_t) type of xref

def add_dref(self, to: ea_t, opoff: int, type: dref_t)

add_dref(self, to, opoff, type) Add a data cross-reference from the instruction. See add_off_drefs() - usually it can be used in most cases.

@param to: (C++: ea_t) target linear address @param opoff: (C++: int) offset of the operand from the start of instruction if the offset is unknown, then 0 @param type: (C++: dref_t) type of xref

def add_off_drefs(self, x: op_t, type: dref_t, outf: int)

add_off_drefs(self, x, type, outf) -> ea_t Add xrefs for an operand of the instruction. This function creates all cross references for 'enum', 'offset' and 'structure offset' operands. Use add_off_drefs() in the presence of negative offsets.

@param x: (C++: const op_t &) reference to operand @param type: (C++: dref_t) type of xref @param outf: (C++: int) out_value() flags. These flags should match the flags used to output the operand @return: if is_off(): the reference target address (the same as calc_reference_data). if is_stroff(): BADADDR because for stroffs the target address is unknown else: BADADDR because enums do not represent addresses

def assign(self, other: insn_t)

assign(self, other)

@param other: an ida_ua.insn_t, or an address (C++: const insn_t &)

def create_op_data(self, *args) ‑> bool

create_op_data(self, ea_, opoff, dtype) -> bool Convenient alias.

@param ea_: (C++: ea_t) @param opoff: int @param dtype: op_dtype_t

create_op_data(self, ea_, op) -> bool

@param ea_: ea_t @param op: op_t const &

def create_stkvar(self, x: op_t, v: adiff_t, flags_: int)

create_stkvar(self, x, v, flags_) -> bool Create or modify a stack variable in the function frame. The emulator could use this function to create stack variables in the function frame before converting the operand to a stack variable. Please check with may_create_stkvars() before calling this function.

@param x: (C++: const op_t &) operand (used to determine the addressing type) @param v: (C++: adiff_t) a displacement in the operand @param flags_: (C++: int) Stack variable flags @retval 1: ok, a stack variable exists now @retval 0: no, couldn't create stack variable

def get_canon_feature(self, *args)

get_canon_feature(self, ph) -> uint32 see instruc_t::feature

@param ph: (C++: const processor_t &) processor_t const &

get_canon_feature(self) -> uint32

def get_canon_mnem(self, *args)

get_canon_mnem(self, ph) -> char const see instruc_t::name

@param ph: (C++: const processor_t &) processor_t const &

get_canon_mnem(self) -> char const *

def get_next_byte(self)

get_next_byte(self) -> uint8

def get_next_dword(self)

get_next_dword(self) -> uint32

def get_next_qword(self)

get_next_qword(self) -> uint64

def get_next_word(self)

get_next_word(self) -> uint16

def is_64bit(self) ‑> bool

is_64bit(self) -> bool Belongs to a 64bit segment?

def is_canon_insn(self, *args) ‑> bool

is_canon_insn(self, ph) -> bool see processor_t::is_canon_insn()

@param ph: (C++: const processor_t &) processor_t const &

is_canon_insn(self) -> bool

def is_macro(self) ‑> bool

is_macro(self) -> bool Is a macro instruction?

class macro_constructor_t

Proxy of C++ macro_constructor_t class.

init(self) -> macro_constructor_t

@param self: PyObject *

Instance variables

var reserved : size_t

reserved

var thisown

The membership flag

Methods

def build_macro(self, insn: insn_t, may_go_forward: bool) ‑> bool

build_macro(self, insn, may_go_forward) -> bool Try to extend the instruction.

@param insn: (C++: insn_t *) Instruction to modify, usually the first instruction of the macro @param may_go_forward: (C++: bool) Is it ok to consider the next instruction for the macro? This argument may be false, for example, if there is a cross reference to the end of INSN. In this case creating a macro is not desired. However, it may still be useful to perform minor tweaks to the instruction using the information about the surrounding instructions. @return: true if created an macro instruction. This function may modify 'insn' and return false; these changes will be accepted by the kernel but the instruction will not be considered as a macro.

def construct_macro(self, insn: insn_t, enable: bool) ‑> bool

construct_macro(self, insn, enable) -> bool Construct a macro instruction. This function may be called from ana() to generate a macro instruction.

The real work is done by the 'build_macro()' virtual function. It must be defined by the processor module.

construct_macro() modifies the database using the info provided by build_macro(). It verifies if the instruction can really be created (for example, that other items do not hinder), may plan to reanalyze the macro, etc. If the macro instructions are disabled by the user, construct_macro() will destroy the macro instruction. Note: if INSN_MODMAC is not set in insn.flags, the database will not be modified.

@param insn: (C++: insn_t *) the instruction to modify into a macro @param enable: (C++: bool) enable macro generation @retval true: the macro instruction is generated in 'insn' @retval false: did not create a macro

class op_t

Proxy of C++ op_t class.

init(self) -> op_t

Instance variables

var addr : ea_t

virtual address pointed or used by the operand. (o_mem,o_displ,o_far,o_near)

var dtype : op_dtype_t

Type of operand value (see Operand value types). Usually first 9 types are used. This is the type of the operand itself, not the size of the addressing mode. for example, byte ptr [epb+32_bit_offset] will have dt_byte type.

var flags : uchar

Operand flags

var n : uchar

Number of operand (0,1,2). Initialized once at the start of work. You have no right to change its value.

var offb : char

Offset of operand value from the instruction start (0 means unknown). Of course this field is meaningful only for certain types of operands. Leave it equal to zero if the operand has no offset. This offset should point to the 'interesting' part of operand. For example, it may point to the address of a function in call func or it may point to bytes holding '5' in mov ax, [bx+5] Usually bytes pointed to this offset are relocated (have fixup information).

var offo : char

Same as offb (some operands have 2 numeric values used to form an operand). This field is used for the second part of operand if it exists. Currently this field is used only for outer offsets of Motorola processors. Leave it equal to zero if the operand has no offset.

var phrase : uint16

number of register phrase (o_phrase,o_displ). you yourself define numbers of phrases as you like

var reg : uint16

number of register (o_reg)

var specflag1 : char

specflag1

var specflag2 : char

specflag2

var specflag3 : char

specflag3

var specflag4 : char

specflag4

var specval : ea_t

This field may be used as you want.

var thisown

The membership flag

var type : optype_t

Type of operand (see Operand types)

var value : ea_t

operand value (o_imm) or outer displacement (o_displ+OF_OUTER_DISP). integer values should be in IDA's (little-endian) order. when using ieee_realcvt(), floating point values should be in the processor's native byte order. dt_double and dt_qword values take up 8 bytes (value and addr fields for 32-bit modules). NB: in case a dt_dword/dt_qword immediate is forced to float by user, the kernel converts it to processor's native order before calling FP conversion routines.

var value64 : uint64

get_value64(self) -> uint64

Methods

def assign(self, other: op_t)

assign(self, other)

@param other: op_t const &

def clr_shown(self)

clr_shown(self) Set operand to hidden.

def has_reg(self, r)

Checks if the operand accesses the given processor register

def is_imm(self, v: uval_t)

is_imm(self, v) -> bool Is immediate operand?

@param v: (C++: uval_t)

def is_reg(self, r: int) ‑> bool

is_reg(self, r) -> bool Is register operand?

@param r: (C++: int)

def set_shown(self)

set_shown(self) Set operand to be shown.

def shown(self) ‑> bool

shown(self) -> bool Is operand set to be shown?

class operands_array (data: op_t (&)[8])

Proxy of C++ wrapped_array_t< op_t,8 > class.

init(self, data) -> operands_array

@param data: op_t (&)[8]

Instance variables

var bytes : bytevec_t

_get_bytes(self) -> bytevec_t

var dataop_t (&)[8]

data

var thisown

The membership flag

class outctx_base_t (*args, **kwargs)

Proxy of C++ outctx_base_t class.

Subclasses

Instance variables

var F32 : flags_t

please use outctx_t::F instead

var default_lnnum : int

index of the most important line in lnar

var insn_ea : ea_t

insn_ea

var outbuf : qstring

buffer for the current output line once ready, it is moved to lnar

var thisown

The membership flag

Methods

def close_comment(self)

close_comment(self)

def clr_gen_label(self)

clr_gen_label(self)

def display_voids(self) ‑> bool

display_voids(self) -> bool

def flush_buf(self, buf: char const *, indent: int = -1)

flush_buf(self, buf, indent=-1) -> bool Append contents of 'buf' to the line array. Behaves like flush_outbuf but accepts an arbitrary buffer

@param buf: (C++: const char *) char const * @param indent: (C++: int)

def flush_outbuf(self, indent: int = -1) ‑> bool

flush_outbuf(self, indent=-1) -> bool Functions to populate the output line array (lnar) Move the contents of the output buffer to the line array (outbuf->lnar) The kernel augments the outbuf contents with additional text like the line prefix, user-defined comments, xrefs, etc at this call.

@param indent: (C++: int)

def forbid_annotations(self) ‑> int

forbid_annotations(self) -> int

def force_code(self) ‑> bool

force_code(self) -> bool

def gen_block_cmt(self, cmt: char const *, color: color_t)

gen_block_cmt(self, cmt, color) -> bool Generate big non-indented comment lines.

@param cmt: (C++: const char *) comment text. may contain \n characters to denote new lines. should not contain comment character (;) @param color: (C++: color_t) color of comment text (one of Color tags) @return: overflow, lnar_maxsize has been reached

def gen_border_line(self, solid: bool = False) ‑> bool

gen_border_line(self, solid=False) -> bool Generate thin border line. This function does nothing if generation of border lines is disabled.

@param solid: (C++: bool) generate solid border line (with =), otherwise with - @return: overflow, lnar_maxsize has been reached

def gen_cmt_line(self, format: char const *)

gen_cmt_line(self, format) -> bool Generate one non-indented comment line, colored with COLOR_AUTOCMT.

@param format: (C++: const char *) printf() style format line. The resulting comment line should not include comment character (;) @return: overflow, lnar_maxsize has been reached

def gen_collapsed_line(self, format: char const *)

gen_collapsed_line(self, format) -> bool Generate one non-indented comment line, colored with COLOR_COLLAPSED.

@param format: (C++: const char *) printf() style format line. The resulting comment line should not include comment character (;) @return: overflow, lnar_maxsize has been reached

def gen_empty_line(self) ‑> bool

gen_empty_line(self) -> bool Generate empty line. This function does nothing if generation of empty lines is disabled.

@return: overflow, lnar_maxsize has been reached

def gen_empty_line_without_annotations(self)

gen_empty_line_without_annotations(self)

def gen_printf(self, indent: int, format: char const *)

gen_printf(self, indent, format) -> bool printf-like function to add lines to the line array.

@param indent: (C++: int) indention of the line. if indent == -1, the kernel will indent the line at idainfo::indent. if indent < 0, -indent will be used for indention. The first line printed with indent < 0 is considered as the most important line at the current address. Usually it is the line with the instruction itself. This line will be displayed in the cross-reference lists and other places. If you need to output an additional line before the main line then pass DEFAULT_INDENT instead of -1. The kernel will know that your line is not the most important one. @param format: (C++: const char *) printf style colored line to generate @return: overflow, lnar_maxsize has been reached

def gen_xref_lines(self) ‑> bool

gen_xref_lines(self) -> bool

def getF(self)

getF(self) -> flags64_t

def get_stkvar(self, x: op_t, v: uval_t, vv: sval_t *, is_sp_based: int *, _frame: tinfo_t)

get_stkvar(self, x, v, vv, is_sp_based, _frame) -> ssize_t

@param x: op_t const & @param v: uval_t @param vv: sval_t * @param is_sp_based: int * @param _frame: tinfo_t *

def init_lines_array(self, answers: qstrvec_t *, maxsize: int)

init_lines_array(self, answers, maxsize)

@param answers: qstrvec_t * @param maxsize: int

def multiline(self) ‑> bool

multiline(self) -> bool

def only_main_line(self) ‑> bool

only_main_line(self) -> bool

def out_addr_tag(self, ea: ea_t)

out_addr_tag(self, ea) Output "address" escape sequence.

@param ea: (C++: ea_t)

def out_btoa(self, Word: uval_t, radix: char = 0)

out_btoa(self, Word, radix=0) Output a number with the specified base (binary, octal, decimal, hex) The number is output without color codes. see also out_long()

@param Word: (C++: uval_t) @param radix: (C++: char)

def out_char(self, c: char)

out_char(self, c) Output one character. The character is output without color codes. see also out_symbol()

@param c: (C++: char)

def out_chars(self, c: char, n: int)

out_chars(self, c, n) Append a character multiple times.

@param c: (C++: char) @param n: (C++: int)

def out_colored_register_line(self, str: char const *)

out_colored_register_line(self, str) Output a colored line with register names in it. The register names will be substituted by user-defined names (regvar_t) Please note that out_tagoff tries to make substitutions too (when called with COLOR_REG)

@param str: (C++: const char *) char const *

def out_keyword(self, str: char const *)

out_keyword(self, str) Output a string with COLOR_KEYWORD color.

@param str: (C++: const char *) char const *

def out_line(self, str: char const *, color: color_t = 0)

out_line(self, str, color=0) Output a string with the specified color.

@param str: (C++: const char *) char const * @param color: (C++: color_t)

def out_long(self, v: sval_t, radix: char)

out_long(self, v, radix) Output a number with appropriate color. Low level function. Use out_value() if you can. if 'suspop' is set then this function uses COLOR_VOIDOP instead of COLOR_NUMBER. 'suspop' is initialized: * in out_one_operand() * in ..\ida\gl.cpp (before calling processor_t::d_out())

@param v: (C++: sval_t) value to output @param radix: (C++: char) base (2,8,10,16)

def out_name_expr(self, *args) ‑> bool

out_name_expr(self, x, ea, off=BADADDR) -> bool Output a name expression.

@param x: (C++: const op_t &) instruction operand referencing the name expression @param ea: (C++: ea_t) address to convert to name expression @param off: (C++: adiff_t) the value of name expression. this parameter is used only to check that the name expression will have the wanted value. You may pass BADADDR for this parameter but I discourage it because it prohibits checks. @return: true if the name expression has been produced

def out_printf(self, format: char const *)

out_printf(self, format) -> size_t Functions to append text to the current output buffer (outbuf) Append a formatted string to the output string.

@param format: (C++: const char *) char const * @return: the number of characters appended

def out_register(self, str: char const *)

out_register(self, str) Output a character with COLOR_REG color.

@param str: (C++: const char *) char const *

def out_spaces(self, len: ssize_t)

out_spaces(self, len) Appends spaces to outbuf until its tag_strlen becomes 'len'.

@param len: (C++: ssize_t)

def out_symbol(self, c: char)

out_symbol(self, c) Output a character with COLOR_SYMBOL color.

@param c: (C++: char)

def out_tagoff(self, tag: color_t)

out_tagoff(self, tag) Output "turn color off" escape sequence.

@param tag: (C++: color_t)

def out_tagon(self, tag: color_t)

out_tagon(self, tag) Output "turn color on" escape sequence.

@param tag: (C++: color_t)

def out_value(self, x: op_t, outf: int = 0)

out_value(self, x, outf=0) -> flags64_t Output immediate value. Try to use this function to output all constants of instruction operands. This function outputs a number from x.addr or x.value in the form determined by F. It outputs colored text.

@param x: (C++: const op_t &) value to output @param outf: (C++: int) Output value flags @return: flags of the output value, otherwise: -1 if printed a number with COLOR_ERROR 0 if printed a nice number or character or segment or enum

def print_label_now(self) ‑> bool

print_label_now(self) -> bool

def restore_ctxflags(self, saved_flags: int)

restore_ctxflags(self, saved_flags)

@param saved_flags: int

def retrieve_cmt(self)

retrieve_cmt(self) -> ssize_t

def retrieve_name(self, arg2: qstring *, arg3: color_t *)

retrieve_name(self, arg2, arg3) -> ssize_t

@param arg2: qstring * @param arg3: color_t *

def set_comment_addr(self, ea: ea_t)

set_comment_addr(self, ea)

@param ea: ea_t

def set_dlbind_opnd(self)

set_dlbind_opnd(self)

def set_gen_cmt(self, on: bool = True)

set_gen_cmt(self, on=True)

@param on: bool

def set_gen_demangled_label(self)

set_gen_demangled_label(self)

def set_gen_label(self)

set_gen_label(self)

def set_gen_xrefs(self, on: bool = True)

set_gen_xrefs(self, on=True)

@param on: bool

def setup_outctx(self, prefix: char const *, makeline_flags: int)

setup_outctx(self, prefix, makeline_flags) Initialization; normally used only by the kernel.

@param prefix: (C++: const char *) char const * @param makeline_flags: (C++: int)

def stack_view(self) ‑> bool

stack_view(self) -> bool

def term_outctx(self, prefix: char const * = None)

term_outctx(self, prefix=None) -> int Finalize the output context.

@param prefix: (C++: const char *) char const * @return: the number of generated lines.

class outctx_t (*args, **kwargs)

Proxy of C++ outctx_t class.

Ancestors

Instance variables

var ash : asm_t &

ash

var bin_ea : ea_t

bin_ea

var bin_state : char

bin_state

var bin_width : int

bin_width

var curlabel : qstring

curlabel

var gl_bpsize : int

gl_bpsize

var insninsn_t

insn

var next_line_ea : ea_t

next_line_ea

var ph : processor_t &

ph

var prefix_ea : ea_t

prefix_ea

var procmod : procmod_t *

procmod

var saved_immvals : uval_t [8]

saved_immvals

var wif : printop_t const *

wif

Methods

gen_func_footer(self, pfn)

@param pfn: func_t const *

def gen_func_header(self, pfn: func_t *)

gen_func_header(self, pfn)

@param pfn: func_t *

def gen_header(self, *args)

gen_header(self, flags=((1 << 0)|(1 << 1)), proc_name=None, proc_flavour=None)

@param flags: int @param proc_name: char const * @param proc_flavour: char const *

def gen_header_extra(self)

gen_header_extra(self)

def out_custom_mnem(self, mnem: char const *, width: int = 8, postfix: char const * = None)

out_custom_mnem(self, mnem, width=8, postfix=None) Output custom mnemonic for 'insn'. E.g. if it should differ from the one in 'ph.instruc'. This function outputs colored text. See out_mnem

@param mnem: (C++: const char ) custom mnemonic @param width: (C++: int) width of field with mnemonic. if < 0, then 'postfix' will be output before the mnemonic, i.e. as a prefix @param postfix: (C++: const char ) optional postfix added to 'mnem'

def out_data(self, analyze_only: bool)

out_data(self, analyze_only)

@param analyze_only: bool

def out_fcref_names(self)

out_fcref_names(self) Print addresses referenced from the specified address as commented symbolic names. This function is used to show, for example, multiple callees of an indirect call. This function outputs colored text.

def out_immchar_cmts(self)

out_immchar_cmts(self) Print all operand values as commented character constants. This function is used to comment void operands with their representation in the form of character constants. This function outputs colored text.

def out_mnem(self, width: int = 8, postfix: char const * = None)

out_mnem(self, width=8, postfix=None) Output instruction mnemonic for 'insn' using information in 'ph.instruc' array. This function outputs colored text. It should be called from processor_t::ev_out_insn() or processor_t::ev_out_mnem() handler. It will output at least one space after the instruction. mnemonic even if the specified 'width' is not enough.

@param width: (C++: int) width of field with mnemonic. if < 0, then 'postfix' will be output before the mnemonic, i.e. as a prefix @param postfix: (C++: const char *) optional postfix added to the instruction mnemonic

def out_mnemonic(self)

out_mnemonic(self) Output instruction mnemonic using information in 'insn'. It should be called from processor_t::ev_out_insn() and it will call processor_t::ev_out_mnem() or out_mnem. This function outputs colored text.

def out_one_operand(self, n: int) ‑> bool

out_one_operand(self, n) -> bool Use this function to output an operand of an instruction. This function checks for the existence of a manually defined operand and will output it if it exists. It should be called from processor_t::ev_out_insn() and it will call processor_t::ev_out_operand(). This function outputs colored text.

@param n: (C++: int) 0..UA_MAXOP-1 operand number @retval 1: operand is displayed @retval 0: operand is hidden

def out_specea(self, segtype: uchar)

out_specea(self, segtype) -> bool

@param segtype: uchar

def set_bin_state(self, value: int)

set_bin_state(self, value)

@param value: int

def setup_outctx(self, prefix: char const *, flags: int)

setup_outctx(self, prefix, flags) Initialization; normally used only by the kernel.

@param prefix: (C++: const char *) char const * @param flags: int

Inherited members