Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: index out of range when iterating through struct.get_members() #110

Open
Elletra opened this issue Oct 27, 2021 · 0 comments
Open

Comments

@Elletra
Copy link

Elletra commented Oct 27, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant