Module ida_idaapi
[frames] | no frames]

Module ida_idaapi

IDA Plugin SDK API wrapper: idaapi

Classes
  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
  loader_input_t
Proxy of C++ loader_input_t class
Functions
 
require(modulename, package=None)
Load, or reload a module.
 
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_ExecSystem(cmd)
Executes a command with popen().
 
IDAPython_FormatExc(etype, value, tb, limit=None)
This function is used to format an exception given the values returned by a PyErr_Fetch()
 
IDAPython_ExecScript(script, g, print_error=True)
Run the specified script.
 
IDAPython_LoadProcMod(script, g, print_error=True)
Load processor module.
 
IDAPython_UnLoadProcMod(script, g, print_error=True)
Unload processor module.
PyObject *
parse_command_line3(cmdline)
idainfo
get_inf_structure()
Returns the global variable 'inf' (an instance of idainfo structure, see ida.hpp)
int
set_script_timeout(timeout)
Changes the script timeout value.
 
disable_script_timeout()
Disables the script timeout and hides the script wait box.
 
enable_extlang_python(enable)
Enables or disables Python extlang.
 
enable_python_cli(enable)
bool
notify_when(when, py_callable)
Register a callback that will be called when an event happens.
 
pygc_refresh(self)
 
pygc_set_node_info(self, py_node_idx, py_node_info, py_flags)
 
pygc_set_nodes_infos(self, values)
PyObject *
pygc_get_node_info(self, py_node_idx)
 
pygc_del_nodes_infos(self, py_nodes)
PyObject *
pygc_get_current_renderer_type(self)
 
pygc_set_current_renderer_type(self, py_rt)
PyObject *
pygc_create_groups(self, groups_infos)
PyObject *
pygc_delete_groups(self, groups, new_current)
PyObject *
pygc_set_groups_visibility(self, groups, expand, new_current)
TWidget *
pycim_get_widget(self)
 
pycim_view_close(self)
loader_input_t
loader_input_t_from_linput(linput)
loader_input_t
loader_input_t_from_cobject(pycobject)
loader_input_t
loader_input_t_from_fp(fp)
Variables
  BADADDR = 4294967295
  BADSEL = 4294967295
  SIZE_MAX = 18446744073709551615
  SEEK_SET = 0
  SEEK_CUR = 1
  SEEK_END = 2
  PLUGIN_MOD = 1
  PLUGIN_DRAW = 2
  PLUGIN_SEG = 4
  PLUGIN_UNL = 8
  PLUGIN_HIDE = 16
  PLUGIN_DBG = 32
  PLUGIN_PROC = 64
  PLUGIN_FIX = 128
  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
  ST_OVER_DEBUG_SEG = 1
step tracing will be disabled when IP is in a debugger segment
  ST_OVER_LIB_FUNC = 2
step tracing will be disabled when IP is in a library function
  has_mbcs = False
  IDAPython_Completion = <ida_idaapi.__IDAPython_Completion_Util...
  NW_OPENIDB = 1
Notify when the database is opened.
  NW_CLOSEIDB = 2
Notify when the database is closed.
  NW_INITIDA = 4
Notify when the IDA starts.
  NW_TERMIDA = 8
Notify when the IDA terminates.
  NW_REMOVE = 16
Use this flag with other flags to uninstall a notifywhen callback
  __package__ = None
Function Details

require(modulename, package=None)

 

Load, or reload a module.

When under heavy development, a user's tool might consist of multiple modules. If those are imported using the standard 'import' mechanism, there is no guarantee that the Python implementation will re-read and re-evaluate the module's Python code. In fact, it usually doesn't. What should be done instead is 'reload()'-ing that module.

This is a simple helper function that will do just that: In case the module doesn't exist, it 'import's it, and if it does exist, 'reload()'s it.

The importing module (i.e., the module calling require()) will have the loaded module bound to its globals(), under the name 'modulename'. (If require() is called from the command line, the importing module will be '__main__'.)

For more information, see: <http://www.hexblog.com/?p=749>.

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 (0-based)
  • 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, print_error=True)

 

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.

set_script_timeout(timeout)

 

Changes the script timeout value. The script wait box dialog will be hidden and shown again when the timeout elapses. See also disable_script_timeout.

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

disable_script_timeout()

 

Disables the script timeout and hides the script wait box. Calling set_script_timeout will not have any effects until the script is compiled and executed again

Returns:
None

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

notify_when(when, py_callable)

 
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

Returns: bool

Variables Details

IDAPython_Completion

Value:
<ida_idaapi.__IDAPython_Completion_Util object>

NW_OPENIDB

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

Value:
1

NW_CLOSEIDB

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

Value:
2

NW_INITIDA

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

Value:
4

NW_TERMIDA

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

Value:
8