Skip to content

Commit b8fdf80

Browse files
committed
Expose BNDetectSearchMode to Python API for search mode testing.
1 parent 695a94c commit b8fdf80

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

python/binaryview.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9911,6 +9911,20 @@ def internal_match_callback(ctxt, offset, match):
99119911
t = threading.Thread(target=lambda: core.BNSearch(self.handle, json.dumps(query), None, progress_callback_obj, None, match_callback_obj))
99129912
return self.QueueGenerator(t, results)
99139913

9914+
@staticmethod
9915+
def detect_search_mode(pattern: str, raw: bool = False) -> str:
9916+
"""
9917+
Detects the search mode that would be used by :py:meth:`search` for the given pattern.
9918+
9919+
:param str pattern: The search pattern to analyze.
9920+
:param bool raw: Whether to interpret the pattern as a raw string (default: False).
9921+
:return: The detected search mode: ``"FlexHex"``, ``"Regex"``, or ``"Raw String"``.
9922+
:rtype: str
9923+
"""
9924+
query = json.dumps({"pattern": pattern, "raw": raw})
9925+
result = core.BNDetectSearchMode(query)
9926+
return result
9927+
99149928
def reanalyze(self) -> None:
99159929
"""
99169930
``reanalyze`` causes all functions to be reanalyzed. This function does not wait for the analysis to finish.

0 commit comments

Comments
 (0)