Module ida_lines
[frames] | no frames]

Module ida_lines

IDA Plugin SDK API wrapper: lines

Classes
  bgcolors_t
Proxy of C++ bgcolors_t class
Functions
ssize_t
tag_strlen(line)
Calculate length of a colored string This function computes the length in unicode codepoints of a line
color_t
calc_prefix_color(ea)
Get prefix color for line at 'ea'
bgcolor_t
calc_bg_color(ea)
Get background color for line at 'ea'
bool
add_sourcefile(ea1, ea2, filename)
Mark a range of address as belonging to a source file.
char const *
get_sourcefile(ea, bounds=None)
Get name of source file occupying the given address.
bool
del_sourcefile(ea)
Delete information about the source file.
bool
add_extra_line(ea, isprev, format)
Add anterior/posterior non-comment line(s).
bool
add_extra_cmt(ea, isprev, format)
Add anterior/posterior comment line(s).
bool
add_pgm_cmt(format)
Add anterior comment line(s) at the start of program.
bool
generate_disasm_line(ea, flags=0)
int
get_first_free_extra_cmtidx(ea, start)
 
update_extra_cmt(ea, what, str)
 
del_extra_cmt(ea, what)
ssize_t
get_extra_cmt(ea, what)
 
delete_extra_cmts(ea, what)
encoder_t *
create_encoding_helper(encidx=-1, nr=nr_once)
PyObject *
tag_remove(nonnul_instr)
Remove color escape sequences from a string
PyObject *
set_user_defined_prefix(width, pycb)
User-defined line-prefixes are displayed just after the autogenerated line prefixes.
PyObject *
tag_addr(ea)
Insert an address mark into a string.
int
tag_skipcode(line)
Skip one color code.
int
tag_skipcodes(line)
Move the pointer past all color codes.
int
tag_advance(line, cnt)
Move pointer to a 'line' to 'cnt' positions right.
PyObject *
generate_disassembly(ea, max_lines, as_stack, notags)
Generate disassembly lines (many lines) and put them into a buffer
 
requires_color_esc(c)
Checks if the given character requires escaping
 
COLSTR(str, tag)
Utility function to create a colored line
Variables
  COLOR_ON = '\x01'
Followed by a color code ( 'color_t' ).
  COLOR_OFF = '\x02'
Followed by a color code ( 'color_t' ).
  COLOR_ESC = '\x03'
Escape character (Quote next character).
  COLOR_INV = '\x04'
Escape character (Inverse foreground and background colors).
  SCOLOR_ON = '\x01'
Escape character (ON)
  SCOLOR_OFF = '\x02'
Escape character (OFF)
  SCOLOR_ESC = '\x03'
Escape character (Quote next character)
  SCOLOR_INV = '\x04'
Escape character (Inverse colors)
  SCOLOR_DEFAULT = '\x01'
Default.
  SCOLOR_REGCMT = '\x02'
Regular comment.
  SCOLOR_RPTCMT = '\x03'
Repeatable comment (defined not here)
  SCOLOR_AUTOCMT = '\x04'
Automatic comment.
  SCOLOR_INSN = '\x05'
Instruction.
  SCOLOR_DATNAME = '\x06'
Dummy Data Name.
  SCOLOR_DNAME = '\x07'
Regular Data Name.
  SCOLOR_DEMNAME = '\x08'
Demangled Name.
  SCOLOR_SYMBOL = '\t'
Punctuation.
  SCOLOR_CHAR = '\n'
Char constant in instruction.
  SCOLOR_STRING = '\x0b'
String constant in instruction.
  SCOLOR_NUMBER = '\x0c'
Numeric constant in instruction.
  SCOLOR_VOIDOP = '\r'
Void operand.
  SCOLOR_CREF = '\x0e'
Code reference.
  SCOLOR_DREF = '\x0f'
Data reference.
  SCOLOR_CREFTAIL = '\x10'
Code reference to tail byte.
  SCOLOR_DREFTAIL = '\x11'
Data reference to tail byte.
  SCOLOR_ERROR = '\x12'
Error or problem.
  SCOLOR_PREFIX = '\x13'
Line prefix.
  SCOLOR_BINPREF = '\x14'
Binary line prefix bytes.
  SCOLOR_EXTRA = '\x15'
Extra line.
  SCOLOR_ALTOP = '\x16'
Alternative operand.
  SCOLOR_HIDNAME = '\x17'
Hidden name.
  SCOLOR_LIBNAME = '\x18'
Library function name.
  SCOLOR_LOCNAME = '\x19'
Local variable name.
  SCOLOR_CODNAME = '\x1a'
Dummy code name.
  SCOLOR_ASMDIR = '\x1b'
Assembler directive.
  SCOLOR_MACRO = '\x1c'
Macro.
  SCOLOR_DSTR = '\x1d'
String constant in data directive.
  SCOLOR_DCHAR = '\x1e'
Char constant in data directive.
  SCOLOR_DNUM = '\x1f'
Numeric constant in data directive.
  SCOLOR_KEYWORD = ' '
Keywords.
  SCOLOR_REG = '!'
Register name.
  SCOLOR_IMPNAME = '"'
Imported name.
  SCOLOR_SEGNAME = '#'
Segment name.
  SCOLOR_UNKNAME = '$'
Dummy unknown name.
  SCOLOR_CNAME = '%'
Regular code name.
  SCOLOR_UNAME = '&'
Regular unknown name.
  SCOLOR_COLLAPSED = '\''
Collapsed line.
  SCOLOR_ADDR = '('
Hidden address mark.
  COLOR_SELECTED = 2
Selected.
  COLOR_LIBFUNC = 3
Library function.
  COLOR_REGFUNC = 4
Regular function.
  COLOR_CODE = 5
Single instruction.
  COLOR_DATA = 6
Data bytes.
  COLOR_UNKNOWN = 7
Unexplored byte.
  COLOR_EXTERN = 8
External name definition segment.
  COLOR_CURITEM = 9
Current item.
  COLOR_CURLINE = 10
Current line.
  COLOR_HIDLINE = 11
Hidden line.
  COLOR_LUMFUNC = 12
Lumina function.
  COLOR_BG_MAX = 13
Max color number.
  cvar = _ida_lines.cvar
  COLOR_DEFAULT = 1
Default.
  COLOR_REGCMT = 2
  COLOR_RPTCMT = 3
  COLOR_AUTOCMT = 4
  COLOR_INSN = 5
  COLOR_DATNAME = 6
  COLOR_DNAME = 7
  COLOR_DEMNAME = 8
  COLOR_SYMBOL = 9
  COLOR_CHAR = 10
  COLOR_STRING = 11
  COLOR_NUMBER = 12
  COLOR_VOIDOP = 13
  COLOR_CREF = 14
  COLOR_DREF = 15
  COLOR_CREFTAIL = 16
  COLOR_DREFTAIL = 17
  COLOR_ERROR = 18
  COLOR_PREFIX = 19
  COLOR_BINPREF = 20
  COLOR_EXTRA = 21
  COLOR_ALTOP = 22
  COLOR_HIDNAME = 23
  COLOR_LIBNAME = 24
  COLOR_LOCNAME = 25
  COLOR_CODNAME = 26
  COLOR_ASMDIR = 27
  COLOR_MACRO = 28
  COLOR_DSTR = 29
  COLOR_DCHAR = 30
  COLOR_DNUM = 31
  COLOR_KEYWORD = 32
  COLOR_REG = 33
  COLOR_IMPNAME = 34
  COLOR_SEGNAME = 35
  COLOR_UNKNAME = 36
  COLOR_CNAME = 37
  COLOR_UNAME = 38
  COLOR_COLLAPSED = 39
  COLOR_FG_MAX = 40
  COLOR_ADDR = 40
  COLOR_OPND1 = 41
  COLOR_OPND2 = 42
  COLOR_OPND3 = 43
  COLOR_OPND4 = 44
  COLOR_OPND5 = 45
  COLOR_OPND6 = 46
  COLOR_OPND7 = 47
  COLOR_OPND8 = 48
  COLOR_RESERVED1 = 51
  COLOR_LUMINA = 52
  VEL_POST = 1
  VEL_CMT = 2
  GENDSM_FORCE_CODE = 1
  GENDSM_MULTI_LINE = 2
  GENDSM_REMOVE_TAGS = 4
  COLOR_ADDR_SIZE = 8
Size of a tagged address (see 'COLOR_ADDR' )
  SCOLOR_FG_MAX = '('
  SCOLOR_OPND1 = ')'
  SCOLOR_OPND2 = '*'
  SCOLOR_OPND3 = '+'
  SCOLOR_OPND4 = ','
  SCOLOR_OPND5 = '-'
  SCOLOR_OPND6 = '.'
  SCOLOR_UTF8 = '2'
  PALETTE_SIZE = 53
  E_PREV = 1000
  E_NEXT = 2000
  __package__ = None
Function Details

tag_strlen(line)

 

Calculate length of a colored string This function computes the length in unicode codepoints of a line

Parameters:
  • line, (C++ - const char *)
Returns: ssize_t
the number of codepoints in the line, or -1 on error

calc_prefix_color(ea)

 

Get prefix color for line at 'ea'

Parameters:
  • ea, (C++ - ea_t)
Returns: color_t
Line prefix colors

calc_bg_color(ea)

 

Get background color for line at 'ea'

Parameters:
  • ea, (C++ - ea_t)
Returns: bgcolor_t
RGB color

add_sourcefile(ea1, ea2, filename)

 

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.

Parameters:
  • ea1 - linear address of start of the address range (C++: ea_t)
  • ea2 - linear address of end of the address range (excluded) (C++: ea_t)
  • filename - name of source file. (C++: const char *)
Returns: bool
success

get_sourcefile(ea, bounds=None)

 

Get name of source file occupying the given address.

Parameters:
  • ea - linear address (C++: ea_t)
  • bounds - pointer to the output buffer with the address range for the current file. May be NULL. (C++: range_t *)
Returns: char const *
NULL if source file information is not found, otherwise returns pointer to file name

del_sourcefile(ea)

 

Delete information about the source file.

Parameters:
  • ea - linear address (C++: ea_t)
Returns: bool
success

add_extra_line(ea, isprev, format)

 
 Add anterior/posterior non-comment line(s).
 
 @param ea: linear address (C++: ea_t)
 @param isprev: do we add anterior lines? (0-no, posterior) (C++: bool)
 @param format: printf() style format string. may contain 
to denote
                new lines. (C++: const char *)
 @return: true if success
 

Returns: bool

add_extra_cmt(ea, isprev, format)

 
 Add anterior/posterior comment line(s).
 
 @param ea: linear address (C++: ea_t)
 @param isprev: do we add anterior lines? (0-no, posterior) (C++: bool)
 @param format: printf() style format string. may contain 
to denote
                new lines. The resulting string should not contain
                comment characters (;), the kernel will add them
                automatically. (C++: const char *)
 @return: true if success
 

Returns: bool

add_pgm_cmt(format)

 
 Add anterior comment line(s) at the start of program.
 
 @param format: printf() style format string. may contain 
to denote
                new lines. The resulting string should not contain
                comment characters (;), the kernel will add them
                automatically. (C++: const char *)
 @return: true if success
 

Returns: bool

tag_remove(nonnul_instr)

 

Remove color escape sequences from a string

Parameters:
  • colstr - the colored string with embedded tags
Returns: PyObject *
a new string w/o the tags

set_user_defined_prefix(width, pycb)

 
User-defined line-prefixes are displayed just after the autogenerated
line prefixes. In order to use them, the plugin should call the
following function to specify its width and contents.
@param width: the width of the user-defined prefix
@param callback: a get_user_defined_prefix callback to get the contents of the prefix.
    Its arguments:
      ea     - linear address
      lnnum  - line number
      indent - indent of the line contents (-1 means the default instruction)
               indent and is used for instruction itself. see explanations for printf_line()
      line   - the line to be generated. the line usually contains color tags this argument
               can be examined to decide whether to generated the prefix
    It returns a buffer of size < bufsize

In order to remove the callback before unloading the plugin, specify the width = 0 or the callback = None

Returns: PyObject *

tag_addr(ea)

 

Insert an address mark into a string.

Parameters:
  • ea - address to include (C++: ea_t)
Returns: PyObject *

tag_skipcode(line)

 

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.

Parameters:
  • line, (C++ - const char *)
Returns: int
moved pointer

tag_skipcodes(line)

 

Move the pointer past all color codes.

Parameters:
  • line - can't be NULL (C++: const char *)
Returns: int
moved pointer, can't be NULL

tag_advance(line, cnt)

 

Move pointer to a 'line' to 'cnt' positions right. Take into account escape sequences.

Parameters:
  • line - pointer to string (C++: const char *)
  • cnt - number of positions to move right (C++: int)
Returns: int
moved pointer

generate_disassembly(ea, max_lines, as_stack, notags)

 

Generate disassembly lines (many lines) and put them into a buffer

Parameters:
  • ea - address to generate disassembly for
  • max_lines - how many lines max to generate
  • as_stack - Display undefined items as 2/4/8 bytes
Returns: PyObject *
  • None on failure
  • tuple(most_important_line_number, tuple(lines)) : Returns a tuple containing the most important line number and a tuple of generated lines

requires_color_esc(c)

 

Checks if the given character requires escaping

Parameters:
  • c - character (string of one char)
Returns:
Boolean

Is the given char a color escape character?

COLSTR(str, tag)

 

Utility function to create a colored line

Parameters:
  • str - The string
  • tag - Color tag constant. One of SCOLOR_XXXX

Variables Details

COLOR_ON

Followed by a color code ( 'color_t' ).

Escape character (ON).

Value:
'\x01'

COLOR_OFF

Followed by a color code ( 'color_t' ).

Escape character (OFF).

Value:
'\x02'

COLOR_ESC

Escape character (Quote next character). This is needed to output '' and '' characters.

Value:
'\x03'

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.

Value:
'\x04'