Skip to content

Commit

Permalink
Merge pull request #2535 from mandiant/fix/ida-find_byte_sequence
Browse files Browse the repository at this point in the history
handle IDA 8.3/8.4 vs. 9.0 API change
  • Loading branch information
mr-tz authored Dec 9, 2024
2 parents f11661f + 8a02b07 commit 347601a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### Bug Fixes

- handle IDA 8.3/8.4 vs. 9.0 API change @mr-tz

### capa Explorer Web

### capa Explorer IDA Pro plugin
Expand Down
10 changes: 9 additions & 1 deletion capa/features/extractors/ida/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ def find_byte_sequence(start: int, end: int, seq: bytes) -> Iterator[int]:
return

while True:
ea, _ = ida_bytes.bin_search(start, end, patterns, ida_bytes.BIN_SEARCH_FORWARD)
ea = ida_bytes.bin_search(start, end, patterns, ida_bytes.BIN_SEARCH_FORWARD)
if isinstance(ea, int):
# "ea_t" in IDA 8.4, 8.3
pass
elif isinstance(ea, tuple):
# "drc_t" in IDA 9
ea = ea[0]
else:
raise NotImplementedError(f"bin_search returned unhandled type: {type(ea)}")
if ea == idaapi.BADADDR:
break
start = ea + 1
Expand Down

0 comments on commit 347601a

Please sign in to comment.