diff --git a/examples/ex_imports.py b/examples/ex_imports.py index 642a0f0..15e2126 100644 --- a/examples/ex_imports.py +++ b/examples/ex_imports.py @@ -5,7 +5,10 @@ import idaapi def imp_cb(ea, name, ord): - print "%08x: %s (ord#%d)" % (ea, name, ord) + if not name: + print "%08x: ord#%d" % (ea, ord) + else: + print "%08x: %s (ord#%d)" % (ea, name, ord) # True -> Continue enumeration # False -> Stop enumeration return True diff --git a/swig/nalt.i b/swig/nalt.i index 732b39d..cc8a3cf 100644 --- a/swig/nalt.i +++ b/swig/nalt.i @@ -20,13 +20,22 @@ // param: user parameter passed to enum_import_names() // return: 1-ok, 0-stop enumeration static int idaapi py_import_enum_cb( - ea_t ea, - const char *name, - uval_t ord, + ea_t ea, + const char *name, + uval_t ord, void *param) { PyObject *py_ea = Py_BuildValue(PY_FMT64, pyul_t(ea)); - PyObject *py_name = PyString_FromString(name); + PyObject *py_name; + if ( name == NULL ) + { + py_name = Py_None; + Py_INCREF(Py_None); + } + else + { + py_name = PyString_FromString(name); + } PyObject *py_ord = Py_BuildValue(PY_FMT64, pyul_t(ord)); PyObject *py_result = PyObject_CallFunctionObjArgs((PyObject *)param, py_ea, py_name, py_ord, NULL); int r = py_result != NULL && PyObject_IsTrue(py_result) ? 1 : 0;