From 741fb0538e0ac6ab14928f78697196803dbd2ed5 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Thu, 19 Dec 2019 16:04:11 -0500 Subject: LLIL_JUMP_TO/MLIL_JUMP_TO now contain mappings from address to destination instruction --- mediumlevelilinstruction.h | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) (limited to 'mediumlevelilinstruction.h') diff --git a/mediumlevelilinstruction.h b/mediumlevelilinstruction.h index 7d11d35d..a5fff2f9 100644 --- a/mediumlevelilinstruction.h +++ b/mediumlevelilinstruction.h @@ -75,6 +75,7 @@ namespace BinaryNinja VariableMediumLevelOperand, SSAVariableMediumLevelOperand, IndexListMediumLevelOperand, + IndexMapMediumLevelOperand, VariableListMediumLevelOperand, SSAVariableListMediumLevelOperand, ExprListMediumLevelOperand @@ -107,7 +108,7 @@ namespace BinaryNinja FalseTargetMediumLevelOperandUsage, DestMemoryVersionMediumLevelOperandUsage, SourceMemoryVersionMediumLevelOperandUsage, - TargetListMediumLevelOperandUsage, + TargetsMediumLevelOperandUsage, SourceMemoryVersionsMediumLevelOperandUsage, OutputVariablesMediumLevelOperandUsage, OutputVariablesSubExprMediumLevelOperandUsage, @@ -249,6 +250,33 @@ namespace BinaryNinja operator std::vector() const; }; + class MediumLevelILIndexMap + { + struct ListIterator + { + MediumLevelILIntegerList::const_iterator pos; + bool operator==(const ListIterator& a) const { return pos == a.pos; } + bool operator!=(const ListIterator& a) const { return pos != a.pos; } + bool operator<(const ListIterator& a) const { return pos < a.pos; } + ListIterator& operator++() { ++pos; ++pos; return *this; } + const std::pair operator*(); + }; + + MediumLevelILIntegerList m_list; + + public: + typedef ListIterator const_iterator; + + MediumLevelILIndexMap(MediumLevelILFunction* func, const BNMediumLevelILInstruction& instr, size_t count); + + const_iterator begin() const; + const_iterator end() const; + size_t size() const; + size_t operator[](uint64_t) const; + + operator std::map() const; + }; + class MediumLevelILVariableList { struct ListIterator @@ -357,6 +385,7 @@ namespace BinaryNinja SSAVariable GetRawOperandAsSSAVariable(size_t operand) const; SSAVariable GetRawOperandAsPartialSSAVariableSource(size_t operand) const; MediumLevelILIndexList GetRawOperandAsIndexList(size_t operand) const; + MediumLevelILIndexMap GetRawOperandAsIndexMap(size_t operand) const; MediumLevelILVariableList GetRawOperandAsVariableList(size_t operand) const; MediumLevelILSSAVariableList GetRawOperandAsSSAVariableList(size_t operand) const; MediumLevelILInstructionList GetRawOperandAsExprList(size_t operand) const; @@ -494,7 +523,7 @@ namespace BinaryNinja template size_t GetFalseTarget() const { return As().GetFalseTarget(); } template size_t GetDestMemoryVersion() const { return As().GetDestMemoryVersion(); } template size_t GetSourceMemoryVersion() const { return As().GetSourceMemoryVersion(); } - template MediumLevelILIndexList GetTargetList() const { return As().GetTargetList(); } + template MediumLevelILIndexMap GetTargets() const { return As().GetTargets(); } template MediumLevelILIndexList GetSourceMemoryVersions() const { return As().GetSourceMemoryVersions(); } template MediumLevelILVariableList GetOutputVariables() const { return As().GetOutputVariables(); } template MediumLevelILSSAVariableList GetOutputSSAVariables() const { return As().GetOutputSSAVariables(); } @@ -545,7 +574,7 @@ namespace BinaryNinja size_t GetFalseTarget() const; size_t GetDestMemoryVersion() const; size_t GetSourceMemoryVersion() const; - MediumLevelILIndexList GetTargetList() const; + MediumLevelILIndexMap GetTargets() const; MediumLevelILIndexList GetSourceMemoryVersions() const; MediumLevelILVariableList GetOutputVariables() const; MediumLevelILSSAVariableList GetOutputSSAVariables() const; @@ -577,6 +606,7 @@ namespace BinaryNinja Variable GetVariable() const; SSAVariable GetSSAVariable() const; MediumLevelILIndexList GetIndexList() const; + MediumLevelILIndexMap GetIndexMap() const; MediumLevelILVariableList GetVariableList() const; MediumLevelILSSAVariableList GetSSAVariableList() const; MediumLevelILInstructionList GetExprList() const; @@ -812,7 +842,7 @@ namespace BinaryNinja template <> struct MediumLevelILInstructionAccessor: public MediumLevelILInstructionBase { MediumLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); } - MediumLevelILIndexList GetTargetList() const { return GetRawOperandAsIndexList(1); } + MediumLevelILIndexMap GetTargets() const { return GetRawOperandAsIndexMap(1); } }; template <> struct MediumLevelILInstructionAccessor: public MediumLevelILInstructionBase { -- cgit v1.3.1