diff options
| author | Brian Potchik <brian@vector35.com> | 2023-02-04 15:23:52 -0500 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2023-02-04 15:23:52 -0500 |
| commit | 1a7d06b3b8044ccdee4e3ff0883a33bf8cce487f (patch) | |
| tree | 6779d6b368acfcad57474e0fd12c1ae4158f5c38 /mediumlevelilinstruction.h | |
| parent | 4005984260466439560545040850557922003325 (diff) | |
Initial support for constant data expressions.
Diffstat (limited to 'mediumlevelilinstruction.h')
| -rw-r--r-- | mediumlevelilinstruction.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/mediumlevelilinstruction.h b/mediumlevelilinstruction.h index 43047fa3..90d2700c 100644 --- a/mediumlevelilinstruction.h +++ b/mediumlevelilinstruction.h @@ -24,6 +24,7 @@ #include <unordered_map> #include <vector> #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<N>().GetConstant(); } template <BNMediumLevelILOperation N> + ConstantData GetConstantData() const + { + return As<N>().GetConstantData(); + } + template <BNMediumLevelILOperation N> int64_t GetVector() const { return As<N>().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; @@ -915,6 +931,14 @@ namespace BinaryNinja /*! \ingroup mediumlevelil */ + struct MediumLevelILConstantDataInstruction : public MediumLevelILInstructionBase + { + ConstantData GetConstantData() const { return GetRawOperandAsConstantData(0); } + }; + + /*! + \ingroup mediumlevelil + */ struct MediumLevelILOneOperandInstruction : public MediumLevelILInstructionBase { MediumLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(0); } @@ -1455,9 +1479,6 @@ namespace BinaryNinja struct MediumLevelILInstructionAccessor<MLIL_CONST> : public MediumLevelILConstantInstruction {}; template <> - struct MediumLevelILInstructionAccessor<MLIL_CONST_DATA> : public MediumLevelILConstantInstruction - {}; - template <> struct MediumLevelILInstructionAccessor<MLIL_CONST_PTR> : public MediumLevelILConstantInstruction {}; template <> @@ -1466,6 +1487,9 @@ namespace BinaryNinja template <> struct MediumLevelILInstructionAccessor<MLIL_IMPORT> : public MediumLevelILConstantInstruction {}; + template <> + struct MediumLevelILInstructionAccessor<MLIL_CONST_DATA> : public MediumLevelILConstantDataInstruction + {}; template <> struct MediumLevelILInstructionAccessor<MLIL_ADD> : public MediumLevelILTwoOperandInstruction |
