From 1a7d06b3b8044ccdee4e3ff0883a33bf8cce487f Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Sat, 4 Feb 2023 15:23:52 -0500 Subject: Initial support for constant data expressions. --- mediumlevelilinstruction.h | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'mediumlevelilinstruction.h') diff --git a/mediumlevelilinstruction.h b/mediumlevelilinstruction.h index 43047fa3..90d2700c 100644 --- a/mediumlevelilinstruction.h +++ b/mediumlevelilinstruction.h @@ -24,6 +24,7 @@ #include #include #ifdef BINARYNINJACORE_LIBRARY + #include "constantdata.h" #include "variable.h" #else #include "binaryninjaapi.h" @@ -43,6 +44,7 @@ namespace BinaryNinja struct MediumLevelILInstruction; struct MediumLevelILConstantInstruction; + struct MediumLevelILConstantDataInstruction; struct MediumLevelILOneOperandInstruction; struct MediumLevelILTwoOperandInstruction; struct MediumLevelILTwoOperandWithCarryInstruction; @@ -76,6 +78,7 @@ namespace BinaryNinja enum MediumLevelILOperandType { IntegerMediumLevelOperand, + ConstantDataMediumLevelOperand, IndexMediumLevelOperand, IntrinsicMediumLevelOperand, ExprMediumLevelOperand, @@ -111,6 +114,7 @@ namespace BinaryNinja LowSSAVariableMediumLevelOperandUsage, OffsetMediumLevelOperandUsage, ConstantMediumLevelOperandUsage, + ConstantDataMediumLevelOperandUsage, VectorMediumLevelOperandUsage, IntrinsicMediumLevelOperandUsage, TargetMediumLevelOperandUsage, @@ -443,6 +447,7 @@ namespace BinaryNinja MediumLevelILOperandList GetOperands() const; uint64_t GetRawOperandAsInteger(size_t operand) const; + ConstantData GetRawOperandAsConstantData(size_t operand) const; size_t GetRawOperandAsIndex(size_t operand) const; MediumLevelILInstruction GetRawOperandAsExpr(size_t operand) const; Variable GetRawOperandAsVariable(size_t operand) const; @@ -538,6 +543,10 @@ namespace BinaryNinja { return *(const MediumLevelILConstantInstruction*)this; } + const MediumLevelILConstantDataInstruction& AsConstantData() const + { + return *(const MediumLevelILConstantDataInstruction*)this; + } const MediumLevelILOneOperandInstruction& AsOneOperand() const { return *(const MediumLevelILOneOperandInstruction*)this; @@ -655,6 +664,11 @@ namespace BinaryNinja return As().GetConstant(); } template + ConstantData GetConstantData() const + { + return As().GetConstantData(); + } + template int64_t GetVector() const { return As().GetVector(); @@ -817,6 +831,7 @@ namespace BinaryNinja SSAVariable GetLowSSAVariable() const; uint64_t GetOffset() const; int64_t GetConstant() const; + ConstantData GetConstantData() const; int64_t GetVector() const; uint32_t GetIntrinsic() const; size_t GetTarget() const; @@ -853,6 +868,7 @@ namespace BinaryNinja MediumLevelILOperandUsage GetUsage() const { return m_usage; } uint64_t GetInteger() const; + ConstantData GetConstantData() const; size_t GetIndex() const; uint32_t GetIntrinsic() const; MediumLevelILInstruction GetExpr() const; @@ -912,6 +928,14 @@ namespace BinaryNinja int64_t GetConstant() const { return GetRawOperandAsInteger(0); } }; + /*! + \ingroup mediumlevelil + */ + struct MediumLevelILConstantDataInstruction : public MediumLevelILInstructionBase + { + ConstantData GetConstantData() const { return GetRawOperandAsConstantData(0); } + }; + /*! \ingroup mediumlevelil */ @@ -1455,9 +1479,6 @@ namespace BinaryNinja struct MediumLevelILInstructionAccessor : public MediumLevelILConstantInstruction {}; template <> - struct MediumLevelILInstructionAccessor : public MediumLevelILConstantInstruction - {}; - template <> struct MediumLevelILInstructionAccessor : public MediumLevelILConstantInstruction {}; template <> @@ -1466,6 +1487,9 @@ namespace BinaryNinja template <> struct MediumLevelILInstructionAccessor : public MediumLevelILConstantInstruction {}; + template <> + struct MediumLevelILInstructionAccessor : public MediumLevelILConstantDataInstruction + {}; template <> struct MediumLevelILInstructionAccessor : public MediumLevelILTwoOperandInstruction -- cgit v1.3.1