I've recently started writing a few IDAPython plugins or scripts instead of using the native SDK, but I think I did not really figure out which module(s) are recommended to be imported. Typically, my script imports look somehow like this:
import ida_funcs
import ida_kernwin
import ida_lines
import ida_nalt
import ida_name
import ida_segment
import ida_struct
import idaapi
import idautils
import idc
from ida_bytes import *
from PyQt5 import QtCore, QtGui, QtWidgets
I've only just now realized that the idaapi
module imports all the single modules. For example, I can define an action handler as
class MyHandler(ida_kernwin.action_handler_t):
but also as
class MyHandler(idaapi.action_handler_t):
So far, I was always trying to find the module the members originate from, and replace idaapi
with the original module name where possible. But then I found BADADDR
to originate from an ida_idaapi
module, and the name feels so ridiculous, I wondered if I've been doing the right thing all along. The source and documentation on it is quite empty.
- Is it recommended to use
idaapi
instead of the single modules? Why doesidaapi
exist?
Then, on the other hand, there is idc
, which seems to provide IDC like functions, even with C style name casing. If I recall correctly, I read that the usage of this module is deprecated and only meant for quickly porting IDC scripts; the documentation prominently states
This file is subject to change without any notice.
Future versions of IDA may use other definitions.
- Should I use
ida_*
/idaapi
methods instead and, if possible, ignoreidc
completely?