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. --- highlevelilinstruction.h | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'highlevelilinstruction.h') diff --git a/highlevelilinstruction.h b/highlevelilinstruction.h index 7ac97d2d..19303bdc 100644 --- a/highlevelilinstruction.h +++ b/highlevelilinstruction.h @@ -48,6 +48,7 @@ namespace BinaryNinja struct HighLevelILInstruction; struct HighLevelILConstantInstruction; + struct HighLevelILConstantDataInstruction; struct HighLevelILOneOperandInstruction; struct HighLevelILTwoOperandInstruction; struct HighLevelILTwoOperandWithCarryInstruction; @@ -62,6 +63,7 @@ namespace BinaryNinja enum HighLevelILOperandType { IntegerHighLevelOperand, + ConstantDataHighLevelOperand, IndexHighLevelOperand, IntrinsicHighLevelOperand, ExprHighLevelOperand, @@ -100,6 +102,7 @@ namespace BinaryNinja OffsetHighLevelOperandUsage, MemberIndexHighLevelOperandUsage, ConstantHighLevelOperandUsage, + ConstantDataHighLevelOperandUsage, VectorHighLevelOperandUsage, IntrinsicHighLevelOperandUsage, TargetHighLevelOperandUsage, @@ -336,6 +339,7 @@ namespace BinaryNinja HighLevelILOperandList GetOperands() const; uint64_t GetRawOperandAsInteger(size_t operand) const; + ConstantData GetRawOperandAsConstantData(size_t operand) const; size_t GetRawOperandAsIndex(size_t operand) const; HighLevelILInstruction GetRawOperandAsExpr(size_t operand) const; Variable GetRawOperandAsVariable(size_t operand) const; @@ -408,6 +412,10 @@ namespace BinaryNinja { return *(const HighLevelILConstantInstruction*)this; } + const HighLevelILConstantDataInstruction& AsConstantData() const + { + return *(const HighLevelILConstantDataInstruction*)this; + } const HighLevelILOneOperandInstruction& AsOneOperand() const { return *(const HighLevelILOneOperandInstruction*)this; @@ -559,6 +567,11 @@ namespace BinaryNinja return As().GetConstant(); } template + ConstantData GetConstantData() const + { + return As().GetConstantData(); + } + template int64_t GetVector() const { return As().GetVector(); @@ -732,6 +745,7 @@ namespace BinaryNinja uint64_t GetOffset() const; size_t GetMemberIndex() const; int64_t GetConstant() const; + ConstantData GetConstantData() const; int64_t GetVector() const; uint32_t GetIntrinsic() const; uint64_t GetTarget() const; @@ -764,6 +778,7 @@ namespace BinaryNinja HighLevelILOperandUsage GetUsage() const { return m_usage; } uint64_t GetInteger() const; + ConstantData GetConstantData() const; size_t GetIndex() const; uint32_t GetIntrinsic() const; HighLevelILInstruction GetExpr() const; @@ -821,6 +836,14 @@ namespace BinaryNinja int64_t GetConstant() const { return GetRawOperandAsInteger(0); } }; + /*! + \ingroup highlevelil + */ + struct HighLevelILConstantDataInstruction : public HighLevelILInstructionBase + { + ConstantData GetConstantData() const { return GetRawOperandAsConstantData(0); } + }; + /*! \ingroup highlevelil */ @@ -1169,9 +1192,6 @@ namespace BinaryNinja struct HighLevelILInstructionAccessor : public HighLevelILConstantInstruction {}; template <> - struct HighLevelILInstructionAccessor : public HighLevelILConstantInstruction - {}; - template <> struct HighLevelILInstructionAccessor : public HighLevelILConstantInstruction {}; template <> @@ -1180,6 +1200,9 @@ namespace BinaryNinja template <> struct HighLevelILInstructionAccessor : public HighLevelILConstantInstruction {}; + template <> + struct HighLevelILInstructionAccessor : public HighLevelILConstantDataInstruction + {}; template <> struct HighLevelILInstructionAccessor : public HighLevelILTwoOperandInstruction -- cgit v1.3.1