Porting guide for IDA 7.4 IDAPython and Python 3
IDAPython developers
Scope of this guide
IDA 7.4 comes with the possibility of using Python 3.
Using Python 3 means that some code, which used to work, might require porting:
print()
becoming a function, not a statementxrange
becomingrange
__builtin__
becomingbuiltins
strings being unicode and not sets of bytes
integer division uses
//
and not/
map()
returning a map object, not a list{}.iteritems()
(and similar) are gonesome changes in the
import
mechanism...
Those are all well-documented Python 3 specifics, are thoroughly documented, and Python even provides tools to help with the transition.
This guide is not about those, but about IDAPython-specific changes to the API, but many of those being "ripples" of those Python 3 changes.
The guide
Note: that all qualified names below use their originating IDAPython module's name (e.g., ida_kernwin
) instead of the 'umbrella' idaapi
module.
Before | After | Notes |
---|---|---|
ida_bytes.data_format_t.printf | The | |
ida_bytes.get_bytes, ida_bytes.get_bytes_and_mask | Used to return a | |
ida_bytes.get_strlit_contents | Used to return a | |
ida_hexrays.mbl_array_t.serialize | Used to return a | |
ida_idp.IDP_Hooks.ev_assemble | Used to return a | |
ida_nalt.retrieve_input_file_md5 | Used to return a | |
ida_nalt.retrieve_input_file_sha256 | Used to return a | |
ida_netnode.netnode.getblob | Used to return a | |
ida_registry.reg_read_binary | Used to return a | |
ida_typeinf.tinfo_t.serialize | Used to return | |
ida_typeinf.get_numbered_type | Used to return | |
ida_ua.insn_t.insnpref | Used to return a | |
ida_ua.insn_t.segpref | Used to return a | |
| Used to return a | |
idautils.Functions.next |
| Required to turn the type into a proper iterator in Python 3 |
idautils.GetInputFileMD5 | Used to return a |
Last updated