From 0763a5064d53a6ec58b7bd40e8c47679d55a81d0 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Sun, 20 Nov 2022 21:35:06 -0500 Subject: Initial constant expression builtin outliner. --- python/highlevelil.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'python/highlevelil.py') diff --git a/python/highlevelil.py b/python/highlevelil.py index b9bb3e88..1f8c3f84 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -38,6 +38,7 @@ from . import types from . import highlight from . import flowgraph from . import variable +from . import databuffer from .interaction import show_graph_report from .commonil import ( BaseILInstruction, Tailcall, Syscall, Localcall, Comparison, Signed, UnaryOperation, BinaryOperation, SSA, Phi, @@ -54,7 +55,7 @@ OperandsType = Tuple[ExpressionIndex, ExpressionIndex, ExpressionIndex, Expressi HighLevelILOperandType = Union['HighLevelILInstruction', 'lowlevelil.ILIntrinsic', 'variable.Variable', 'mediumlevelil.SSAVariable', List[int], List['variable.Variable'], List['mediumlevelil.SSAVariable'], List['HighLevelILInstruction'], Optional[int], float, - 'GotoLabel'] + 'GotoLabel', databuffer.DataBuffer] VariablesList = List[Union['mediumlevelil.SSAVariable', 'variable.Variable']] StringOrType = Union[str, '_types.Type', '_types.TypeBuilder'] @@ -1401,6 +1402,17 @@ class HighLevelILConst(HighLevelILInstruction, Constant): return [self.constant] +@dataclass(frozen=True, repr=False, eq=False) +class HighLevelILConstData(HighLevelILInstruction, Constant): + @property + def constant(self) -> 'DataBuffer': + return self.function.source_function.view.get_constant_data(self._get_int(0)) + + @property + def operands(self) -> List[HighLevelILOperandType]: + return [self.constant] + + @dataclass(frozen=True, repr=False, eq=False) class HighLevelILConstPtr(HighLevelILInstruction, Constant): @property @@ -1978,6 +1990,7 @@ ILInstruction = { HighLevelILDerefFieldSsa, # ("src", "expr"), ("src_memory", "int"), ("offset", "int"), ("member_index", "member_index"), HighLevelILOperation.HLIL_ADDRESS_OF: HighLevelILAddressOf, # ("src", "expr"), HighLevelILOperation.HLIL_CONST: HighLevelILConst, # ("constant", "int"), + HighLevelILOperation.HLIL_CONST_DATA: HighLevelILConstData, # ("constant", "int"), HighLevelILOperation.HLIL_CONST_PTR: HighLevelILConstPtr, # ("constant", "int"), HighLevelILOperation.HLIL_EXTERN_PTR: HighLevelILExternPtr, # ("constant", "int"), ("offset", "int"), HighLevelILOperation.HLIL_FLOAT_CONST: HighLevelILFloatConst, # ("constant", "float"), -- cgit v1.3.1