mirror of
https://github.com/cemu-project/idapython.git
synced 2024-11-28 03:54:18 +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.
67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
# -----------------------------------------------------------------------
|
|
# This is an example illustrating how to use the user graphing functionality
|
|
# in Python
|
|
# (c) Hex-Rays
|
|
#
|
|
from idaapi import GraphViewer
|
|
|
|
class MyGraph(GraphViewer):
|
|
def __init__(self, funcname, result):
|
|
GraphViewer.__init__(self, "call graph of " + funcname)
|
|
self.funcname = funcname
|
|
self.result = result
|
|
|
|
def OnRefresh(self):
|
|
self.Clear()
|
|
id = self.AddNode(self.funcname)
|
|
for x in self.result.keys():
|
|
callee = self.AddNode(x)
|
|
self.AddEdge(id, callee)
|
|
|
|
return True
|
|
|
|
def OnGetText(self, node_id):
|
|
return str(self[node_id])
|
|
|
|
def OnCommand(self, cmd_id):
|
|
"""
|
|
Triggered when a menu command is selected through the menu or its hotkey
|
|
@return: None
|
|
"""
|
|
if self.cmd_close == cmd_id:
|
|
self.Close()
|
|
return
|
|
|
|
print "command:", cmd_id
|
|
|
|
def Show(self):
|
|
if not GraphViewer.Show(self):
|
|
return False
|
|
self.cmd_close = self.AddCommand("Close", "F2")
|
|
if self.cmd_close == 0:
|
|
print "Failed to add popup menu item!"
|
|
return True
|
|
|
|
def show_graph():
|
|
f = idaapi.get_func(here())
|
|
if not f:
|
|
print "Must be in a function"
|
|
return
|
|
# Iterate through all function instructions and take only call instructions
|
|
result = {}
|
|
for x in [x for x in FuncItems(f.startEA) if idaapi.is_call_insn(x)]:
|
|
for xref in XrefsFrom(x, idaapi.XREF_FAR):
|
|
if not xref.iscode: continue
|
|
t = GetFunctionName(xref.to)
|
|
if not t:
|
|
t = hex(xref.to)
|
|
result[t] = True
|
|
g = MyGraph(GetFunctionName(f.startEA), result)
|
|
if g.Show():
|
|
return g
|
|
else:
|
|
return None
|
|
|
|
g = show_graph()
|
|
if g:
|
|
print "Graph created and displayed!" |