mirror of
https://github.com/cemu-project/idapython.git
synced 2024-11-24 10:09:20 +01:00
fbb5bfabd6
What's new: - added the decompiler bindings - Expose simpleline_t type to IDAPython. That lets the user to set the bgcolor & text for each line in the decompilation. - Wrapped new functions from the IDA SDK Various fixes: for non-code locations, idc.GetOpnd() would create instructions instead of returning empty result - idb_event::area_cmt_changed was never received in IDB_Hooks (and descendants) - idb_event::ti_changed, and idb_event::op_ti_changed notifications were not accessible in IDAPython - op_t.value was truncated to 32 bits under IDA64. - print_tinfo() wouldn't return a valid string. - readsel2() was not usable. - read_selection() was buggy for 64-bit programs. - StructMembers() considered holes in structures, and didn't properly iterate through the whole structure definition. - There was no way to call calc_switch_cases() from IDAPython. - when using multi-select/multi-edit choosers, erroneous event codes could be sent at beginning & end of batch deletion of lines. - When, in a PluginForm#OnCreate, the layout of IDA was requested to change (for example by starting a debugging session), that PluginForm could be deleted and create an access violation. - tinfo_t objects created from IDAPython could cause an assertion failure at exit time. - Usage of IDAPython's DropdownListControl was broken.
63 lines
1.4 KiB
Python
63 lines
1.4 KiB
Python
""" It demonstrates how to iterate a cblock_t object.
|
|
|
|
Author: EiNSTeiN_ <einstein@g3nius.org>
|
|
|
|
This is a rewrite in Python of the vds7 example that comes with hexrays sdk.
|
|
"""
|
|
|
|
import idautils
|
|
import idaapi
|
|
import idc
|
|
|
|
import traceback
|
|
|
|
class cblock_visitor_t(idaapi.ctree_visitor_t):
|
|
|
|
def __init__(self):
|
|
idaapi.ctree_visitor_t.__init__(self, idaapi.CV_FAST)
|
|
return
|
|
|
|
def visit_insn(self, ins):
|
|
|
|
try:
|
|
if ins.op == idaapi.cit_block:
|
|
self.dump_block(ins.ea, ins.cblock)
|
|
except:
|
|
traceback.print_exc()
|
|
|
|
return 0
|
|
|
|
def dump_block(self, ea, b):
|
|
# iterate over all block instructions
|
|
print "dumping block %x" % (ea, )
|
|
for ins in b:
|
|
print " %x: insn %s" % (ins.ea, ins.opname)
|
|
|
|
return
|
|
|
|
class hexrays_callback_info(object):
|
|
|
|
def __init__(self):
|
|
return
|
|
|
|
def event_callback(self, event, *args):
|
|
|
|
try:
|
|
if event == idaapi.hxe_maturity:
|
|
cfunc, maturity = args
|
|
|
|
if maturity == idaapi.CMAT_BUILT:
|
|
cbv = cblock_visitor_t()
|
|
cbv.apply_to(cfunc.body, None)
|
|
|
|
except:
|
|
traceback.print_exc()
|
|
|
|
return 0
|
|
|
|
if idaapi.init_hexrays_plugin():
|
|
i = hexrays_callback_info()
|
|
idaapi.install_hexrays_callback(i.event_callback)
|
|
else:
|
|
print 'cblock visitor: hexrays is not available.'
|