diff --git a/build.py b/build.py index 3631d6c..f6ba1ed 100644 --- a/build.py +++ b/build.py @@ -72,6 +72,7 @@ BINDIST_MANIFEST = [ "examples/structure.py", "examples/ex_gdl_qflow_chart.py", "examples/ex_strings.py", + "examples/ex_debug_names.py" ] # List files for the source distribution (appended to binary list) diff --git a/examples/ex_debug_names.py b/examples/ex_debug_names.py new file mode 100644 index 0000000..e6993c2 --- /dev/null +++ b/examples/ex_debug_names.py @@ -0,0 +1,15 @@ +import idaapi + +def main(): + if not idaapi.is_debugger_on(): + print "Please run the process first!" + return + if idaapi.get_process_state() != -1: + print "Please suspend the debugger first!" + return + + dn = idaapi.get_debug_names(idaapi.cvar.inf.minEA, idaapi.cvar.inf.maxEA) + for i in dn: + print "%08x: %s" % (i, dn[i]) + +main() diff --git a/swig/name.i b/swig/name.i index 1b89a9b..6eb7482 100644 --- a/swig/name.i +++ b/swig/name.i @@ -11,6 +11,7 @@ %ignore get_struct_operand; %ignore set_debug_names; %ignore get_debug_name; +%ignore get_debug_names; %ignore nameVa; // Unexported & kernel-only @@ -30,5 +31,26 @@ %ignore is_exit_name; %ignore dummy_name_ea; +%rename (get_debug_names) py_get_debug_names; +%inline %{ +PyObject *py_get_debug_names(ea_t ea1, ea_t ea2) +{ + // Get debug names + ea_name_vec_t names; + get_debug_names(ea1, ea2, names); + PyObject *dict = Py_BuildValue("{}"); + if (dict == NULL) + return NULL; + + for (ea_name_vec_t::iterator it=names.begin();it!=names.end();++it) + { + PyDict_SetItem(dict, + PyInt_FromSize_t(it->ea), + PyString_FromString(it->name.c_str())); + } + return dict; +} +%} + %include "name.hpp"