IDA SDK

- Main Page
- Header Files
- Classes
- Modules

Modules | Functions | Variables
Output helpers

## Detailed Description

Functions to help display instruction information.

All output functions use cmd structure to get information.

## Modules
| Output value flags
| Flags passed to OutValue() and get_immval().

## Functions
idaman void ida_export | init_output_buffer (char *buf, size_t bufsize)
| Initialize output buffer. More...
idaman char *ida_export | term_output_buffer (void)
| Terminate output buffer. More...
idaman int ida_export | out_snprintf (const char *format,...)
| Append a formatted string to the output string. More...
idaman char *ida_export | set_output_ptr (char *ptr)
| Set the pointer to the output buffer. More...
char *idaapi | get_output_ptr (void)
| Get pointer to the output buffer.
idaman void ida_export | out_insert (char *ptr, const char *string)
| Insert a string into the output string. More...
idaman int ida_export | OutMnem (int width=8, const char *postfix=NULL)
| Output instruction mnemonics using information in cmd. More...
idaman void ida_export | OutBadInstruction (void)
| Output instruction as a sequence of bytes, followed by a comment character and instruction mnemonics. More...
idaman bool ida_export | out_one_operand (int n)
| Use this function to output an operand of an instruction. More...
idaman flags_t ida_export | OutValue (const op_t &x, int outflags=0)
| Output immediate value. More...
uval_t | get_immval (const op_t &x, int outf=0, bool extend_sign=false, char *dtyp_ptr=NULL, size_t *nbytes_ptr=NULL)
| Extract immediate value from the operand according to the specified flags. More...
idaman void ida_export | out_symbol (char c)
| Output a character with COLOR_SYMBOL color.
idaman void ida_export | out_line (const char *str, color_t color)
| Output a string with the specified color.
void | out_keyword (const char *str)
| Output a string with COLOR_KEYWORD color.
void | out_register (const char *str)
| Output a character with COLOR_REG color.
idaman void ida_export | out_tagon (color_t tag)
| Output "turn color on" escape sequence.
idaman void ida_export | out_tagoff (color_t tag)
| Output "turn color off" escape sequence.
idaman void ida_export | out_addr_tag (ea_t ea)
| Output "address" escape sequence.
idaman void ida_export | out_colored_register_line (const char *str)
| Output a colored line with register names in it. More...
idaman void ida_export | OutLine (const char *s)
| Output plain text without color codes. More...
idaman void ida_export | OutChar (char c)
| Output one character. More...
idaman void ida_export | OutLong (uval_t Word, char radix)
| Output a number with the specified base (binary, octal, decimal, hex) The number is output without color codes. More...
idaman void ida_export | OutImmChar (const op_t &x)
| Output operand value as a commented character constant. More...
idaman bool ida_export | showAsChar (const void *ptr, char *buf, int size)
| Try to display value as a character constant. More...
idaman bool ida_export | out_real (const void *v, int size, char *buf, size_t bufsize)
| Output a floating point value. More...
idaman void ida_export | out_long (sval_t v, char radix)
| Output a number with appropriate color. More...
idaman bool ida_export | out_name_expr (const op_t &x, ea_t ea, adiff_t off=BADADDR)
| Output a name expression. More...

## Variables
idaman int ida_export_data | voidop
| see out_long()

## Function Documentation

idaman void ida_export init_output_buffer | ( | char * | buf,
|  | size_t | bufsize
| ) |  |

Initialize output buffer.

Must be called before using any out/Out functions.

idaman char* ida_export term_output_buffer | ( | void |  | ) |

Terminate output buffer.

Must be called after using all out/Out functions to form the output string.

Returns
  pointer to the end of the output string.

idaman int ida_export out_snprintf | ( | const char * | format,
|  |  | ...
| ) |  |

Append a formatted string to the output string.

Returns
  the number of characters appended

idaman char* ida_export set_output_ptr | ( | char * | ptr | ) |

Set the pointer to the output buffer.

Parameters

  ptr | if NULL, the pointer value is not changed (essentially this function becomes get_output_ptr() in this case)

Returns
  the old value of the pointer

idaman void ida_export out_insert | ( | char * | ptr,
|  | const char * | string
| ) |  |

Insert a string into the output string.

Parameters

  ptr | place to insert to. should come from get_output_ptr()
  string | string to insert

idaman int ida_export OutMnem | ( | int | width = `8`,
|  | const char * | postfix = `NULL`
| ) |  |

Output instruction mnemonics using information in cmd.

This function outputs a colored text. It will output at least one space after the instruction mnemonics even if the specified 'width' is not enough.

Parameters

  width | width of field with mnemonics. if < 0, then 'postfix' will be output before the mnemonics, i.e. as a prefix
  postfix | optional postfix added to the instruction mnemonics

Return values

  0 | displayed as bytes
  1 | displayed as instruction

idaman void ida_export OutBadInstruction | ( | void |  | ) |

Output instruction as a sequence of bytes, followed by a comment character and instruction mnemonics.

This function is used to display undocumented instructions or instructions that are improperly handled by the target assembler. OutMnem() calls this function if the current instruction is present in the array of bad instructions ( asm_t::badworks). This function outputs a colored text.

idaman bool ida_export out_one_operand | ( | int | n | ) |

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. Otherwise it will call processor_t::u_outop() to output operand. This function outputs a colored text.

Parameters

  n | number of operand

Return values

  1 | operand is displayed
  0 | operand is hidden

idaman flags_t ida_export OutValue | ( | const op_t & | x,
|  | int | outflags = `0`
| ) |  |

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 uFlag. It outputs a colored text.

- -1 is output with COLOR_ERROR
- 0 is output as a number or character or segment
  Parameters

    x | value to output
    outflags | Output value flags

  Returns
    flags of the output value

uval_t get_immval | ( | const op_t & | x,
|  | int | outf = `0`,
|  | bool | extend_sign = `false`,
|  | char * | dtyp_ptr = `NULL`,
|  | size_t * | nbytes_ptr = `NULL`
| ) |  |

Extract immediate value from the operand according to the specified flags.

This is an internal function. Use get_operand_immvals() instead

Parameters

  | x | operand
  | outf | Output value flags
  | extend_sign | should the sign be extended?
  [out] | dtyp_ptr | pointer to the dtyp which will be filled by this function
  [out] | nbytes_ptr | pointer to the 'nbytes' which will be filled by this function - number of bytes required to store the value

idaman void ida_export out_colored_register_line | ( | const char * | 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)

idaman void ida_export OutLine | ( | const char * | s | ) |

Output plain text without color codes.

see also out_line()

idaman void ida_export OutChar | ( | char | c | ) |

Output one character.

The character is output without color codes. see also out_symbol()

idaman void ida_export OutLong | ( | uval_t | Word,
|  | char | radix
| ) |  |

Output a number with the specified base (binary, octal, decimal, hex) The number is output without color codes.

see also out_long()

idaman void ida_export OutImmChar | ( | const op_t & | x | ) |

Output operand value as a commented character constant.

This function is used to comment void operands with their representation in the form of character constants. This function outputs a colored text.

idaman bool ida_export showAsChar | ( | const void * | ptr,
|  | char * | buf,
|  | int | size
| ) |  |

Try to display value as a character constant.

This is low level function, it is called from OutValue(). This function outputs uncolored text.

Parameters

  ptr | pointer to value to convert
  buf | output buffer
  size | size of input value in bytes

Return values

  1 | ok, the buffer contains character constant. its form depends on asm_t::flags.
  0 | failed, probably the constant is invalid for the target assembler

idaman bool ida_export out_real | ( | const void * | v,
|  | int | size,
|  | char * | buf,
|  | size_t | bufsize
| ) |  |

Output a floating point value.

Low level function. Use OutValue() if you can. This function outputs uncolored text.

Parameters

  v | floating point value in processor native format
  size | size of the value in bytes
  buf | output buffer. may be NULL
  bufsize | size of the output buffer

Returns
  true ok
  false can't represent as floating point number

void out_long | ( | sval_t | v,
|  | char | radix
| ) |  |

Output a number with appropriate color.

Low level function. Use OutValue() if you can. if 'voidop' is set then this function uses COLOR_VOIDOP instead of COLOR_NUMBER. 'voidop' is initialized:

- in out_one_operand()
- in ...cpp (before calling processor_t::d_out())
  Parameters

    v | value to output
    radix | base (2,8,10,16)
    voidop | voidop voidop==0: operand is ok voidop==1: operand is void and should be output with COLOR_VOIDOP voidop==2: operand can't be output as requested and should be output with COLOR_ERROR

idaman bool ida_export out_name_expr | ( | const op_t & | x,
|  | ea_t | ea,
|  | adiff_t | off = `BADADDR`
| ) |  |

Output a name expression.

Parameters

  x | instruction operand referencing the name expression
  ea | address to convert to name expression
  off | 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.

Returns
  true if the name expression has been produced