From f609ea22f31177777009263c3d41af3015b8c953 Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Thu, 25 Jun 2020 21:45:34 -0400 Subject: Add C++ APIs to get SSA and non-SSA forms of HLIL instructions --- highlevelilinstruction.cpp | 33 +++++++++++++++++++++++++++++++++ highlevelilinstruction.h | 6 ++++++ 2 files changed, 39 insertions(+) diff --git a/highlevelilinstruction.cpp b/highlevelilinstruction.cpp index d7d1c6aa..e4ad6c7b 100644 --- a/highlevelilinstruction.cpp +++ b/highlevelilinstruction.cpp @@ -20,6 +20,7 @@ #ifdef BINARYNINJACORE_LIBRARY #include "highlevelilfunction.h" +#include "highlevelilssafunction.h" #include "mediumlevelilfunction.h" #include "mediumlevelilssafunction.h" using namespace BinaryNinjaCore; @@ -848,6 +849,38 @@ Confidence> HighLevelILInstructionBase::GetType() const } +size_t HighLevelILInstructionBase::GetSSAExprIndex() const +{ + return function->GetSSAExprIndex(exprIndex); +} + + +size_t HighLevelILInstructionBase::GetNonSSAExprIndex() const +{ + return function->GetNonSSAExprIndex(exprIndex); +} + + +HighLevelILInstruction HighLevelILInstructionBase::GetSSAForm() const +{ + Ref ssa = function->GetSSAForm().GetPtr(); + if (!ssa) + return *this; + size_t expr = GetSSAExprIndex(); + return ssa->GetExpr(expr); +} + + +HighLevelILInstruction HighLevelILInstructionBase::GetNonSSAForm() const +{ + Ref nonSsa = function->GetNonSSAForm(); + if (!nonSsa) + return *this; + size_t expr = GetNonSSAExprIndex(); + return nonSsa->GetExpr(expr); +} + + size_t HighLevelILInstructionBase::GetMediumLevelILExprIndex() const { return function->GetMediumLevelILExprIndex(exprIndex); diff --git a/highlevelilinstruction.h b/highlevelilinstruction.h index 497cf122..763c8221 100644 --- a/highlevelilinstruction.h +++ b/highlevelilinstruction.h @@ -318,6 +318,12 @@ namespace BinaryNinja _STD_SET()) const; Confidence> GetType() const; + size_t GetSSAExprIndex() const; + size_t GetNonSSAExprIndex() const; + + HighLevelILInstruction GetSSAForm() const; + HighLevelILInstruction GetNonSSAForm() const; + size_t GetMediumLevelILExprIndex() const; bool HasMediumLevelIL() const; MediumLevelILInstruction GetMediumLevelIL() const; -- cgit v1.3.1