Skip to content

Commit

Permalink
Fix a bad BADADDR reference (thanks @Cl4sm)
Browse files Browse the repository at this point in the history
  • Loading branch information
mahaloz committed Aug 29, 2024
1 parent fe6d659 commit 171fca0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libbs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.19.1"
__version__ = "1.19.2"


import logging
Expand Down
16 changes: 11 additions & 5 deletions libbs/decompilers/ida/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ def structs():
@execute_write
def struct(name):
sid = ida_struct.get_struc_id(name)
if sid == 0xffffffffffffffff:
if sid == idaapi.BADADDR:
return None

sptr = ida_struct.get_struc(sid)
Expand All @@ -855,7 +855,7 @@ def struct(name):
@execute_write
def del_ida_struct(name) -> bool:
sid = ida_struct.get_struc_id(name)
if sid == 0xffffffffffffffff:
if sid == idaapi.BADADDR:
return False

sptr = ida_struct.get_struc(sid)
Expand All @@ -869,7 +869,7 @@ def set_struct_member_name(ida_struct, frame, offset, name):
def set_ida_struct(struct: Struct) -> bool:
# first, delete any struct by the same name if it exists
sid = ida_struct.get_struc_id(struct.name)
if sid != 0xffffffffffffffff:
if sid != idaapi.BADADDR:
sptr = ida_struct.get_struc(sid)
ida_struct.del_struc(sptr)

Expand Down Expand Up @@ -997,14 +997,20 @@ def get_enum_members(_enum) -> typing.Dict[str, int]:
enum_members[member_name] = member

member = ida_enum.get_next_enum_member(_enum, member, 0)
while member:
if member == 0xffffffffffffffff: break
max_iters = 100
for _ in range(max_iters):
if member == idaapi.BADADDR:
break

member_addr = ida_enum.get_enum_member(_enum, member, 0, 0)
member_name = ida_enum.get_enum_member_name(member_addr)
if member_name:
enum_members[member_name] = member

member = ida_enum.get_next_enum_member(_enum, member, 0)
else:
_l.critical(f"IDA failed to iterate all enum members for enum %s", _enum)

return enum_members


Expand Down

0 comments on commit 171fca0

Please sign in to comment.