Module ida_idaapi

Global Variables

BADADDR

BADADDR = 18446744073709551615

BADADDR32

BADADDR32 = 4294967295

BADADDR64

BADADDR64 = 18446744073709551615

BADSEL

BADSEL = 18446744073709551615

HBF_CALL_WITH_NEW_EXEC

HBF_CALL_WITH_NEW_EXEC = 1

HBF_VOLATILE_METHOD_SET

HBF_VOLATILE_METHOD_SET = 2

NW_CLOSEIDB

NW_CLOSEIDB = 2

NW_INITIDA

NW_INITIDA = 4

NW_OPENIDB

NW_OPENIDB = 1

NW_REMOVE

NW_REMOVE = 16

NW_TERMIDA

NW_TERMIDA = 8

PLUGIN_DBG

PLUGIN_DBG = 32

PLUGIN_DRAW

PLUGIN_DRAW = 2

PLUGIN_FIX

PLUGIN_FIX = 128

PLUGIN_HIDE

PLUGIN_HIDE = 16

PLUGIN_KEEP

PLUGIN_KEEP = 2

PLUGIN_MOD

PLUGIN_MOD = 1

PLUGIN_MULTI

PLUGIN_MULTI = 256

PLUGIN_OK

PLUGIN_OK = 1

PLUGIN_PROC

PLUGIN_PROC = 64

PLUGIN_SEG

PLUGIN_SEG = 4

PLUGIN_SKIP

PLUGIN_SKIP = 0

PLUGIN_UNL

PLUGIN_UNL = 8

PY_ICID_BYREF

PY_ICID_BYREF = 1

PY_ICID_INT64

PY_ICID_INT64 = 0

PY_ICID_OPAQUE

PY_ICID_OPAQUE = 2

SEEK_CUR

SEEK_CUR = 1

SEEK_END

SEEK_END = 2

SEEK_SET

SEEK_SET = 0

SIZE_MAX

SIZE_MAX = 18446744073709551615

ST_OVER_DEBUG_SEG

ST_OVER_DEBUG_SEG = 1

ST_OVER_LIB_FUNC

ST_OVER_LIB_FUNC = 2

Functions

IDAPython_ExecScript(path, g, print_error=True)

Run the specified script.

This function is used by the low-level plugin code.

IDAPython_ExecSystem(cmd)

Executes a command with popen().

IDAPython_FormatExc(etype, value=None, tb=None, limit=None)

This function is used to format an exception given the values returned by a PyErr_Fetch()

IDAPython_LoadProcMod(path, g, print_error=True)

Load processor module.

IDAPython_UnLoadProcMod(script, g, print_error=True)

Unload processor module.

TRUNC(ea)

Truncate EA for the current application bitness

as_UTF16(s)

Convenience function to convert a string into appropriate unicode format

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 \x00 and returns the string value up to that point.

as_int32(v)

Returns a number as a signed int32 number

as_signed(v, nbits=32)

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

as_uint32(v)

Returns a number as an unsigned int32 number

as_unicode(s)

Convenience function to convert a string into appropriate unicode format

copy_bits(v, s, e=-1)

Copy bits from a value v: the value s: starting bit (0-based) e: ending bit

disable_script_timeout() ‑> void

disable_script_timeout() Disables the script timeout and hides the script wait box. Calling L{set_script_timeout} will not have any effects until the script is compiled and executed again

return: None

enable_extlang_python(enable: bool) ‑> void

enable_extlang_python(enable) Enables or disables Python extlang. When enabled, all expressions will be evaluated by Python.

enable: Set to True to enable, False otherwise

enable_python_cli(enable: bool) ‑> void

enable_python_cli(enable)

enable: bool

format_basestring(_in: PyObject *) ‑> PyObject *

format_basestring(_in) -> str

_in: PyObject *

notify_when(when, callback)

Register a callback that will be called when an event happens. when: one of NW_XXXX constants 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

parse_command_line3(cmdline: char const *) ‑> PyObject *

parse_command_line3(cmdline) -> PyObject *

cmdline: char const *

pycim_get_widget(_self: PyObject *) ‑> TWidget *

pycim_get_widget(_self) -> TWidget *

self: PyObject *

pycim_view_close(_self: PyObject *) ‑> void

pycim_view_close(_self)

self: PyObject *

pygc_create_groups(_self: PyObject *, groups_infos: PyObject *) ‑> PyObject *

pygc_create_groups(_self, groups_infos) -> [int, ...] or None

self: PyObject *
groups_infos: PyObject *

pygc_delete_groups(_self: PyObject *, groups: PyObject *, new_current: PyObject *) ‑> PyObject *

pygc_delete_groups(_self, groups, new_current) -> bool

self: PyObject *
groups: PyObject *
new_current: PyObject *

pygc_refresh(_self: PyObject *) ‑> void

pygc_refresh(_self)

self: PyObject *

pygc_set_groups_visibility(_self: PyObject *, groups: PyObject *, expand: PyObject *, new_current: PyObject *) ‑> PyObject *

pygc_set_groups_visibility(_self, groups, expand, new_current) -> bool

self: PyObject *
groups: PyObject *
expand: PyObject *
new_current: PyObject *

replfun(func)

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.

set_script_timeout(timeout: int) ‑> int

set_script_timeout(timeout) -> int Changes the script timeout value. The script wait box dialog will be hidden and shown again when the timeout elapses. See also L{disable_script_timeout}.

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

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.

Classes

IDAPython_displayhook()

:

Methods

  • displayhook(self, item)


  • format_item(self, num_printer, storage, item)


  • format_seq(self, num_printer, storage, item, opn, cls)


PyIdc_cvt_int64__(v)

: Helper class for explicitly representing VT_INT64 values

Ancestors (in MRO)

* ida_idaapi.pyidc_cvt_helper__

PyIdc_cvt_refclass__(v)

: Helper class for representing references to immutable objects

Ancestors (in MRO)

* ida_idaapi.pyidc_cvt_helper__

Methods

  • cstr(self) Returns the string as a C string (up to the zero termination)


loader_input_t(pycapsule: PyObject * = None)

: A helper class to work with linput_t related functions. This class is also used by file loaders scripts.

__init__(self, pycapsule=None) -> loader_input_t

 pycapsule: PyObject *

Static methods

  • from_capsule(pycapsule: PyObject *) ‑> loader_input_t * from_capsule(pycapsule) -> loader_input_t

    pycapsule: PyObject *


  • from_fp(fp: FILE *) ‑> loader_input_t from_fp(fp) -> loader_input_t A static method to construct an instance from a FILE

    fp: FILE *


  • from_linput(linput: linput_t *) ‑> loader_input_t * from_linput(linput) -> loader_input_t

    linput: linput_t *


Methods

  • close(self) ‑> void close(self) Closes the file


  • file2base(self, pos: int64, ea1: ea_t, ea2: ea_t, patchable: int) ‑> int file2base(self, pos, ea1, ea2, patchable) -> int Load portion of file into the database This function will include (ea1..ea2) into the addressing space of the program (make it enabled)

    pos: position in the file ea1: ..ea2): range of destination linear addresses ea1: ..ea2): range of destination linear addresses patchable: should the kernel remember correspondance of file offsets to linear addresses. return: 1-ok,0-read error, a warning is displayed


  • filename(self) ‑> PyObject * filename(self) -> PyObject *


  • get_byte(self) ‑> PyObject * get_byte(self) -> PyObject * Reads a single byte from the file. Returns None if EOF or the read byte


  • get_linput(self) ‑> linput_t * get_linput(self) -> linput_t *


  • gets(self, len: size_t) ‑> PyObject * gets(self, len) -> str Reads a line from the input file. Returns the read line or None

    len: size_t


  • getz(self, sz: size_t, fpos: int64 = -1) ‑> PyObject * getz(self, sz, fpos=-1) -> PyObject Returns a zero terminated string at the given position

    sz: maximum size of the string fpos: if != -1 then seek will be performed before reading return: The string or None on failure.


  • open(self, filename: char const *, remote: bool = False) ‑> bool open(self, filename, remote=False) -> bool Opens a file (or a remote file)

    filename: char const * remote: bool return: Boolean


  • open_memory(self, start: ea_t, size: asize_t = 0) ‑> bool open_memory(self, start, size=0) -> bool Create a linput for process memory (By internally calling idaapi.create_memory_linput()) This linput will use dbg->read_memory() to read data

    start: starting address of the input size: size of the memory range to represent as linput if unknown, may be passed as 0


  • opened(self) ‑> bool opened(self) -> bool Checks if the file is opened or not


  • read(self, *args) ‑> PyObject * read(self, size=size_t(-1)) -> PyObject Read up to size bytes (all data if size is negative). Return an empty bytes object on EOF.

    size: size_t


  • readbytes(self, size: size_t, big_endian: bool) ‑> PyObject * readbytes(self, size, big_endian) -> PyObject * Similar to read() but it respect the endianness

    size: size_t big_endian: bool


  • seek(self, *args) ‑> int64 seek(self, pos, whence=SEEK_SET) -> int64 Set input source position

    pos: int64 whence: int return: the new position (not 0 as fseek!)


  • set_linput(self, linput: linput_t *) ‑> void set_linput(self, linput) Links the current loader_input_t instance to a linput_t instance

    linput: linput_t *


  • size(self) ‑> int64 size(self) -> int64


  • tell(self) ‑> int64 tell(self) -> int64 Returns the current position


object_t(**kwds)

: Helper class used to initialize empty objects

plugin_t()

: Base class for all scripted plugins.

Ancestors (in MRO)

* ida_idaapi.pyidc_opaque_object_t

Methods

  • run(self, arg)


  • term(self)


plugmod_t()

: Base class for all scripted multi-plugins.

Ancestors (in MRO)

* ida_idaapi.pyidc_opaque_object_t

py_clinked_object_t(lnk=None)

: This is a utility and base class for C linked objects

Ancestors (in MRO)

* ida_idaapi.pyidc_opaque_object_t

Descendants

* ida_kernwin.textctrl_info_t
* ida_pro._qstrvec_t

Instance variables

  • clink


  • clink_ptr


Methods

  • assign(self, other) Overwrite me. This method allows you to assign an instance contents to anothers return: Boolean


  • copy(self) Returns a new copy of this class


pyidc_cvt_helper__(cvt_id, value)

: 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. This object is characterized by its special attribute and its value

Descendants

* ida_idaapi.PyIdc_cvt_int64__
* ida_idaapi.PyIdc_cvt_refclass__

Instance variables

  • value


pyidc_opaque_object_t()

: This is the base class for all Python<->IDC opaque objects

Descendants

* ida_idaapi.plugin_t
* ida_idaapi.plugmod_t
* ida_idaapi.py_clinked_object_t
* ida_kernwin.cli_t

Last updated