From 1a73fb21cea559e8da2cabb43176b0f183a937ee Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Fri, 7 Feb 2020 21:02:12 -0500 Subject: Add HLIL instructions for variable declarations --- highlevelilinstruction.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'highlevelilinstruction.h') diff --git a/highlevelilinstruction.h b/highlevelilinstruction.h index cfc917e8..967bafec 100644 --- a/highlevelilinstruction.h +++ b/highlevelilinstruction.h @@ -68,6 +68,7 @@ namespace BinaryNinja { SourceExprHighLevelOperandUsage, VariableHighLevelOperandUsage, + DestVariableHighLevelOperandUsage, SSAVariableHighLevelOperandUsage, DestSSAVariableHighLevelOperandUsage, DestExprHighLevelOperandUsage, @@ -374,6 +375,7 @@ namespace BinaryNinja // Templated accessors for instruction operands, use these for efficient access to a known instruction template HighLevelILInstruction GetSourceExpr() const { return As().GetSourceExpr(); } template Variable GetVariable() const { return As().GetVariable(); } + template Variable GetDestVariable() const { return As().GetDestVariable(); } template SSAVariable GetSSAVariable() const { return As().GetSSAVariable(); } template SSAVariable GetDestSSAVariable() const { return As().GetDestSSAVariable(); } template HighLevelILInstruction GetDestExpr() const { return As().GetDestExpr(); } @@ -428,6 +430,7 @@ namespace BinaryNinja // on type mismatch. These are slower than the templated versions above. HighLevelILInstruction GetSourceExpr() const; Variable GetVariable() const; + Variable GetDestVariable() const; SSAVariable GetSSAVariable() const; SSAVariable GetDestSSAVariable() const; HighLevelILInstruction GetDestExpr() const; @@ -598,6 +601,21 @@ namespace BinaryNinja void SetSourceExprs(const std::vector& exprs) { UpdateRawOperandAsExprList(0, exprs); } }; + template <> struct HighLevelILInstructionAccessor: public HighLevelILInstructionBase + { + Variable GetVariable() const { return GetRawOperandAsVariable(0); } + }; + template <> struct HighLevelILInstructionAccessor: public HighLevelILInstructionBase + { + Variable GetDestVariable() const { return GetRawOperandAsVariable(0); } + HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); } + }; + template <> struct HighLevelILInstructionAccessor: public HighLevelILInstructionBase + { + SSAVariable GetDestSSAVariable() const { return GetRawOperandAsSSAVariable(0); } + void SetDestSSAVersion(size_t version) { UpdateRawOperand(1, version); } + HighLevelILInstruction GetSourceExpr() const { return GetRawOperandAsExpr(1); } + }; template <> struct HighLevelILInstructionAccessor: public HighLevelILInstructionBase { HighLevelILInstruction GetDestExpr() const { return GetRawOperandAsExpr(0); } -- cgit v1.3.1