cemu-idapython/swig/gdl.i
elias.bachaalany ac5d88a83b IDAPython 1.4.3:
- IDA 6.0 support
- Python CLI now prints expression evaluation result (no need to use print())
- Changed Alt-8 to Ctrl-F3 (because it conflicts with window switching key Alt+n)
- Added get_highlighted_identifier()
- Added PluginForm class to allow UI development with either PyQt4 or PySide
- Added idautils.Entries() to enumerate entrypoints
- idc / AddConst() was broken
- Minor fixes
2010-11-10 13:58:08 +00:00

92 lines
2.6 KiB
OpenEdge ABL

%ignore cancellable_graph_t;
%ignore gdl_graph_t;
%ignore intmap_t;
%ignore intset_t;
%ignore intseq_t;
%ignore node_set_t;
%ignore qflow_chart_t::blocks;
%ignore flow_chart_t;
%ignore default_graph_format;
%ignore setup_graph_subsystem;
%ignore qbasic_block_t::succ;
%ignore qbasic_block_t::pred;
%include "gdl.hpp"
%extend qflow_chart_t
{
qbasic_block_t *__getitem__(int n)
{
return &(self->blocks[n]);
}
}
%pythoncode %{
#<pycode(py_gdl)>
# -----------------------------------------------------------------------
class BasicBlock:
"""Basic block class. It is returned by the Flowchart class"""
def __init__(self, id, bb, f):
self._f = f
self.id = id
"""Basic block ID"""
self.startEA = bb.startEA
"""startEA of basic block"""
self.endEA = bb.endEA
"""endEA of basic block"""
self.type = self._f._q.calc_block_type(self.id)
"""Block type (check fc_block_type_t enum)"""
def preds(self):
"""
Iterates the predecessors list
"""
q = self._f._q
for i in xrange(0, self._f._q.npred(self.id)):
yield self._f[q.pred(self.id, i)]
def succs(self):
"""
Iterates the successors list
"""
q = self._f._q
for i in xrange(0, q.nsucc(self.id)):
yield self._f[q.succ(self.id, i)]
# -----------------------------------------------------------------------
class FlowChart:
"""
Flowchart class used to determine basic blocks.
Check ex_gdl_qflow_chart.py for sample usage.
"""
def __init__(self, f=None, bounds=None, flags=0):
"""
Constructor
@param f: A func_t type, use get_func(ea) to get a reference
@param bounds: A tuple of the form (start, end). Used if "f" is None
@param flags: one of the FC_xxxx flags. One interesting flag is FC_PREDS
"""
if (not f) and (not bounds or type(bounds) != types.TupleType):
raise Exception("Please specifiy either a function or start/end pair")
if not bounds:
bounds = (BADADDR, BADADDR)
# create the flowchart
self._q = qflow_chart_t("", f, bounds[0], bounds[1], flags)
self.size = self._q.size()
def refresh():
self._q.refresh()
self.size = self._q.size()
def __getitem__(self, index):
"""
Returns a basic block
@return: BasicBlock
"""
if index >= self.size:
raise StopIteration
return BasicBlock(index, self._q[index], self)
#</pycode(py_gdl)>
%}