mirror of
https://github.com/cemu-project/idapython.git
synced 2024-12-27 10:11:53 +01:00
Contributed by EiNSTeiN_:
- added support for 'long' addresses - updated copyright notice in hexrays.i - added methods to remove or insert elements in the qlist<cinsn_t> list - added support for ctree_visitor_t / ctree_parentee_t / cfunc_parentee_t / user_lvar_visitor_t - updated vds3 sample - added vds4 and vds7 python samples (ported from their C++ counter parts)
This commit is contained in:
parent
7eb6d04c6e
commit
c88a77e809
@ -88,41 +88,74 @@ class hexrays_callback_info(object):
|
|||||||
self.save()
|
self.save()
|
||||||
return
|
return
|
||||||
|
|
||||||
def invert_if_event(self, vu):
|
def find_if_statement(self, vu):
|
||||||
|
|
||||||
vu.get_current_item(idaapi.USE_KEYBOARD)
|
vu.get_current_item(idaapi.USE_KEYBOARD)
|
||||||
item = vu.item
|
item = vu.item
|
||||||
|
|
||||||
|
if item.is_citem() and item.it.op == idaapi.cit_if and item.it.to_specific_type.cif.ielse is not None:
|
||||||
|
return item.it.to_specific_type
|
||||||
|
|
||||||
|
if vu.tail.citype == idaapi.VDI_TAIL and vu.tail.loc.itp == idaapi.ITP_ELSE:
|
||||||
|
# for tail marks, we know only the corresponding ea,
|
||||||
|
# not the pointer to if-statement
|
||||||
|
# find it by walking the whole ctree
|
||||||
|
class if_finder_t(idaapi.ctree_visitor_t):
|
||||||
|
def __init__(self, ea):
|
||||||
|
idaapi.ctree_visitor_t.__init__(self, idaapi.CV_FAST | idaapi.CV_INSNS)
|
||||||
|
|
||||||
|
self.ea = ea
|
||||||
|
self.found = None
|
||||||
|
return
|
||||||
|
|
||||||
|
def visit_insn(self, i):
|
||||||
|
if i.op == idaapi.cit_if and i.ea == self.ea:
|
||||||
|
self.found = i
|
||||||
|
return 1 # stop enumeration
|
||||||
|
return 0
|
||||||
|
|
||||||
|
iff = if_finder_t(vu.tail.loc.ea)
|
||||||
|
if iff.apply_to(vu.cfunc.body, None):
|
||||||
|
return iff.found
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def invert_if_event(self, vu):
|
||||||
|
|
||||||
cfunc = vu.cfunc.__deref__()
|
cfunc = vu.cfunc.__deref__()
|
||||||
|
|
||||||
if item.citype != idaapi.VDI_EXPR:
|
i = self.find_if_statement(vu)
|
||||||
|
if not i:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.invert_if(cfunc, item.it.to_specific_type):
|
if self.invert_if(cfunc, i):
|
||||||
vu.refresh_ctext()
|
vu.refresh_ctext()
|
||||||
|
|
||||||
self.add_location(item.it.ea)
|
self.add_location(i.ea)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def restore(self, cfunc):
|
def restore(self, cfunc):
|
||||||
|
|
||||||
#~ print 'restoring invert-if for %x' % (cfunc.entry_ea, )
|
class visitor(idaapi.ctree_visitor_t):
|
||||||
|
|
||||||
|
def __init__(self, inverter, cfunc):
|
||||||
|
idaapi.ctree_visitor_t.__init__(self, idaapi.CV_FAST | idaapi.CV_INSNS)
|
||||||
|
self.inverter = inverter
|
||||||
|
self.cfunc = cfunc
|
||||||
|
return
|
||||||
|
|
||||||
|
def visit_insn(self, i):
|
||||||
|
try:
|
||||||
|
if i.op == idaapi.cit_if and i.ea in self.inverter.stored:
|
||||||
|
self.inverter.invert_if(self.cfunc, i)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
return 0 # continue enumeration
|
||||||
|
|
||||||
str(cfunc) # generate treeitems.
|
visitor(self, cfunc).apply_to(cfunc.body, None)
|
||||||
|
|
||||||
restored = False
|
return
|
||||||
|
|
||||||
for item in cfunc.treeitems:
|
|
||||||
item = item.to_specific_type
|
|
||||||
if item.opname == 'if' and item.ea in self.stored:
|
|
||||||
if self.invert_if(cfunc, item):
|
|
||||||
restored = True
|
|
||||||
#~ print 'restore invert-if location %x' % (item.ea, )
|
|
||||||
else:
|
|
||||||
print 'invert-if location %x: NOT RESTORED' % (item.ea, )
|
|
||||||
|
|
||||||
return restored
|
|
||||||
|
|
||||||
def menu_callback(self):
|
def menu_callback(self):
|
||||||
try:
|
try:
|
||||||
@ -142,7 +175,7 @@ class hexrays_callback_info(object):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
elif event == idaapi.hxe_right_click:
|
elif event == idaapi.hxe_right_click:
|
||||||
self.vu = args[0]
|
self.vu, = args
|
||||||
idaapi.add_custom_viewer_popup_item(self.vu.ct, "Invert then/else", "I", self.menu_callback)
|
idaapi.add_custom_viewer_popup_item(self.vu.ct, "Invert then/else", "I", self.menu_callback)
|
||||||
|
|
||||||
elif event == idaapi.hxe_maturity:
|
elif event == idaapi.hxe_maturity:
|
||||||
|
123
examples/vds4.py
Normal file
123
examples/vds4.py
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
""" Print user-defined details to the output window.
|
||||||
|
|
||||||
|
Author: EiNSTeiN_ <einstein@g3nius.org>
|
||||||
|
|
||||||
|
This is a rewrite in Python of the vds4 example that comes with hexrays sdk.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import idautils
|
||||||
|
import idaapi
|
||||||
|
import idc
|
||||||
|
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
def run():
|
||||||
|
|
||||||
|
cfunc = idaapi.decompile(idaapi.get_screen_ea())
|
||||||
|
if not cfunc:
|
||||||
|
print 'Please move the cursor into a function.'
|
||||||
|
return
|
||||||
|
|
||||||
|
entry_ea = cfunc.entry_ea
|
||||||
|
print "Dump of user-defined information for function at %x" % (entry_ea, )
|
||||||
|
|
||||||
|
# Display user defined labels.
|
||||||
|
labels = idaapi.restore_user_labels(entry_ea);
|
||||||
|
if labels is not None:
|
||||||
|
print "------- %u user defined labels" % (len(labels), )
|
||||||
|
for org_label, name in labels.iteritems():
|
||||||
|
print "Label %d: %s" % (org_label, str(name))
|
||||||
|
idaapi.user_labels_free(labels)
|
||||||
|
|
||||||
|
# Display user defined comments
|
||||||
|
cmts = idaapi.restore_user_cmts(entry_ea);
|
||||||
|
if cmts is not None:
|
||||||
|
print "------- %u user defined comments" % (len(cmts), )
|
||||||
|
for tl, cmt in cmts.iteritems():
|
||||||
|
print "Comment at %x, preciser %x:\n%s\n" % (tl.ea, tl.itp, str(cmt))
|
||||||
|
idaapi.user_cmts_free(cmts)
|
||||||
|
|
||||||
|
# Display user defined citem iflags
|
||||||
|
iflags = idaapi.restore_user_iflags(entry_ea)
|
||||||
|
if iflags is not None:
|
||||||
|
print "------- %u user defined citem iflags" % (len(iflags), )
|
||||||
|
for cl, t in iflags.iteritems():
|
||||||
|
print "%a(%d): %08X%s" % (cl.ea, cl.op, f, " CIT_COLLAPSED" if f & CIT_COLLAPSED else "")
|
||||||
|
idaapi.user_iflags_free(iflags)
|
||||||
|
|
||||||
|
# Display user defined number formats
|
||||||
|
numforms = idaapi.restore_user_numforms(entry_ea)
|
||||||
|
if numforms is not None:
|
||||||
|
print "------- %u user defined number formats" % (len(numforms), )
|
||||||
|
for ol, nf in numforms.iteritems():
|
||||||
|
|
||||||
|
print "Number format at %a, operand %d: %s" % (ol.ea, ol.opnum, "negated " if (nf.props & NF_NEGATE) != 0 else "")
|
||||||
|
|
||||||
|
if nf.isEnum():
|
||||||
|
print "enum %s (serial %d)" % (str(nf.type_name), nf.serial)
|
||||||
|
|
||||||
|
elif nf.isChar():
|
||||||
|
print "char"
|
||||||
|
|
||||||
|
elif nf.isStroff():
|
||||||
|
print "struct offset %s" % (str(nf.type_name), )
|
||||||
|
|
||||||
|
else:
|
||||||
|
print "number base=%d" % (idaapi.getRadix(nf.flags, ol.opnum), )
|
||||||
|
|
||||||
|
idaapi.user_numforms_free(numforms)
|
||||||
|
|
||||||
|
# Display user-defined local variable information
|
||||||
|
# First defined the visitor class
|
||||||
|
class dump_lvar_info_t(idaapi.user_lvar_visitor_t):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
idaapi.user_lvar_visitor_t.__init__(self)
|
||||||
|
self.displayed_header = False
|
||||||
|
return
|
||||||
|
|
||||||
|
def get_info_qty_for_saving(self):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def get_info_for_saving(self, lv):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def handle_retrieved_info(self, lv):
|
||||||
|
|
||||||
|
try:
|
||||||
|
if not self.displayed_header:
|
||||||
|
self.displayed_header = True;
|
||||||
|
print "------- User defined local variable information"
|
||||||
|
|
||||||
|
print "Lvar defined at %x" % (lv.ll.defea, )
|
||||||
|
|
||||||
|
if len(str(lv.name)):
|
||||||
|
print " Name: %s" % (str(lv.name), )
|
||||||
|
|
||||||
|
if len(str(lv.type)):
|
||||||
|
#~ print_type_to_one_line(buf, sizeof(buf), idati, .c_str());
|
||||||
|
print " Type: %s" % (str(lv.type), )
|
||||||
|
|
||||||
|
if len(str(lv.cmt)):
|
||||||
|
print " Comment: %s" % (str(lv.cmt), )
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def handle_retrieved_mapping(self, lm):
|
||||||
|
return 0
|
||||||
|
|
||||||
|
def get_info_mapping_for_saving(self):
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Now iterate over all user definitions
|
||||||
|
dli = dump_lvar_info_t();
|
||||||
|
idaapi.restore_user_lvar_settings(entry_ea, dli)
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
if idaapi.init_hexrays_plugin():
|
||||||
|
run()
|
||||||
|
else:
|
||||||
|
print 'dump user info: hexrays is not available.'
|
62
examples/vds7.py
Normal file
62
examples/vds7.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
""" 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.'
|
182
swig/hexrays.i
182
swig/hexrays.i
@ -2,6 +2,7 @@
|
|||||||
// SWIG bindings for Hexray Decompiler's hexrays.hpp
|
// SWIG bindings for Hexray Decompiler's hexrays.hpp
|
||||||
//
|
//
|
||||||
// Author: EiNSTeiN_ <einstein@g3nius.org>
|
// Author: EiNSTeiN_ <einstein@g3nius.org>
|
||||||
|
// Copyright (C) 2013 ESET
|
||||||
//
|
//
|
||||||
// Integrated into IDAPython project by the IDAPython Team <idapython@googlegroups.com>
|
// Integrated into IDAPython project by the IDAPython Team <idapython@googlegroups.com>
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
@ -153,6 +154,11 @@ public:
|
|||||||
typedef intvec_t svalvec_t; // vector of signed values
|
typedef intvec_t svalvec_t; // vector of signed values
|
||||||
typedef intvec_t eavec_t;// vector of addresses
|
typedef intvec_t eavec_t;// vector of addresses
|
||||||
|
|
||||||
|
// director classes make it possible to override virtual functions from python.
|
||||||
|
%feature("director") ctree_visitor_t;
|
||||||
|
%feature("director") ctree_parentee_t;
|
||||||
|
%feature("director") cfunc_parentee_t;
|
||||||
|
%feature("director") user_lvar_visitor_t;
|
||||||
|
|
||||||
// hexrays templates
|
// hexrays templates
|
||||||
%template(user_numforms_t) std::map<operand_locator_t, number_format_t>;
|
%template(user_numforms_t) std::map<operand_locator_t, number_format_t>;
|
||||||
@ -240,7 +246,7 @@ void qswap(cinsn_t &a, cinsn_t &b);
|
|||||||
%{
|
%{
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
static int hexrays_cblist_py_call(PyObject *fct, PyObject *args)
|
static int hexrays_python_call(PyObject *fct, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *resultobj;
|
PyObject *resultobj;
|
||||||
int result;
|
int result;
|
||||||
@ -264,7 +270,7 @@ static int hexrays_cblist_py_call(PyObject *fct, PyObject *args)
|
|||||||
if (SWIG_IsOK(ecode1))
|
if (SWIG_IsOK(ecode1))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
msg("IDAPython: Hex-rays python callback returned non-integer, value ignored.\n");
|
msg("IDAPython: Hex-rays python callback returned non-integer; value ignored.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +280,7 @@ static bool idaapi __python_custom_viewer_popup_item_callback(void *ud)
|
|||||||
int ret;
|
int ret;
|
||||||
PyObject *fct = (PyObject *)ud;
|
PyObject *fct = (PyObject *)ud;
|
||||||
|
|
||||||
ret = hexrays_cblist_py_call(fct, NULL);
|
ret = hexrays_python_call(fct, NULL);
|
||||||
|
|
||||||
return ret ? true : false;
|
return ret ? true : false;
|
||||||
}
|
}
|
||||||
@ -296,18 +302,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
{
|
{
|
||||||
cfunc_t *arg0 = va_arg(va, cfunc_t *);
|
cfunc_t *arg0 = va_arg(va, cfunc_t *);
|
||||||
ctree_maturity_t arg1 = va_argi(va, ctree_maturity_t);
|
ctree_maturity_t arg1 = va_argi(va, ctree_maturity_t);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_cfunc_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_cfunc_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iOi)", event, arg0obj, arg1);
|
args = Py_BuildValue("(iOi)", event, arg0obj, arg1);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
|
||||||
Py_DECREF(args);
|
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_cfunc_t, SWIG_POINTER_DISOWN | 0 ))) {
|
Py_XDECREF(arg0obj);
|
||||||
msg("error deleting callback argument #0 cfunc_t");
|
Py_DECREF(args);
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_interr:
|
case hxe_interr:
|
||||||
@ -317,7 +318,7 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
int arg0 = va_argi(va, int);
|
int arg0 = va_argi(va, int);
|
||||||
|
|
||||||
args = Py_BuildValue("(ii)", event, arg0);
|
args = Py_BuildValue("(ii)", event, arg0);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
}
|
}
|
||||||
@ -331,24 +332,15 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
{
|
{
|
||||||
cfunc_t *arg0 = va_arg(va, cfunc_t *);
|
cfunc_t *arg0 = va_arg(va, cfunc_t *);
|
||||||
vc_printer_t *arg1 = va_arg(va, vc_printer_t *);
|
vc_printer_t *arg1 = va_arg(va, vc_printer_t *);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_cfunc_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_cfunc_t, 0 );
|
||||||
PyObject *arg1obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg1), SWIGTYPE_p_vc_printer_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg1obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg1), SWIGTYPE_p_vc_printer_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iOO)", event, arg0obj, arg1obj);
|
args = Py_BuildValue("(iOO)", event, arg0obj, arg1obj);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
//Py_XDECREF(arg1obj);
|
Py_XDECREF(arg1obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_cfunc_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 cfunc_t");
|
|
||||||
PyErr_Clear();
|
|
||||||
}
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg1obj, &argp,SWIGTYPE_p_vc_printer_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #1 vc_printer_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -358,18 +350,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
///< vdui_t *vu
|
///< vdui_t *vu
|
||||||
{
|
{
|
||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iO)", event, arg0obj);
|
args = Py_BuildValue("(iO)", event, arg0obj);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_switch_pseudocode:
|
case hxe_switch_pseudocode:
|
||||||
@ -379,18 +366,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
///< vdui_t *vu
|
///< vdui_t *vu
|
||||||
{
|
{
|
||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iO)", event, arg0obj);
|
args = Py_BuildValue("(iO)", event, arg0obj);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_refresh_pseudocode:
|
case hxe_refresh_pseudocode:
|
||||||
@ -399,18 +381,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
///< See also hxe_text_ready, which happens earlier
|
///< See also hxe_text_ready, which happens earlier
|
||||||
{
|
{
|
||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iO)", event, arg0obj);
|
args = Py_BuildValue("(iO)", event, arg0obj);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_close_pseudocode:
|
case hxe_close_pseudocode:
|
||||||
@ -418,18 +395,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
///< vdui_t *vu
|
///< vdui_t *vu
|
||||||
{
|
{
|
||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iO)", event, arg0obj);
|
args = Py_BuildValue("(iO)", event, arg0obj);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_keyboard:
|
case hxe_keyboard:
|
||||||
@ -442,18 +414,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
int arg1 = va_argi(va, int);
|
int arg1 = va_argi(va, int);
|
||||||
int arg2 = va_argi(va, int);
|
int arg2 = va_argi(va, int);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iOii)", event, arg0obj, arg1, arg2);
|
args = Py_BuildValue("(iOii)", event, arg0obj, arg1, arg2);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_right_click:
|
case hxe_right_click:
|
||||||
@ -461,18 +428,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
///< vdui_t *vu
|
///< vdui_t *vu
|
||||||
{
|
{
|
||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iO)", event, arg0obj);
|
args = Py_BuildValue("(iO)", event, arg0obj);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_double_click:
|
case hxe_double_click:
|
||||||
@ -483,18 +445,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
{
|
{
|
||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
int arg1 = va_argi(va, int);
|
int arg1 = va_argi(va, int);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iOi)", event, arg0obj, arg1);
|
args = Py_BuildValue("(iOi)", event, arg0obj, arg1);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_curpos:
|
case hxe_curpos:
|
||||||
@ -503,18 +460,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
///< vdui_t *vu
|
///< vdui_t *vu
|
||||||
{
|
{
|
||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iO)", event, arg0obj);
|
args = Py_BuildValue("(iO)", event, arg0obj);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_create_hint:
|
case hxe_create_hint:
|
||||||
@ -529,18 +481,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
///< appended by the decompiler
|
///< appended by the decompiler
|
||||||
{
|
{
|
||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iO)", event, arg0obj);
|
args = Py_BuildValue("(iO)", event, arg0obj);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case hxe_text_ready:
|
case hxe_text_ready:
|
||||||
@ -551,18 +498,13 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
///< COLOR_ADDR is used to store pointers to ctree elements
|
///< COLOR_ADDR is used to store pointers to ctree elements
|
||||||
{
|
{
|
||||||
vdui_t *arg0 = va_arg(va, vdui_t *);
|
vdui_t *arg0 = va_arg(va, vdui_t *);
|
||||||
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, SWIG_POINTER_OWN | 0 );
|
PyObject *arg0obj = SWIG_NewPointerObj(SWIG_as_voidptr(arg0), SWIGTYPE_p_vdui_t, 0 );
|
||||||
|
|
||||||
args = Py_BuildValue("(iO)", event, arg0obj);
|
args = Py_BuildValue("(iO)", event, arg0obj);
|
||||||
ret = hexrays_cblist_py_call(fct, args);
|
ret = hexrays_python_call(fct, args);
|
||||||
|
|
||||||
//Py_XDECREF(arg0obj);
|
Py_XDECREF(arg0obj);
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
|
||||||
if (!SWIG_IsOK(SWIG_ConvertPtr(arg0obj, &argp,SWIGTYPE_p_vdui_t, SWIG_POINTER_DISOWN | 0 ))) {
|
|
||||||
msg("error deleting callback argument #0 vdui_t");
|
|
||||||
//PyErr_Clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -579,8 +521,6 @@ static int idaapi __hexrays_python_callback(void *ud, hexrays_event_t event, va_
|
|||||||
%ignore init_hexrays_plugin;
|
%ignore init_hexrays_plugin;
|
||||||
%rename(init_hexrays_plugin) __init_hexrays_plugin;
|
%rename(init_hexrays_plugin) __init_hexrays_plugin;
|
||||||
|
|
||||||
%rename(add_custom_viewer_popup_item) __add_custom_viewer_popup_item;
|
|
||||||
|
|
||||||
%ignore add_custom_viewer_popup_item;
|
%ignore add_custom_viewer_popup_item;
|
||||||
%rename(add_custom_viewer_popup_item) __add_custom_viewer_popup_item;
|
%rename(add_custom_viewer_popup_item) __add_custom_viewer_popup_item;
|
||||||
|
|
||||||
@ -673,7 +613,7 @@ class DecompilationFailure(Exception):
|
|||||||
|
|
||||||
# ---------------------------------------------------------------------
|
# ---------------------------------------------------------------------
|
||||||
def decompile(ea, hf=None):
|
def decompile(ea, hf=None):
|
||||||
if type(ea) == int:
|
if isinstance(ea, (int, long)):
|
||||||
func = idaapi.get_func(ea)
|
func = idaapi.get_func(ea)
|
||||||
if not func: return
|
if not func: return
|
||||||
elif type(ea) == idaapi.func_t:
|
elif type(ea) == idaapi.func_t:
|
||||||
@ -749,7 +689,7 @@ def citem_to_specific_type(self):
|
|||||||
elif self.op >= cit_empty and self.op < cit_end:
|
elif self.op >= cit_empty and self.op < cit_end:
|
||||||
return self.cinsn
|
return self.cinsn
|
||||||
|
|
||||||
raise RuntimeError('unknown op type')
|
raise RuntimeError('unknown op type %s' % (repr(self.op), ))
|
||||||
citem_t.to_specific_type = property(citem_to_specific_type)
|
citem_t.to_specific_type = property(citem_to_specific_type)
|
||||||
|
|
||||||
""" array used for translating cinsn_t->op type to their names. """
|
""" array used for translating cinsn_t->op type to their names. """
|
||||||
@ -953,7 +893,7 @@ lvar_t.is_mapdst_var = property(lvar_t.is_mapdst_var)
|
|||||||
|
|
||||||
def _map___getitem__(self, key):
|
def _map___getitem__(self, key):
|
||||||
""" Returns the value associated with the provided key. """
|
""" Returns the value associated with the provided key. """
|
||||||
if type(key) != self.keytype:
|
if not isinstance(key, self.keytype):
|
||||||
raise KeyError('type of key should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
raise KeyError('type of key should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
||||||
if key not in self:
|
if key not in self:
|
||||||
raise KeyError('key not found')
|
raise KeyError('key not found')
|
||||||
@ -961,16 +901,16 @@ def _map___getitem__(self, key):
|
|||||||
|
|
||||||
def _map___setitem__(self, key, value):
|
def _map___setitem__(self, key, value):
|
||||||
""" Returns the value associated with the provided key. """
|
""" Returns the value associated with the provided key. """
|
||||||
if type(key) != self.keytype:
|
if not isinstance(key, self.keytype):
|
||||||
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
||||||
if type(value) != self.valuetype:
|
if not isinstance(value, self.valuetype):
|
||||||
raise KeyError('type of `value` should be ' + repr(self.valuetype) + ' but got ' + type(value))
|
raise KeyError('type of `value` should be ' + repr(self.valuetype) + ' but got ' + type(value))
|
||||||
self.insert(key, value)
|
self.insert(key, value)
|
||||||
return
|
return
|
||||||
|
|
||||||
def _map___delitem__(self, key):
|
def _map___delitem__(self, key):
|
||||||
""" Removes the value associated with the provided key. """
|
""" Removes the value associated with the provided key. """
|
||||||
if type(key) != self.keytype:
|
if not isinstance(key, self.keytype):
|
||||||
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
||||||
if key not in self:
|
if key not in self:
|
||||||
raise KeyError('key not found')
|
raise KeyError('key not found')
|
||||||
@ -979,7 +919,7 @@ def _map___delitem__(self, key):
|
|||||||
|
|
||||||
def _map___contains__(self, key):
|
def _map___contains__(self, key):
|
||||||
""" Returns true if the specified key exists in the . """
|
""" Returns true if the specified key exists in the . """
|
||||||
if type(key) != self.keytype:
|
if not isinstance(key, self.keytype):
|
||||||
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
||||||
if self.find(key) != self.end():
|
if self.find(key) != self.end():
|
||||||
return True
|
return True
|
||||||
@ -1035,7 +975,7 @@ def _map_has_key(self, key):
|
|||||||
|
|
||||||
def _map_pop(self, key):
|
def _map_pop(self, key):
|
||||||
""" Sets the value associated with the provided key. """
|
""" Sets the value associated with the provided key. """
|
||||||
if type(key) != self.keytype:
|
if not isinstance(key, self.keytype):
|
||||||
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
||||||
if key not in self:
|
if key not in self:
|
||||||
raise KeyError('key not found')
|
raise KeyError('key not found')
|
||||||
@ -1052,7 +992,7 @@ def _map_popitem(self):
|
|||||||
|
|
||||||
def _map_setdefault(self, key, default=None):
|
def _map_setdefault(self, key, default=None):
|
||||||
""" Sets the value associated with the provided key. """
|
""" Sets the value associated with the provided key. """
|
||||||
if type(key) != self.keytype:
|
if not isinstance(key, self.keytype):
|
||||||
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
raise KeyError('type of `key` should be ' + repr(self.keytype) + ' but got ' + repr(type(key)))
|
||||||
if key in self:
|
if key in self:
|
||||||
return self[key]
|
return self[key]
|
||||||
@ -1100,11 +1040,11 @@ def _map_as_dict(maptype, name, keytype, valuetype):
|
|||||||
maptype.popitem = _map_popitem
|
maptype.popitem = _map_popitem
|
||||||
maptype.setdefault = _map_setdefault
|
maptype.setdefault = _map_setdefault
|
||||||
|
|
||||||
_map_as_dict(user_labels_t, 'user_labels', int, qstring)
|
_map_as_dict(user_labels_t, 'user_labels', (int, long), qstring)
|
||||||
_map_as_dict(user_cmts_t, 'user_cmts', treeloc_t, citem_cmt_t)
|
_map_as_dict(user_cmts_t, 'user_cmts', treeloc_t, citem_cmt_t)
|
||||||
_map_as_dict(user_numforms_t, 'user_numforms', operand_locator_t, number_format_t)
|
_map_as_dict(user_numforms_t, 'user_numforms', operand_locator_t, number_format_t)
|
||||||
_map_as_dict(user_iflags_t, 'user_iflags', citem_locator_t, int)
|
_map_as_dict(user_iflags_t, 'user_iflags', citem_locator_t, (int, long))
|
||||||
_map_as_dict(user_unions_t, 'user_unions', int, intvec_t)
|
_map_as_dict(user_unions_t, 'user_unions', (int, long), intvec_t)
|
||||||
_map_as_dict(eamap_t, 'eamap', int, cinsnptrvec_t)
|
_map_as_dict(eamap_t, 'eamap', int, cinsnptrvec_t)
|
||||||
#_map_as_dict(boundaries_t, 'boundaries', cinsn_t, areaset_t)
|
#_map_as_dict(boundaries_t, 'boundaries', cinsn_t, areaset_t)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user