bugfix: import enumeration did not handle imports by ordinal properly

This commit is contained in:
elias.bachaalany 2010-03-17 11:30:28 +00:00
parent ee8fab6c4c
commit f57af01a21
2 changed files with 17 additions and 5 deletions

View File

@ -5,7 +5,10 @@
import idaapi import idaapi
def imp_cb(ea, name, ord): 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 # True -> Continue enumeration
# False -> Stop enumeration # False -> Stop enumeration
return True return True

View File

@ -26,7 +26,16 @@ static int idaapi py_import_enum_cb(
void *param) void *param)
{ {
PyObject *py_ea = Py_BuildValue(PY_FMT64, pyul_t(ea)); 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_ord = Py_BuildValue(PY_FMT64, pyul_t(ord));
PyObject *py_result = PyObject_CallFunctionObjArgs((PyObject *)param, py_ea, py_name, py_ord, NULL); 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; int r = py_result != NULL && PyObject_IsTrue(py_result) ? 1 : 0;