summaryrefslogtreecommitdiff
path: root/python/highlevelil.py
diff options
context:
space:
mode:
authorRusty Wagner <rusty.wagner@gmail.com>2025-10-13 19:35:01 -0400
committerRusty Wagner <rusty.wagner@gmail.com>2025-10-21 13:52:39 -0400
commit5d4fc5f1fb7a0c368d2a048a5d750564c970c9c9 (patch)
treecd740b4af25fe5184935fd67067025733f17b099 /python/highlevelil.py
parentcae26921cf2b2e564f66e58b77a3963fe36f6d2d (diff)
Add derived strings and string recognizer API
Diffstat (limited to 'python/highlevelil.py')
-rw-r--r--python/highlevelil.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/python/highlevelil.py b/python/highlevelil.py
index ce264e19..ef1b3de2 100644
--- a/python/highlevelil.py
+++ b/python/highlevelil.py
@@ -41,6 +41,7 @@ from . import highlight
from . import flowgraph
from . import variable
from . import databuffer
+from . import stringrecognizer
from . import types as _types
from .interaction import show_graph_report
from .commonil import (
@@ -973,6 +974,13 @@ class HighLevelILInstruction(BaseILInstruction):
hash ^= rotl(discriminator, 47)
return hash
+ @property
+ def derived_string_reference(self) -> Optional['binaryview.DerivedString']:
+ str = core.BNDerivedString()
+ if not core.BNGetHighLevelILDerivedStringReferenceForExpr(self.function.handle, self.expr_index, str):
+ return None
+ return binaryview.DerivedString._from_core_struct(str, True)
+
@dataclass(frozen=True, repr=False, eq=False)
class HighLevelILUnaryBase(HighLevelILInstruction, UnaryOperation):
@@ -3003,6 +3011,22 @@ class HighLevelILFunction:
result |= flag.value
core.BNSetHighLevelILExprAttributes(self.handle, expr, result)
+ def set_derived_string_reference_for_expr(self, expr: InstructionOrExpression, str: 'binaryview.DerivedString'):
+ if isinstance(expr, HighLevelILInstruction):
+ expr = expr.expr_index
+ elif isinstance(expr, int):
+ expr = ExpressionIndex(expr)
+
+ str_obj = str._to_core_struct(False)
+ core.BNSetHighLevelILDerivedStringReferenceForExpr(self.handle, expr, str_obj)
+
+ def remove_derived_string_reference_for_expr(self, expr: InstructionOrExpression):
+ if isinstance(expr, HighLevelILInstruction):
+ expr = expr.expr_index
+ elif isinstance(expr, int):
+ expr = ExpressionIndex(expr)
+ core.BNRemoveHighLevelILDerivedStringReferenceForExpr(self.handle, expr)
+
def nop(self, loc: Optional['ILSourceLocation'] = None) -> ExpressionIndex:
"""
``nop`` no operation, this instruction does nothing