Skip to content

Commit 347601a

Browse files
authored
Merge pull request #2535 from mandiant/fix/ida-find_byte_sequence
handle IDA 8.3/8.4 vs. 9.0 API change
2 parents f11661f + 8a02b07 commit 347601a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
### Bug Fixes
1414

15+
- handle IDA 8.3/8.4 vs. 9.0 API change @mr-tz
16+
1517
### capa Explorer Web
1618

1719
### capa Explorer IDA Pro plugin

capa/features/extractors/ida/helpers.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ def find_byte_sequence(start: int, end: int, seq: bytes) -> Iterator[int]:
4141
return
4242

4343
while True:
44-
ea, _ = ida_bytes.bin_search(start, end, patterns, ida_bytes.BIN_SEARCH_FORWARD)
44+
ea = ida_bytes.bin_search(start, end, patterns, ida_bytes.BIN_SEARCH_FORWARD)
45+
if isinstance(ea, int):
46+
# "ea_t" in IDA 8.4, 8.3
47+
pass
48+
elif isinstance(ea, tuple):
49+
# "drc_t" in IDA 9
50+
ea = ea[0]
51+
else:
52+
raise NotImplementedError(f"bin_search returned unhandled type: {type(ea)}")
4553
if ea == idaapi.BADADDR:
4654
break
4755
start = ea + 1

0 commit comments

Comments
 (0)