Module pywraps
[frames] | no frames]

Module pywraps

This is a placeholder module used to document all the IDA SDK functions that are wrapped manually. You still need to import 'idaapi' and not this module to use the functions

Classes
  data_type_t
Custom data type definition.
  data_format_t
Information about a data format
  loader_input_t
A helper class to work with linput_t related functions.
  qfile_t
A helper class to work with FILE related functions.
  BasicBlock
Basic block class.
  FlowChart
Flowchart class used to determine basic blocks.
  GraphViewer
This class wraps the user graphing facility provided by the graph.hpp file
  pyidc_opaque_object_t
This is the base class for all Python<->IDC opaque objects
  py_clinked_object_t
This is a utility and base class for C linked objects
  object_t
Helper class used to initialize empty objects
  plugin_t
Base class for all scripted plugins.
  pyidc_cvt_helper__
This is a special helper object that helps detect which kind of object is this python object wrapping and how to convert it back and from IDC.
  PyIdc_cvt_int64__
Helper class for explicitly representing VT_INT64 values
  PyIdc_cvt_refclass__
Helper class for representing references to immutable objects
  Appcall_array__
This class is used with Appcall.array() method
  Appcall_callable__
Helper class to issue appcalls using a natural syntax:...
  Appcall_consts__
Helper class used by Appcall.Consts attribute It is used to retrieve constants via attribute access
  Appcall__
  IDP_Hooks
  Choose
Choose - class for choose() with callbacks
  Choose2
Choose2 wrapper class.
  cli_t
cli_t wrapper class.
  simplecustviewer_t
The base class for implementing simple custom viewers
  switch_info_ex_t
  NearestName
Utility class to help find the nearest name in a given ea/name dictionary
  op_t
Class representing operands
  insn_t
Class representing instructions
  processor_t
Base class for all processor module scripts
Functions
 
get_many_bytes(ea, size)
Get the specified number of bytes of the program into the buffer.
 
register_custom_data_type(dt)
Registers a custom data type.
 
unregister_custom_data_type(dtid)
Unregisters a custom data type.
 
register_custom_data_format(dtid, df)
Registers a custom data format with a given data type.
 
unregister_custom_data_format(dtid, dfid)
Unregisters a custom data format
 
get_custom_data_format(dtid, dfid)
Returns a dictionary populated with the data format values or None on failure.
 
get_custom_data_type(dtid)
Returns a dictionary populated with the data type values or None on failure.
 
register_data_types_and_formats(formats)
Registers multiple data types and formats at once.
 
unregister_data_types_and_formats(formats)
As opposed to register_data_types_and_formats(), this function unregisters multiple data types and formats at once.
 
get_manual_regions()
Returns the manual memory regions
 
dbg_is_loaded()
Checks if a debugger is loaded
 
refresh_debugger_memory()
Refreshes the debugger memory
 
enumerate_files(path, fname, callback)
Enumerate files in the specified directory while the callback returns 0.
 
enumerate_system_files(subdir, fname, callback)
Similar to enumerate_files() however it searches inside IDA directory or its subdirectories
 
get_fchunk_referer(ea, idx)
 
as_cstr(val)
Returns a C str from the passed value.
 
as_unicode(s)
Convenience function to convert a string into appropriate unicode format
 
as_uint32(v)
Returns a number as an unsigned int32 number
 
as_int32(v)
Returns a number as a signed int32 number
 
as_signed(v, nbits=32)
Returns a number as signed.
 
copy_bits(v, s, e=-1)
Copy bits from a value
 
struct_unpack(buffer, signed=False, offs=0)
Unpack a buffer given its length and offset using struct.unpack_from().
 
IDAPython_ExecScript(script, g)
Run the specified script.
 
parse_command_line(cmdline)
Parses a space separated string (quotes and escape character are supported)
 
get_inf_structure()
Returns the global variable 'inf' (an instance of idainfo structure, see ida.hpp)
 
set_script_timeout(timeout)
Changes the script timeout value.
 
enable_extlang_python(enable)
Enables or disables Python extlang.
 
RunPythonStatement(stmt)
This is an IDC function exported from the Python plugin.
 
notify_when(when, callback)
Register a callback that will be called when an event happens.
 
dbg_get_registers()
This function returns the register definition from the currently loaded debugger.
 
dbg_get_thread_sreg_base(tid, sreg_value)
Returns the segment register base value
 
dbg_read_memory(ea, sz)
Reads from the debugee's memory at the specified ea
 
dbg_write_memory(ea, buffer)
Writes a buffer to the debugee's memory
 
dbg_get_name()
This function returns the current debugger's name.
 
dbg_get_memory_info()
This function returns the memory configuration of a debugged process.
 
dbg_can_query()
This function can be used to check if the debugger can be queried:
 
AssembleLine(ea, cs, ip, use32, line)
Assemble an instruction to a buffer (display a warning if an error is found)
 
ph_get_id()
Returns the 'ph.id' field
 
ph_get_version()
Returns the 'ph.version'
 
ph_get_flag()
Returns the 'ph.flag'
 
ph_get_cnbits()
Returns the 'ph.cnbits'
 
ph_get_dnbits()
Returns the 'ph.dnbits'
 
ph_get_regFirstSreg()
Returns the 'ph.regFirstSreg'
 
ph_get_regLastSreg()
Returns the 'ph.regLastSreg'
 
ph_get_segreg_size()
Returns the 'ph.segreg_size'
 
ph_get_regCodeSreg()
Returns the 'ph.regCodeSreg'
 
ph_get_regDataSreg()
Returns the 'ph.regDataSreg'
 
ph_get_high_fixup_bits()
Returns the 'ph.high_fixup_bits'
 
ph_get_icode_return()
Returns the 'ph.icode_return'
 
ph_get_instruc_start()
Returns the 'ph.instruc_start'
 
ph_get_instruc_end()
Returns the 'ph.instruc_end'
 
ph_get_tbyte_size()
Returns the 'ph.tbyte_size' field as defined in he processor module
 
ph_get_instruc()
Returns a list of tuples (instruction_name, instruction_feature) containing the instructions list as defined in he processor module
 
ph_get_regnames()
Returns the list of register names as defined in the processor module
 
asklong(defval, format)
 
askaddr(defval, format)
 
askseg(defval, format)
 
get_highlighted_identifier(flags=0)
Returns the currently highlighted identifier
 
asktext(max_text, defval, prompt)
Asks for a long text
 
str2ea(addr)
Converts a string express to EA.
 
del_menu_item(menu_ctx)
Deletes a menu item previously added with add_menu_item()
 
add_menu_item(menupath, name, hotkey, flags, callback, args)
Adds a menu item @param menupath: path to the menu item after or before which the insertion will take place @param name: name of the menu item (~x~ is used to denote Alt-x hot letter) @param hotkey: hotkey for the menu item (may be empty) @param flags: one of SETMENU_...
 
set_dock_pos(src, dest, orient, left=0, top=0, right=0, bottom=0)
Sets the dock orientation of a window relatively to another window.
 
set_user_defined_prefix(width, callback)
User-defined line-prefixes are displayed just after the autogenerated line prefixes.
 
tag_remove(colstr)
Remove color escape sequences from a string
 
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
 
mem2base(mem, ea, fpos)
Load database from the memory.
 
load_plugin(name)
Loads a plugin
 
run_plugin(plg)
Runs a plugin
 
get_import_module_name(path, fname, callback)
Returns the name of an imported module given its index
 
get_switch_info_ex(ea)
Returns the a switch_info_ex_t structure containing the information about the switch.
 
create_switch_xrefs(insn_ea, si)
This function creates xrefs from the indirect jump.
 
create_switch_table(insn_ea, si)
Create switch table from the switch information
 
set_switch_info_ex(ea, switch_info_ex)
Saves the switch information in the database Please refer to the SDK sample 'uiswitch'
 
del_switch_info_ex(ea)
Deletes stored switch information
 
enum_import_names(mod_index, callback)
Enumerate imports from a specific module.
 
get_type_size0(ti, tp)
Returns the size of a type
 
print_type(ea, on_line)
Returns the type of an item
 
py_unpack_object_from_idb(ti, tp, fields, ea, pio_flags=0)
Unpacks from the database at 'ea' to an object.
 
unpack_object_from_bv(ti, tp, fields, bytes, pio_flags=0)
Unpacks a buffer into an object.
 
pack_object_to_idb(obj, ti, tp, fields, ea, pio_flags=0)
Write a typed object to the database.
 
pack_object_to_bv(obj, ti, tp, fields, base_ea, pio_flags=0)
Packs a typed object to a string
 
init_output_buffer(size=MAXSTR)
This function initialize an output buffer with the given size.
 
term_output_buffer()
Use this function to terminate an output buffer.
 
decode_preceding_insn(ea)
Decodes the preceding instruction.
 
OutValue(op, outflags=0)
Output immediate value
 
get_stkvar(op, v)
Get pointer to stack variable
 
add_stkvar3(op, v, flags)
Automatically add stack variable if doesn't exist Processor modules should use ua_stkvar2()
 
apply_type_to_stkarg(op, v, type, name)
Apply type information to a stack variable
 
OutImmChar(op, outflags=0)
Output operand value as a commented character constant
 
ua_stkvar2(op, outflags=0)
Create or modify a stack variable in the function frame.
 
ua_add_off_drefs(op, type)
Add xrefs for offset operand of the current instruction Please check ua.hpp / ua_add_off_drefs()
 
ua_add_off_drefs2(op, type, outf)
Add xrefs for offset operand of the current instruction Please check ua.hpp / ua_add_off_drefs2()
 
out_name_expr(op, ea, off)
Output a name expression
Variables
  DTP_NODUP = 0x0001
  SEEK_SET = 0
  SEEK_CUR = 1
  SEEK_END = 2
  PLUGIN_MOD = 0x0001
  PLUGIN_DRAW = 0x0002
  PLUGIN_SEG = 0x0004
  PLUGIN_UNL = 0x0008
  PLUGIN_HIDE = 0x0010
  PLUGIN_DBG = 0x0020
  PLUGIN_PROC = 0x0040
  PLUGIN_FIX = 0x0080
  PLUGIN_SKIP = 0
  PLUGIN_OK = 1
  PLUGIN_KEEP = 2
  PY_ICID_INT64 = 0
int64 object
  PY_ICID_BYREF = 1
byref object
  PY_ICID_OPAQUE = 2
opaque object
  IDAPython_Completion = __IDAPython_Completion_Util()
  NW_OPENIDB = 0x0001
Notify when the database is opened.
  NW_CLOSEIDB = 0x0002
Notify when the database is closed.
  NW_INITIDA = 0x0004
Notify when the IDA starts.
  NW_TERMIDA = 0x0008
Notify when the IDA terminates.
  NW_REMOVE = 0x0010
Use this flag with other flags to uninstall a notifywhen callback
  Appcall = Appcall__()
  DP_LEFT = 0x0001
  DP_TOP = 0x0002
  DP_RIGHT = 0x0004
  DP_BOTTOM = 0x0008
  DP_INSIDE = 0x0010
  DP_BEFORE = 0x0020
  DP_RAW = 0x0040
  DP_FLOATING = 0x0080
  COLOR_ADDR_SIZE = 16 if _idaapi.BADADDR== 0xFFFFFFFFFFFFFFFFL ...
  SCOLOR_FG_MAX = '\x28'
  SCOLOR_OPND1 = chr(cvar.COLOR_ADDR+ 1)
  SCOLOR_OPND2 = chr(cvar.COLOR_ADDR+ 2)
  SCOLOR_OPND3 = chr(cvar.COLOR_ADDR+ 3)
  SCOLOR_OPND4 = chr(cvar.COLOR_ADDR+ 4)
  SCOLOR_OPND5 = chr(cvar.COLOR_ADDR+ 5)
  SCOLOR_OPND6 = chr(cvar.COLOR_ADDR+ 6)
  SCOLOR_UTF8 = chr(cvar.COLOR_ADDR+ 10)
  PALETTE_SIZE = cvar.COLOR_FG_MAX+ _idaapi.COLOR_BG_MAX
  SWI_SPARSE = 0x1
sparse switch ( value table present ) otherwise lowcase present
  SWI_V32 = 0x2
32-bit values in table
  SWI_J32 = 0x4
32-bit jump offsets
  SWI_VSPLIT = 0x8
value table is split (only for 32-bit values)
  SWI_DEFAULT = 0x10
default case is present
  SWI_END_IN_TBL = 0x20
switchend in table (default entry)
  SWI_JMP_INV = 0x40
jumptable is inversed (last entry is for first entry in values table)
  SWI_SHIFT_MASK = 0x180
use formula (element*shift + elbase) to find jump targets
  SWI_ELBASE = 0x200
elbase is present (if not and shift!=0, endof(jumpea) is used)
  SWI_JSIZE = 0x400
jump offset expansion bit
  SWI_VSIZE = 0x800
value table element size expansion bit
  SWI_SEPARATE = 0x1000
do not create an array of individual dwords
  SWI_SIGNED = 0x2000
jump table entries are signed
  SWI_CUSTOM = 0x4000
custom jump table - ph.create_switch_xrefs will be called to create code xrefs for the table.
  SWI_EXTENDED = 0x8000
this is switch_info_ex_t
  SWI2_INDIRECT = 0x0001
value table elements are used as indexes into the jump table
  SWI2_SUBTRACT = 0x0002
table values are subtracted from the elbase instead of being addded
  CUSTOM_CMD_ITYPE = 0x8000
  REG_SPOIL = 0x80000000
  REAL_ERROR_FORMAT = -1
  REAL_ERROR_RANGE = -2
  REAL_ERROR_BADDATA = -3
  OP_FP_BASED = 0x00000000
  OP_SP_BASED = 0x00000001
  OP_SP_ADD = 0x00000000
  OP_SP_SUB = 0x00000002
  PLFM_386 = 0x0
  PLFM_Z80 = 0x1
  PLFM_I860 = 0x2
  PLFM_8051 = 0x3
  PLFM_TMS = 0x4
  PLFM_6502 = 0x5
  PLFM_PDP = 0x6
  PLFM_68K = 0x7
  PLFM_JAVA = 0x8
  PLFM_6800 = 0x9
  PLFM_ST7 = 0x10
  PLFM_MC6812 = 0x11
  PLFM_MIPS = 0x12
  PLFM_ARM = 0x13
  PLFM_TMSC6 = 0x14
  PLFM_PPC = 0x15
  PLFM_80196 = 0x16
  PLFM_Z8 = 0x17
  PLFM_SH = 0x18
  PLFM_NET = 0x19
  PLFM_AVR = 0x20
  PLFM_H8 = 0x21
  PLFM_PIC = 0x22
  PLFM_SPARC = 0x23
  PLFM_ALPHA = 0x24
  PLFM_HPPA = 0x25
  PLFM_H8500 = 0x26
  PLFM_TRICORE = 0x27
  PLFM_DSP56K = 0x28
  PLFM_C166 = 0x29
  PLFM_ST20 = 0x30
  PLFM_IA64 = 0x31
  PLFM_I960 = 0x32
  PLFM_F2MC = 0x33
  PLFM_TMS320C54 = 0x34
  PLFM_TMS320C55 = 0x35
  PLFM_TRIMEDIA = 0x36
  PLFM_M32R = 0x37
  PLFM_NEC_78K0 = 0x38
  PLFM_NEC_78K0S = 0x39
  PLFM_M740 = 0x40
  PLFM_M7700 = 0x41
  PLFM_ST9 = 0x42
  PLFM_FR = 0x43
  PLFM_MC6816 = 0x44
  PLFM_M7900 = 0x45
  PLFM_TMS320C3 = 0x46
  PLFM_KR1878 = 0x47
  PLFM_AD218X = 0x48
  PLFM_OAKDSP = 0x49
  PLFM_TLCS900 = 0x50
  PLFM_C39 = 0x51
  PLFM_CR16 = 0x52
  PLFM_MN102L00 = 0x53
  PLFM_TMS320C1X = 0x54
  PLFM_NEC_V850X = 0x55
  PLFM_SCR_ADPT = 0x56
  PLFM_EBC = 0x57
  PLFM_MSP430 = 0x58
  PR_SEGS = 0x000001
  PR_USE32 = 0x000002
  PR_DEFSEG32 = 0x000004
  PR_RNAMESOK = 0x000008
  PR_ADJSEGS = 0x000020
  PR_DEFNUM = 0x0000C0
  PRN_HEX = 0x000000
  PRN_OCT = 0x000040
  PRN_DEC = 0x000080
  PRN_BIN = 0x0000C0
  PR_WORD_INS = 0x000100
  PR_NOCHANGE = 0x000200
  PR_ASSEMBLE = 0x000400
  PR_ALIGN = 0x000800
  PR_TYPEINFO = 0x001000
  PR_USE64 = 0x002000
  PR_SGROTHER = 0x004000
  PR_STACK_UP = 0x008000
  PR_BINMEM = 0x010000
  PR_SEGTRANS = 0x020000
  PR_CHK_XREF = 0x040000
  PR_NO_SEGMOVE = 0x080000
  PR_FULL_HIFXP = 0x100000
  PR_USE_ARG_TYPES = 0x200000
  PR_SCALE_STKVARS = 0x400000
  PR_DELAYED = 0x800000
  PR_ALIGN_INSN = 0x1000000
  PR_PURGING = 0x2000000
  PR_CNDINSNS = 0x4000000
  PR_USE_TBYTE = 0x8000000
  PR_DEFSEG64 = 0x10000000
  UA_MAXOP = 6
The maximum number of operands in the insn_t structure
  cmd = insn_t(_idaapi.py_get_global_cmd_link())
cmd is a global variable of type insn_t.
  CF_STOP = 0x00001
  CF_CALL = 0x00002
  CF_CHG1 = 0x00004
  CF_CHG2 = 0x00008
  CF_CHG3 = 0x00010
  CF_CHG4 = 0x00020
  CF_CHG5 = 0x00040
  CF_CHG6 = 0x00080
  CF_USE1 = 0x00100
  CF_USE2 = 0x00200
  CF_USE3 = 0x00400
  CF_USE4 = 0x00800
  CF_USE5 = 0x01000
  CF_USE6 = 0x02000
  CF_JUMP = 0x04000
  CF_SHFT = 0x08000
  CF_HLL = 0x10000
  o_void = 0
  o_reg = 1
  o_mem = 2
  o_phrase = 3
  o_displ = 4
  o_imm = 5
  o_far = 6
  o_near = 7
  o_idpspec0 = 8
  o_idpspec1 = 9
  o_idpspec2 = 10
  o_idpspec3 = 11
  o_idpspec4 = 12
  o_idpspec5 = 13
  o_last = 14
  dt_byte = 0
  dt_word = 1
  dt_dword = 2
  dt_float = 3
  dt_double = 4
  dt_tbyte = 5
  dt_packreal = 6
  dt_qword = 7
  dt_byte16 = 8
  dt_code = 9
  dt_void = 10
  dt_fword = 11
  dt_bitfild = 12
  dt_string = 13
  dt_unicode = 14
  dt_3byte = 15
  dt_ldbl = 16
  OF_NO_BASE_DISP = 0x80
  OF_OUTER_DISP = 0x40
  PACK_FORM_DEF = 0x20
  OF_NUMBER = 0x10
  OF_SHOW = 0x08
  INSN_MACRO = 0x01
  INSN_MODMAC = 0x02
  IDPOPT_STR = 1
  IDPOPT_NUM = 2
  IDPOPT_BIT = 3
  IDPOPT_FLT = 4
  IDPOPT_I64 = 5
  IDPOPT_OK = 0
  IDPOPT_BADKEY = 1
  IDPOPT_BADTYPE = 2
  IDPOPT_BADVALUE = 3
  ph = __ph()
Function Details

get_many_bytes(ea, size)

 

Get the specified number of bytes of the program into the buffer.

Parameters:
  • ea - program address
  • size - number of bytes to return
Returns:
None or the string buffer

register_custom_data_type(dt)

 

Registers a custom data type.

Parameters:
  • dt - an instance of the data_type_t class
Returns:
< 0 if failed to register > 0 data type id

unregister_custom_data_type(dtid)

 

Unregisters a custom data type.

Parameters:
  • dtid - the data type id
Returns:
Boolean

register_custom_data_format(dtid, df)

 

Registers a custom data format with a given data type.

Parameters:
  • dtid - data type id
  • df - an instance of data_format_t
Returns:
< 0 if failed to register > 0 data format id

unregister_custom_data_format(dtid, dfid)

 

Unregisters a custom data format

Parameters:
  • dtid - data type id
  • dfid - data format id
Returns:
Boolean

get_custom_data_format(dtid, dfid)

 

Returns a dictionary populated with the data format values or None on failure.

Parameters:
  • dtid - data type id
  • dfid - data format id

get_custom_data_type(dtid)

 

Returns a dictionary populated with the data type values or None on failure.

Parameters:
  • dtid - data type id

register_data_types_and_formats(formats)

 

Registers multiple data types and formats at once.
To register one type/format at a time use register_custom_data_type/register_custom_data_format
It employs a special table of types and formats described below:
The 'formats' is a list of tuples. If a tuple has one element then it is the format to be registered with dtid=0
If the tuple has more than one element, then tuple[0] is the data type and tuple[1:] are the data formats. For example:
many_formats = [
  (pascal_data_type(), pascal_data_format()),
  (simplevm_data_type(), simplevm_data_format()),
  (makedword_data_format(),),
  (simplevm_data_format(),)
]
The first two tuples describe data types and their associated formats.
The last two tuples describe two data formats to be used with built-in data types.

get_manual_regions()

 

Returns the manual memory regions

Returns:
list(startEA, endEA, name, sclass, sbase, bitness, perm)

dbg_is_loaded()

 

Checks if a debugger is loaded

Returns:
Boolean

refresh_debugger_memory()

 

Refreshes the debugger memory

Returns:
Nothing

enumerate_files(path, fname, callback)

 

Enumerate files in the specified directory while the callback returns 0.

Parameters:
  • path - directory to enumerate files in
  • fname - mask of file names to enumerate
  • callback - a callable object that takes the filename as its first argument and it returns 0 to continue enumeration or non-zero to stop enumeration.
Returns:
None in case of script errors tuple(code, fname) : If the callback returns non-zero

as_cstr(val)

 

Returns a C str from the passed value. The passed value can be of type refclass (returned by a call to buffer() or byref()) It scans for the first and returns the string value up to that point.

as_signed(v, nbits=32)

 

Returns a number as signed. The number of bits are specified by the user. The MSB holds the sign.

copy_bits(v, s, e=-1)

 

Copy bits from a value

Parameters:
  • v - the value
  • s - starting bit
  • e - ending bit

struct_unpack(buffer, signed=False, offs=0)

 

Unpack a buffer given its length and offset using struct.unpack_from(). This function will know how to unpack the given buffer by using the lookup table '__struct_unpack_table' If the buffer is of unknown length then None is returned. Otherwise the unpacked value is returned.

IDAPython_ExecScript(script, g)

 

Run the specified script. It also addresses http://code.google.com/p/idapython/issues/detail?id=42 This function is used by the low-level plugin code.

parse_command_line(cmdline)

 

Parses a space separated string (quotes and escape character are supported)

Parameters:
  • cmdline - The command line to parse
Returns:
A list of strings or None on failure

set_script_timeout(timeout)

 

Changes the script timeout value.

Parameters:
  • timeout - This value is in seconds. If this value is set to zero then the script will never timeout.
Returns:
returns the old timeout value

enable_extlang_python(enable)

 

Enables or disables Python extlang. When enabled, all expressions will be evaluated by Python.

Parameters:
  • enable - Set to True to enable, False otherwise

RunPythonStatement(stmt)

 

This is an IDC function exported from the Python plugin. It is used to evaluate Python statements from IDC.

Parameters:
  • stmt - The statement to evaluate
Returns:
0 - on success otherwise a string containing the error

notify_when(when, callback)

 

Register a callback that will be called when an event happens.
@param when: one of NW_XXXX constants
@param callback: This callback prototype varies depending on the 'when' parameter:
                 The general callback format:
                     def notify_when_callback(nw_code)
                 In the case of NW_OPENIDB:
                     def notify_when_callback(nw_code, is_old_database)
@return: Boolean

dbg_get_registers()

 

This function returns the register definition from the currently loaded debugger. Basically, it returns an array of structure similar to to idd.hpp / register_info_t

Returns:
None if no debugger is loaded tuple(name, flags, class, dtyp, bit_strings, bit_strings_default_mask) The bit_strings can be a tuple of strings or None (if the register does not have bit_strings)

dbg_get_thread_sreg_base(tid, sreg_value)

 

Returns the segment register base value

Parameters:
  • tid - thread id
  • sreg_value - segment register (selector) value
Returns:
  • The base as an 'ea'
  • Or None on failure

dbg_read_memory(ea, sz)

 

Reads from the debugee's memory at the specified ea

Returns:
  • The read buffer (as a string)
  • Or None on failure

dbg_write_memory(ea, buffer)

 

Writes a buffer to the debugee's memory

Returns:
Boolean

dbg_get_name()

 

This function returns the current debugger's name.

Returns:
Debugger name or None if no debugger is active

dbg_get_memory_info()

 

This function returns the memory configuration of a debugged process.

Returns:
None if no debugger is active tuple(startEA, endEA, name, sclass, sbase, bitness, perm)

dbg_can_query()

 

This function can be used to check if the debugger can be queried:

  • debugger is loaded
  • process is suspended
  • process is not suspended but can take requests. In this case some requests like memory read/write, bpt management succeed and register querying will fail. Check if idaapi.get_process_state() < 0 to tell if the process is suspended
Returns:
Boolean

AssembleLine(ea, cs, ip, use32, line)

 

Assemble an instruction to a buffer (display a warning if an error is found)

Parameters:
  • ea - linear address of instruction
  • cs - cs of instruction
  • ip - ip of instruction
  • use32 - is 32bit segment
  • line - line to assemble
Returns:
  • None on failure
  • or a string containing the assembled instruction

get_highlighted_identifier(flags=0)

 

Returns the currently highlighted identifier

Parameters:
  • flags - reserved (pass 0)
Returns:
None or the highlighted identifier

asktext(max_text, defval, prompt)

 

Asks for a long text

Parameters:
  • max_text - Maximum text length
  • defval - The default value
  • prompt - The prompt value
Returns:
None or the entered string

str2ea(addr)

 

Converts a string express to EA. The expression evaluator may be called as well.

Returns:
BADADDR or address value

del_menu_item(menu_ctx)

 

Deletes a menu item previously added with add_menu_item()

Parameters:
  • menu_ctx - value returned by add_menu_item()
Returns:
Boolean

add_menu_item(menupath, name, hotkey, flags, callback, args)

 

Adds a menu item
@param menupath: path to the menu item after or before which the insertion will take place
@param name: name of the menu item (~x~ is used to denote Alt-x hot letter)
@param hotkey: hotkey for the menu item (may be empty)
@param flags: one of SETMENU_... consts
@param callback: function which gets called when the user selects the menu item.
           The function callback is of the form:
           def callback(*args):
              pass
@param args: tuple containing the arguments
@return: None or a menu context (to be used by del_menu_item())

set_dock_pos(src, dest, orient, left=0, top=0, right=0, bottom=0)

 

Sets the dock orientation of a window relatively to another window.
@param src: Source docking control
@param dest: Destination docking control
@param orient: One of DOR_XXXX constants
@param left, top, right, bottom: These parameter if DOR_FLOATING is used, or if you want to specify the width of docked windows
@return: Boolean
Example:
    set_dock_pos('Structures', 'Enums', DOR_RIGHT) <- docks the Structures window to the right of Enums window

set_user_defined_prefix(width, callback)

 

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
      bufsize- the maximum allowed size of the output buffer
    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

tag_remove(colstr)

 

Remove color escape sequences from a string

Parameters:
  • colstr - the colored string with embedded tags
Returns:
None on failure or a new string w/o the tags

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:
  • 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

COLSTR(str, tag)

 

Utility function to create a colored line

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

mem2base(mem, ea, fpos)

 

Load database from the memory.

Parameters:
  • mem - the buffer
  • ea - start linear addresses
  • fpos - position in the input file the data is taken from. if == -1, then no file position correspond to the data.
Returns:
  • Returns zero if the passed buffer was not a string
  • Otherwise 1 is returned

load_plugin(name)

 

Loads a plugin

Returns:
  • None if plugin could not be loaded
  • An opaque object representing the loaded plugin

run_plugin(plg)

 

Runs a plugin

Parameters:
  • plg - A plugin object (returned by load_plugin())
Returns:
Boolean

get_import_module_name(path, fname, callback)

 

Returns the name of an imported module given its index

Returns:
None or the module name

get_switch_info_ex(ea)

 

Returns the a switch_info_ex_t structure containing the information about the switch. Please refer to the SDK sample 'uiswitch'

Returns:
None or switch_info_ex_t instance

create_switch_xrefs(insn_ea, si)

 

This function creates xrefs from the indirect jump. Usually there is no need to call this function directly because the kernel will call it for switch tables Note: Custom switch information are not supported yet.

Parameters:
  • insn_ea - address of the 'indirect jump' instruction
  • si - switch information
Returns:
Boolean

create_switch_table(insn_ea, si)

 

Create switch table from the switch information

Parameters:
  • insn_ea - address of the 'indirect jump' instruction
  • si - switch information
Returns:
Boolean

set_switch_info_ex(ea, switch_info_ex)

 

Saves the switch information in the database Please refer to the SDK sample 'uiswitch'

Returns:
Boolean

enum_import_names(mod_index, callback)

 

Enumerate imports from a specific module. Please refer to ex_imports.py example.

Parameters:
  • mod_index - The module index
  • callback - A callable object that will be invoked with an ea, name (could be None) and ordinal.
Returns:
1-finished ok, -1 on error, otherwise callback return value (<=0)

get_type_size0(ti, tp)

 

Returns the size of a type

Parameters:
  • ti - Type info. 'idaapi.cvar.idati' can be passed.
  • tp - type string
Returns:
  • None on failure
  • The size of the type

print_type(ea, on_line)

 

Returns the type of an item

Returns:
  • None on failure
  • The type string with a semicolon. Can be used directly with idc.SetType()

py_unpack_object_from_idb(ti, tp, fields, ea, pio_flags=0)

 

Unpacks from the database at 'ea' to an object. Please refer to unpack_object_from_bv()

unpack_object_from_bv(ti, tp, fields, bytes, pio_flags=0)

 

Unpacks a buffer into an object. Returns the error_t returned by idaapi.pack_object_to_idb

Parameters:
  • ti - Type info. 'idaapi.cvar.idati' can be passed.
  • tp - type string
  • fields - type fields
  • bytes - the bytes to unpack
  • pio_flags - flags used while unpacking
Returns:
  • tuple(0, err) on failure
  • tuple(1, obj) on success

pack_object_to_idb(obj, ti, tp, fields, ea, pio_flags=0)

 

Write a typed object to the database. Raises an exception if wrong parameters were passed or conversion fails Returns the error_t returned by idaapi.pack_object_to_idb

Parameters:
  • ti - Type info. 'idaapi.cvar.idati' can be passed.
  • tp - type string
  • fields - type fields
  • ea - ea to be used while packing
  • pio_flags - flags used while unpacking

pack_object_to_bv(obj, ti, tp, fields, base_ea, pio_flags=0)

 

Packs a typed object to a string

Parameters:
  • ti - Type info. 'idaapi.cvar.idati' can be passed.
  • tp - type string
  • fields - type fields
  • base_ea - base ea used to relocate the pointers in the packed object
  • pio_flags - flags used while unpacking
Returns:
tuple(0, err_code) on failure tuple(1, packed_buf) on success

init_output_buffer(size=MAXSTR)

 

This function initialize an output buffer with the given size. It should be called before using any out_xxxx() functions.

Returns:
It returns a string. This string should then be passed to MakeLine(). This function could return None if it failed to create a buffer with the given size.

decode_preceding_insn(ea)

 

Decodes the preceding instruction. Please check ua.hpp / decode_preceding_insn()

Parameters:
  • ea - current ea
Returns:
tuple(preceeding_ea or BADADDR, farref = Boolean)

OutValue(op, outflags=0)

 

Output immediate value

Parameters:
  • op - operand (of type op_t)
Returns:
flags of the output value -1: value is output with COLOR_ERROR 0: value is output as a number or character or segment

get_stkvar(op, v)

 

Get pointer to stack variable

Parameters:
  • op - reference to instruction operand
  • v - immediate value in the operand (usually op.addr)
Returns:
  • None on failure
  • tuple(member_t, actval) where actval: actual value used to fetch stack variable

add_stkvar3(op, v, flags)

 

Automatically add stack variable if doesn't exist Processor modules should use ua_stkvar2()

Parameters:
  • op - reference to instruction operand
  • v - immediate value in the operand (usually op.addr)
  • flags - combination of STKVAR_... constants
Returns:
Boolean

apply_type_to_stkarg(op, v, type, name)

 

Apply type information to a stack variable

Parameters:
  • op - reference to instruction operand
  • v - immediate value in the operand (usually op.addr)
  • type - type string. Retrieve from idc.ParseType("type string", flags)[1]
  • name - stack variable name
Returns:
Boolean

OutImmChar(op, outflags=0)

 

Output operand value as a commented character constant

Parameters:
  • op - operand (of type op_t)
Returns:
None

ua_stkvar2(op, outflags=0)

 

Create or modify a stack variable in the function frame. Please check ua.hpp / ua_stkvar2()

Parameters:
  • op - operand (of type op_t)
Returns:
None

ua_add_off_drefs(op, type)

 

Add xrefs for offset operand of the current instruction Please check ua.hpp / ua_add_off_drefs()

Parameters:
  • op - operand (of type op_t)
Returns:
None

ua_add_off_drefs2(op, type, outf)

 

Add xrefs for offset operand of the current instruction Please check ua.hpp / ua_add_off_drefs2()

Returns:
ea_t

out_name_expr(op, ea, off)

 

Output a name expression

Parameters:
  • op - operand (of type op_t)
  • ea - address of 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.
Returns:
true if the name expression has been produced

Variables Details

NW_OPENIDB

Notify when the database is opened. Its callback is of the form: def notify_when_callback(nw_code, is_old_database)

Value:
0x0001

NW_CLOSEIDB

Notify when the database is closed. Its callback is of the form: def notify_when_callback(nw_code)

Value:
0x0002

NW_INITIDA

Notify when the IDA starts. Its callback is of the form: def notify_when_callback(nw_code)

Value:
0x0004

NW_TERMIDA

Notify when the IDA terminates. Its callback is of the form: def notify_when_callback(nw_code)

Value:
0x0008

COLOR_ADDR_SIZE

Value:
16 if _idaapi.BADADDR== 0xFFFFFFFFFFFFFFFFL else 8

SWI_CUSTOM

custom jump table - ph.create_switch_xrefs will be called to create code xrefs for the table. it must return 2. custom jump table must be created by the module

Value:
0x4000

cmd

cmd is a global variable of type insn_t. It is contains information about the last decoded instruction. This variable is also filled by processor modules when they decode instructions.

Value:
insn_t(_idaapi.py_get_global_cmd_link())

[an error occurred while processing this directive]