From 7b816fc2e285aa9cd77fba33bc55afa16947095f Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Thu, 1 Jun 2023 17:36:20 -0400 Subject: Add Var, SSAVar, and AliasedVar to commonil.py, and update the relavent MLIL/HLIL instrutctions --- python/commonil.py | 15 +++++++++++++++ python/highlevelil.py | 8 ++++---- python/mediumlevelil.py | 10 ++++------ 3 files changed, 23 insertions(+), 10 deletions(-) (limited to 'python') diff --git a/python/commonil.py b/python/commonil.py index f84da073..288db8d9 100644 --- a/python/commonil.py +++ b/python/commonil.py @@ -189,3 +189,18 @@ class SetReg: @dataclass(frozen=True, repr=False, eq=False) class Intrinsic(BaseILInstruction): pass + + +@dataclass(frozen=True, repr=False, eq=False) +class VariableInstruction(BaseILInstruction): + pass + + +@dataclass(frozen=True, repr=False, eq=False) +class SSAVariableInstruction(SSA, VariableInstruction): + pass + + +@dataclass(frozen=True, repr=False, eq=False) +class AliasedVariableInstruction(VariableInstruction): + pass diff --git a/python/highlevelil.py b/python/highlevelil.py index 2a7d2fc7..4a7f3929 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -27,7 +27,6 @@ from enum import Enum # Binary Ninja components from . import _binaryninjacore as core from .enums import HighLevelILOperation, DataFlowQueryOption, FunctionGraphType, ILInstructionAttribute -from . import decorators from . import function from . import binaryview from . import architecture @@ -43,7 +42,8 @@ from . import types as _types from .interaction import show_graph_report from .commonil import ( BaseILInstruction, Tailcall, Syscall, Localcall, Comparison, Signed, UnaryOperation, BinaryOperation, SSA, Phi, - Loop, ControlFlow, Memory, Constant, Arithmetic, DoublePrecision, Terminal, FloatingPoint, Intrinsic, Return + Loop, ControlFlow, Memory, Constant, Arithmetic, DoublePrecision, Terminal, FloatingPoint, Intrinsic, Return, + VariableInstruction, SSAVariableInstruction ) from . import deprecation @@ -1378,7 +1378,7 @@ class HighLevelILAssignUnpackMemSsa(HighLevelILInstruction, SSA, Memory): @dataclass(frozen=True, repr=False, eq=False) -class HighLevelILVar(HighLevelILInstruction): +class HighLevelILVar(HighLevelILInstruction, VariableInstruction): @property def var(self) -> 'variable.Variable': return self.get_var(0) @@ -1391,7 +1391,7 @@ class HighLevelILVar(HighLevelILInstruction): @dataclass(frozen=True, repr=False, eq=False) -class HighLevelILVarSsa(HighLevelILInstruction, SSA): +class HighLevelILVarSsa(HighLevelILInstruction, SSAVariableInstruction): @property def var(self) -> 'mediumlevelil.SSAVariable': return self.get_var_ssa(0, 1) diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py index f3c8c538..66bf079e 100644 --- a/python/mediumlevelil.py +++ b/python/mediumlevelil.py @@ -18,7 +18,6 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. -from abc import abstractmethod import ctypes import struct from typing import (Optional, List, Union, Mapping, @@ -37,13 +36,12 @@ from . import flowgraph from . import variable from . import architecture from . import binaryview -from . import databuffer from . import types as _types from .interaction import show_graph_report from .commonil import ( BaseILInstruction, Constant, BinaryOperation, UnaryOperation, Comparison, SSA, Phi, FloatingPoint, ControlFlow, Terminal, Call, Localcall, Syscall, Tailcall, Return, Signed, Arithmetic, Carry, DoublePrecision, Memory, Load, - Store, RegisterStack, SetVar, Intrinsic + Store, RegisterStack, SetVar, Intrinsic, VariableInstruction, SSAVariableInstruction, AliasedVariableInstruction ) TokenList = List['function.InstructionTextToken'] @@ -1103,7 +1101,7 @@ class MediumLevelILLoad(MediumLevelILInstruction, Load): @dataclass(frozen=True, repr=False, eq=False) -class MediumLevelILVar(MediumLevelILInstruction): +class MediumLevelILVar(MediumLevelILInstruction, VariableInstruction): @property def src(self) -> variable.Variable: return self._get_var(0) @@ -1392,7 +1390,7 @@ class MediumLevelILFtrunc(MediumLevelILUnaryBase, Arithmetic, FloatingPoint): @dataclass(frozen=True, repr=False, eq=False) -class MediumLevelILVarSsa(MediumLevelILInstruction, SSA): +class MediumLevelILVarSsa(MediumLevelILInstruction, SSAVariableInstruction): @property def src(self) -> SSAVariable: return self._get_var_ssa(0, 1) @@ -1403,7 +1401,7 @@ class MediumLevelILVarSsa(MediumLevelILInstruction, SSA): @dataclass(frozen=True, repr=False, eq=False) -class MediumLevelILVarAliased(MediumLevelILInstruction, SSA): +class MediumLevelILVarAliased(MediumLevelILInstruction, SSA, AliasedVariableInstruction): @property def src(self) -> SSAVariable: return self._get_var_ssa(0, 1) -- cgit v1.3.1