Module index

Module ida_lines

High level functions that deal with the generation of the disassembled text lines.
This file also contains definitions for the syntax highlighting.
Finally there are functions that deal with anterior/posterior user-defined lines.

Global variables

var COLOR_ADDR
hidden address marks. the address is represented as 8digit hex number: 01234567. it doesn't have COLOR_OFF pair. NB: for 64-bit IDA, the address is 16digit.
var COLOR_ADDR_SIZE
Size of a tagged address (see COLOR_ADDR)
var COLOR_ALTOP
Alternative operand.
var COLOR_ASMDIR
Assembler directive.
var COLOR_AUTOCMT
Automatic comment.
var COLOR_BG_MAX
Max color number.
var COLOR_BINPREF
Binary line prefix bytes.
var COLOR_CHAR
Char constant in instruction.
var COLOR_CNAME
Regular code name.
var COLOR_CODE
Single instruction.
var COLOR_CODNAME
Dummy code name.
var COLOR_COLLAPSED
Collapsed line.
var COLOR_CREF
Code reference.
var COLOR_CREFTAIL
Code reference to tail byte.
var COLOR_CURITEM
Current item.
var COLOR_CURLINE
Current line.
var COLOR_DATA
Data bytes.
var COLOR_DATNAME
Dummy Data Name.
var COLOR_DCHAR
Char constant in data directive.
var COLOR_DEFAULT
Default.
var COLOR_DEMNAME
Demangled Name.
var COLOR_DNAME
Regular Data Name.
var COLOR_DNUM
Numeric constant in data directive.
var COLOR_DREF
Data reference.
var COLOR_DREFTAIL
Data reference to tail byte.
var COLOR_DSTR
String constant in data directive.
var COLOR_ERROR
Error or problem.
var COLOR_ESC
Escape character (Quote next character). This is needed to output '\1' and '\2' characters.
var COLOR_EXTERN
External name definition segment.
var COLOR_EXTRA
Extra line.
var COLOR_FG_MAX
Max color number.
var COLOR_HIDLINE
Hidden line.
var COLOR_HIDNAME
Hidden name.
var COLOR_IMPNAME
Imported name.
var COLOR_INSN
Instruction.
var COLOR_INV
Escape character (Inverse foreground and background colors). This escape character has no corresponding COLOR_OFF. Its action continues until the next COLOR_INV or end of line.
var COLOR_KEYWORD
Keywords.
var COLOR_LIBFUNC
Library function.
var COLOR_LIBNAME
Library function name.
var COLOR_LOCNAME
Local variable name.
var COLOR_LUMFUNC
Lumina function.
var COLOR_LUMINA
Lumina-related, only for the navigation band.
var COLOR_MACRO
Macro.
var COLOR_NUMBER
Numeric constant in instruction.
var COLOR_OFF
Escape character (OFF). Followed by a color code (color_t).
var COLOR_ON
Escape character (ON). Followed by a color code (color_t).
var COLOR_OPND1
Instruction operand 1.
var COLOR_OPND2
Instruction operand 2.
var COLOR_OPND3
Instruction operand 3.
var COLOR_OPND4
Instruction operand 4.
var COLOR_OPND5
Instruction operand 5.
var COLOR_OPND6
Instruction operand 6.
var COLOR_OPND7
Instruction operand 7.
var COLOR_OPND8
Instruction operand 8.
var COLOR_PREFIX
Line prefix.
var COLOR_REG
Register name.
var COLOR_REGCMT
Regular comment.
var COLOR_REGFUNC
Regular function.
var COLOR_RESERVED1
This tag is reserved for internal IDA use.
var COLOR_RPTCMT
Repeatable comment (comment defined somewhere else)
var COLOR_SEGNAME
Segment name.
var COLOR_SELECTED
Selected.
var COLOR_STRING
String constant in instruction.
var COLOR_SYMBOL
Punctuation.
var COLOR_UNAME
Regular unknown name.
var COLOR_UNKNAME
Dummy unknown name.
var COLOR_UNKNOWN
Unexplored byte.
var COLOR_VOIDOP
Void operand.
var E_NEXT
E_NEXT = 2000
var E_PREV
E_PREV = 1000
var GDISMF_ADDR_TAG
GDISMF_ADDR_TAG = 2
var GDISMF_AS_STACK
GDISMF_AS_STACK = 1
var GENDSM_FORCE_CODE
GENDSM_FORCE_CODE = 1
var GENDSM_MULTI_LINE
GENDSM_MULTI_LINE = 2
var GENDSM_REMOVE_TAGS
GENDSM_REMOVE_TAGS = 4
var PALETTE_SIZE
PALETTE_SIZE = 53
var SCOLOR_ADDR
Hidden address mark.
var SCOLOR_ALTOP
Alternative operand.
var SCOLOR_ASMDIR
Assembler directive.
var SCOLOR_AUTOCMT
Automatic comment.
var SCOLOR_BINPREF
Binary line prefix bytes.
var SCOLOR_CHAR
Char constant in instruction.
var SCOLOR_CNAME
Regular code name.
var SCOLOR_CODNAME
Dummy code name.
var SCOLOR_COLLAPSED
Collapsed line.
var SCOLOR_CREF
Code reference.
var SCOLOR_CREFTAIL
Code reference to tail byte.
var SCOLOR_DATNAME
Dummy Data Name.
var SCOLOR_DCHAR
Char constant in data directive.
var SCOLOR_DEFAULT
Default.
var SCOLOR_DEMNAME
Demangled Name.
var SCOLOR_DNAME
Regular Data Name.
var SCOLOR_DNUM
Numeric constant in data directive.
var SCOLOR_DREF
Data reference.
var SCOLOR_DREFTAIL
Data reference to tail byte.
var SCOLOR_DSTR
String constant in data directive.
var SCOLOR_ERROR
Error or problem.
var SCOLOR_ESC
Escape character (Quote next character)
var SCOLOR_EXTRA
Extra line.
var SCOLOR_FG_MAX
SCOLOR_FG_MAX = '('
var SCOLOR_HIDNAME
Hidden name.
var SCOLOR_IMPNAME
Imported name.
var SCOLOR_INSN
Instruction.
var SCOLOR_INV
Escape character (Inverse colors)
var SCOLOR_KEYWORD
Keywords.
var SCOLOR_LIBNAME
Library function name.
var SCOLOR_LOCNAME
Local variable name.
var SCOLOR_MACRO
Macro.
var SCOLOR_NUMBER
Numeric constant in instruction.
var SCOLOR_OFF
Escape character (OFF)
var SCOLOR_ON
Escape character (ON)
var SCOLOR_OPND1
SCOLOR_OPND1 = ')'
var SCOLOR_OPND2
SCOLOR_OPND2 = '*'
var SCOLOR_OPND3
SCOLOR_OPND3 = '+'
var SCOLOR_OPND4
SCOLOR_OPND4 = ','
var SCOLOR_OPND5
SCOLOR_OPND5 = '-'
var SCOLOR_OPND6
SCOLOR_OPND6 = '.'
var SCOLOR_PREFIX
Line prefix.
var SCOLOR_REG
Register name.
var SCOLOR_REGCMT
Regular comment.
var SCOLOR_RPTCMT
Repeatable comment (defined not here)
var SCOLOR_SEGNAME
Segment name.
var SCOLOR_STRING
String constant in instruction.
var SCOLOR_SYMBOL
Punctuation.
var SCOLOR_UNAME
Regular unknown name.
var SCOLOR_UNKNAME
Dummy unknown name.
var SCOLOR_UTF8
SCOLOR_UTF8 = '2'
var SCOLOR_VOIDOP
Void operand.
var VEL_CMT
VEL_CMT = 2
var VEL_POST
VEL_POST = 1

Functions

def COLSTR(str, tag)
Utility function to create a colored line
str: The string
tag: Color tag constant. One of SCOLOR_XXXX
def add_extra_cmt(*args) ‑> bool
add_extra_cmt(ea, isprev, format) -> bool
Add anterior/posterior comment line(s).
ea: (C++: ea_t) linear address
isprev: (C++: bool) do we add anterior lines? (0-no, posterior)
format: (C++: const char *) printf() style format string. may contain \n to denote new lines.
The resulting string should not contain comment characters (;), the kernel will add them automatically.
return: true if success
def add_extra_line(*args) ‑> bool
add_extra_line(ea, isprev, format) -> bool
Add anterior/posterior non-comment line(s).
ea: (C++: ea_t) linear address
isprev: (C++: bool) do we add anterior lines? (0-no, posterior)
format: (C++: const char *) printf() style format string. may contain \n to denote new lines.
return: true if success
def add_pgm_cmt(*args) ‑> bool
add_pgm_cmt(format) -> bool
Add anterior comment line(s) at the start of program.
format: (C++: const char *) printf() style format string. may contain \n to denote new lines.
The resulting string should not contain comment characters (;), the kernel will add them automatically.
return: true if success
def add_sourcefile(*args) ‑> bool
add_sourcefile(ea1, ea2, filename) -> bool
Mark a range of address as belonging to a source file. An address range may belong only to one source file. A source file may be represented by several address ranges.
ea1: (C++: ea_t) linear address of start of the address range
ea2: (C++: ea_t) linear address of end of the address range (excluded)
filename: (C++: const char *) name of source file.
return: success
def calc_bg_color(*args) ‑> bgcolor_t
calc_bg_color(ea) -> bgcolor_t
Get background color for line at 'ea'
ea: (C++: ea_t)
return: RGB color
def calc_prefix_color(*args) ‑> color_t
calc_prefix_color(ea) -> color_t
Get prefix color for line at 'ea'
ea: (C++: ea_t)
return: Line prefix colors
def create_encoding_helper(*args) ‑> encoder_t *
create_encoding_helper(encidx=-1, nr=nr_once) -> encoder_t *
encidx: int
nr: enum encoder_t::notify_recerr_t
def del_extra_cmt(*args) ‑> void
del_extra_cmt(ea, what)
ea: ea_t
what: int
def del_sourcefile(*args) ‑> bool
del_sourcefile(ea) -> bool
Delete information about the source file.
ea: (C++: ea_t) linear address
return: success
def delete_extra_cmts(*args) ‑> void
delete_extra_cmts(ea, what)
ea: ea_t
what: int
def generate_disasm_line(*args) ‑> qstring *
generate_disasm_line(ea, flags=0) -> str
ea: ea_t
flags: int
def generate_disassembly(*args) ‑> PyObject *
generate_disassembly(ea, max_lines, as_stack, notags) -> (int, [str, ...])
Generate disassembly lines (many lines) and put them into a buffer
ea: address to generate disassembly for
max_lines: how many lines max to generate
as_stack: Display undefined items as 2/4/8 bytes
notags: bool
return: - None on failure
  • tuple(most_important_line_number, list(lines)) : Returns a tuple containing
    the most important line number and a list of generated lines
def get_extra_cmt(*args) ‑> int
get_extra_cmt(ea, what) -> ssize_t
ea: ea_t
what: int
def get_first_free_extra_cmtidx(*args) ‑> int
get_first_free_extra_cmtidx(ea, start) -> int
ea: ea_t
start: int
def get_sourcefile(*args) ‑> char const *
get_sourcefile(ea, bounds=None) -> char const *
Get name of source file occupying the given address.
ea: (C++: ea_t) linear address
bounds: (C++: range_t *) pointer to the output buffer with the address range for the
current file. May be nullptr.
return: nullptr if source file information is not found, otherwise returns
pointer to file name
def install_user_defined_prefix(*args) ‑> bool
install_user_defined_prefix(prefix_len, udp, owner) -> bool
User-defined line-prefixes are displayed just after the autogenerated line prefixes in the disassembly listing. There is no need to call this function explicitly. Use the user_defined_prefix_t class.
prefix_len: (C++: size_t) prefixed length. if 0, then uninstall UDP
udp: (C++: struct user_defined_prefix_t *) object to generate user-defined prefix
owner: (C++: const void *) pointer to the plugin_t that owns UDP if non-nullptr, then the
object will be uninstalled and destroyed when the plugin gets unloaded
def requires_color_esc(c)
Checks if the given character requires escaping Is the given char a color escape character?
def set_user_defined_prefix(*args) ‑> PyObject *
set_user_defined_prefix(width, pycb) -> bool
Deprecated. Please use install_user_defined_prefix() instead
width: size_t
pycb: PyObject *
def tag_addr(*args) ‑> PyObject *
tag_addr(ea) -> PyObject *
Insert an address mark into a string.
ea: (C++: ea_t) address to include
def tag_advance(*args) ‑> int
tag_advance(line, cnt) -> int
Move pointer to a 'line' to 'cnt' positions right. Take into account escape sequences.
line: (C++: const char *) pointer to string
cnt: (C++: int) number of positions to move right
return: moved pointer
def tag_remove(*args) ‑> PyObject *
tag_remove(nonnul_instr) -> str
nonnul_instr: char const *
def tag_skipcode(*args) ‑> int
tag_skipcode(line) -> int
Skip one color code. This function should be used if you are interested in color codes and want to analyze all of them. Otherwise tag_skipcodes() function is better since it will skip all colors at once. This function will skip the current color code if there is one. If the current symbol is not a color code, it will return the input.
line: (C++: const char *) char const *
return: moved pointer
def tag_skipcodes(*args) ‑> int
tag_skipcodes(line) -> int
Move the pointer past all color codes.
line: (C++: const char *) can't be nullptr
return: moved pointer, can't be nullptr
def tag_strlen(*args) ‑> ssize_t
tag_strlen(line) -> ssize_t
Calculate length of a colored string This function computes the length in unicode codepoints of a line
line: (C++: const char *) char const *
return: the number of codepoints in the line, or -1 on error
def update_extra_cmt(*args) ‑> void
update_extra_cmt(ea, what, str)
ea: ea_t
what: int
str: char const *

Classes

class user_defined_prefix_t (*args)
Proxy of C++ user_defined_prefix_t class.
__init__(self, prefix_len, owner) -> user_defined_prefix_t
prefix_len: size_t
owner: void const *

Methods

def get_user_defined_prefix(self, *args) ‑> void
get_user_defined_prefix(self, ea, insn, lnnum, indent, line)
This callback must be overridden by the derived class.
ea: (C++: ea_t) the current address
insn: (C++: const class insn_t &) the current instruction. if the current item is not an instruction,
then insn.itype is zero.
lnnum: (C++: int) number of the current line (each address may have several listing
lines for it). 0 means the very first line for the current address.
indent: (C++: int) see explanations for gen_printf()
line: (C++: const char *) the line to be generated. the line usually contains color tags.
this argument can be examined to decide whether to generate the prefix.