python-idb
python-idb copied to clipboard
`IndexError: index out of range` when iterating through struct.get_members()
I'm trying to iterate through all structures' members, but I'm getting IndexError: index out of range
on one particular structure.
Here's the traceback:
File "C:\Users\<redacted>\...\generate_symbol_list.py", line 60, in <module>
for member in struct.get_members():
File "C:\Users\<redacted>\AppData\Local\Programs\Python\Python39\lib\site-packages\python_idb-0.7.1-py3.9.egg\idb\analysis.py", line 1133, in get_members
nodeid_offset = u.addr()
File "C:\Users\<redacted>\AppData\Local\Programs\Python\Python39\lib\site-packages\python_idb-0.7.1-py3.9.egg\idb\analysis.py", line 206, in addr
return self._do_unpack(unpack_dd)
File "C:\Users\<redacted>\AppData\Local\Programs\Python\Python39\lib\site-packages\python_idb-0.7.1-py3.9.egg\idb\analysis.py", line 189, in _do_unpack
v, delta = unpack_fn(self.buf, offset=self.offset)
File "C:\Users\<redacted>\AppData\Local\Programs\Python\Python39\lib\site-packages\python_idb-0.7.1-py3.9.egg\idb\analysis.py", line 131, in unpack_dd
hi = ((header & 0x3F) << 8) + six.indexbytes(buf, 0x1)
IndexError: index out of range
Here's the code snippet:
first_idx = api.ida_struct.get_first_struc_idx()
last_idx = api.ida_struct.get_last_struc_idx()
if first_idx != api.idc.BADADDR and last_idx != api.idc.BADADDR:
for i in range(first_idx, last_idx + 1):
struct = api.ida_struct.get_struc_by_idx(i)
print ("\n{}".format(struct.get_name()))
for member in struct.get_members():
print(" {}".format (member.get_name()))
Note that this also happens with find_member_by_name()
, which uses get_members()
. It happens on the same exact structure every time.