IDA C++ SDK 9.2
Loading...
Searching...
No Matches
Instruction/Data operands

Represent instruction/data operands. More...

Topics

 Functions: examine operand flags (specific operands)
 Functions: examine operand flags (arbitrary operand)
 Functions: get type information bits for flags
 Functions: set operand representation
 Bits: data bytes
 Functions: examine data bits
 Functions: manipulate data bits

Functions

constexpr int get_operand_type_shift (uint32 n)
 Get the shift in flags64_t for the nibble representing operand n's type.
constexpr flags64_t get_operand_flag (uint8 typebits, int n)
 Place operand n's type flag in the right nibble of a 64-bit flags set.
constexpr bool is_flag_for_operand (flags64_t F, uint8 typebits, int n)
 Check that the 64-bit flags set has the expected type for operand n.
idaman bool ida_export op_adds_xrefs (flags64_t F, int n)
 Should processor module create xrefs from the operand?
idaman bool ida_export set_op_type (ea_t ea, flags64_t type, int n)
 (internal function) change representation of operand(s).
idaman bool ida_export op_seg (ea_t ea, int n)
 Set operand representation to be 'segment'.
idaman bool ida_export op_enum (ea_t ea, int n, tid_t id, uchar serial=0)
 Set operand representation to be enum type If applied to unexplored bytes, converts them to 16/32bit word data.
idaman tid_t ida_export get_enum_id (uchar *serial, ea_t ea, int n)
 Get enum id of 'enum' operand.
idaman bool ida_export op_stroff (const insn_t &insn, int n, const tid_t *path, int path_len, adiff_t delta)
 Set operand representation to be 'struct offset'.
idaman bool ida_export op_based_stroff (const insn_t &insn, int n, adiff_t opval, ea_t base)
 Set operand representation to be 'struct offset' if the operand likely points to a structure member.
idaman int ida_export get_stroff_path (tid_t *path, adiff_t *delta, ea_t ea, int n)
 Get struct path of operand.
idaman bool ida_export op_stkvar (ea_t ea, int n)
 Set operand representation to be 'stack variable'.
idaman bool ida_export set_forced_operand (ea_t ea, int n, const char *op)
 Set forced operand.
idaman ssize_t ida_export get_forced_operand (qstring *buf, ea_t ea, int n)
 Get forced operand.
idaman bool ida_export is_forced_operand (ea_t ea, int n)
 Is operand manually defined?
constexpr flags64_t idaapi combine_flags (flags64_t F)
idaman bool ida_export op_custfmt (ea_t ea, int n, int fid)
 Set custom data format for operand (fid-custom data format id)
idaman bool ida_export clr_op_type (ea_t ea, int n)
 Remove operand representation information.
idaman int ida_export get_default_radix (void)
 Get default base of number for the current processor.
idaman int ida_export get_radix (flags64_t F, int n)
 Get radix of the operand, in: flags.

Detailed Description

Represent instruction/data operands.

IDA keeps bitmask representations for a maximum of 8 operands:

For data bytes, only the first bitmask is used (i.e. all elements of an array have the same type).

Function Documentation

◆ get_operand_type_shift()

int get_operand_type_shift ( uint32 n)
inlineconstexpr

Get the shift in flags64_t for the nibble representing operand n's type.

Note: n must be < UA_MAXOP, and is not checked

Parameters
nthe operand number
Returns
the shift to the nibble

◆ get_operand_flag()

flags64_t get_operand_flag ( uint8 typebits,
int n )
inlineconstexpr

Place operand n's type flag in the right nibble of a 64-bit flags set.

Parameters
typebitsthe type bits (one of FF_N_)
nthe operand number
Returns
the shift to the nibble

◆ is_flag_for_operand()

bool is_flag_for_operand ( flags64_t F,
uint8 typebits,
int n )
inlineconstexpr

Check that the 64-bit flags set has the expected type for operand n.

Parameters
Fthe flags
typebitsthe type bits (one of FF_N_)
nthe operand number
Returns
success

◆ op_adds_xrefs()

idaman bool ida_export op_adds_xrefs ( flags64_t F,
int n )

Should processor module create xrefs from the operand?

Currently 'offset', 'structure offset', 'stack' and 'enum' operands create xrefs

◆ set_op_type()

idaman bool ida_export set_op_type ( ea_t ea,
flags64_t type,
int n )

(internal function) change representation of operand(s).

Parameters
ealinear address
typenew flag value (should be obtained from char_flag(), num_flag() and similar functions)
n0..#UA_MAXOP-1 operand number, OPND_ALL all operands
Return values
1ok
0failed (applied to a tail byte)

◆ op_seg()

idaman bool ida_export op_seg ( ea_t ea,
int n )

Set operand representation to be 'segment'.

If applied to unexplored bytes, converts them to 16/32bit word data

Parameters
ealinear address
n0..#UA_MAXOP-1 operand number, OPND_ALL all operands
Returns
success

◆ op_enum()

idaman bool ida_export op_enum ( ea_t ea,
int n,
tid_t id,
uchar serial = 0 )

Set operand representation to be enum type If applied to unexplored bytes, converts them to 16/32bit word data.

Parameters
ealinear address
n0..#UA_MAXOP-1 operand number, OPND_ALL all operands
idid of enum
serialthe serial number of the constant in the enumeration, usually 0. the serial numbers are used if the enumeration contains several constants with the same value
Returns
success

◆ get_enum_id()

idaman tid_t ida_export get_enum_id ( uchar * serial,
ea_t ea,
int n )

Get enum id of 'enum' operand.

Parameters
ealinear address
n0..#UA_MAXOP-1 operand number, OPND_ALL one of the operands
serialpointer to variable to hold the serial number of the constant in the enumeration
Returns
id of enum or #BADNODE

◆ op_stroff()

idaman bool ida_export op_stroff ( const insn_t & insn,
int n,
const tid_t * path,
int path_len,
adiff_t delta )

Set operand representation to be 'struct offset'.

Parameters
insnthe instruction
n0..#UA_MAXOP-1 operand number, OPND_ALL all operands
pathstructure path (strpath). see nalt.hpp for more info.
path_lenlength of the structure path
deltastruct offset delta. usually 0. denotes the difference between the structure base and the pointer into the structure.
Returns
success

◆ op_based_stroff()

idaman bool ida_export op_based_stroff ( const insn_t & insn,
int n,
adiff_t opval,
ea_t base )

Set operand representation to be 'struct offset' if the operand likely points to a structure member.

For example, let's there is a structure at 1000 1000 stru_1000 Elf32_Sym <...> the operand #8 will be represented as '#Elf32_Sym.st_size' after the call of 'op_based_stroff(..., 8, 0x1000)' By the way, after the call of 'op_plain_offset(..., 0x1000)' it will be represented as '#(stru_1000.st_size - 0x1000)'

Parameters
insnthe instruction
n0..#UA_MAXOP-1 operand number, OPND_ALL all operands
opvaloperand value (usually op_t::value or op_t::addr)
basebase reference
Returns
success

◆ get_stroff_path()

idaman int ida_export get_stroff_path ( tid_t * path,
adiff_t * delta,
ea_t ea,
int n )

Get struct path of operand.

Parameters
pathbuffer for structure path (strpath). see nalt.hpp for more info.
deltastruct offset delta
ealinear address
n0..#UA_MAXOP-1 operand number, OPND_ALL one of the operands
Returns
length of strpath

◆ op_stkvar()

idaman bool ida_export op_stkvar ( ea_t ea,
int n )

Set operand representation to be 'stack variable'.

Should be applied to an instruction within a function. Should be applied after creating a stack var using insn_t::create_stkvar().

Parameters
ealinear address
n0..#UA_MAXOP-1 operand number, OPND_ALL all operands
Returns
success

◆ set_forced_operand()

idaman bool ida_export set_forced_operand ( ea_t ea,
int n,
const char * op )

Set forced operand.

Parameters
ealinear address
n0..#UA_MAXOP-1 operand number
optext of operand
  • nullptr: do nothing (return 0)
  • "" : delete forced operand
Returns
success

◆ get_forced_operand()

idaman ssize_t ida_export get_forced_operand ( qstring * buf,
ea_t ea,
int n )

Get forced operand.

Parameters
bufoutput buffer, may be nullptr
ealinear address
n0..#UA_MAXOP-1 operand number
Returns
size of forced operand or -1

◆ is_forced_operand()

idaman bool ida_export is_forced_operand ( ea_t ea,
int n )

Is operand manually defined?

Parameters
ealinear address
n0..#UA_MAXOP-1 operand number

◆ combine_flags()

flags64_t idaapi combine_flags ( flags64_t F)
inlineconstexpr

◆ op_custfmt()

idaman bool ida_export op_custfmt ( ea_t ea,
int n,
int fid )

Set custom data format for operand (fid-custom data format id)

◆ clr_op_type()

idaman bool ida_export clr_op_type ( ea_t ea,
int n )

Remove operand representation information.

(set operand representation to be 'undefined')

Parameters
ealinear address
n0..#UA_MAXOP-1 operand number, OPND_ALL all operands
Returns
success

◆ get_default_radix()

idaman int ida_export get_default_radix ( void )

Get default base of number for the current processor.

Returns
2, 8, 10, 16

◆ get_radix()

idaman int ida_export get_radix ( flags64_t F,
int n )

Get radix of the operand, in: flags.

If the operand is not a number, returns get_default_radix()

Parameters
Fflags
nnumber of operand (0, 1, -1)
Returns
2, 8, 10, 16