From bbbe4d177c378077b43b09c74a3a20a09bfee443 Mon Sep 17 00:00:00 2001 From: Galen Williamson Date: Mon, 2 May 2022 15:36:52 -0400 Subject: added API for GetLanguageRepresentationIfAvailable --- binaryninjaapi.h | 1 + binaryninjacore.h | 1 + function.cpp | 14 +++++++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 763eb02c..755d465c 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -3778,6 +3778,7 @@ namespace BinaryNinja { Ref GetHighLevelIL() const; Ref GetHighLevelILIfAvailable() const; Ref GetLanguageRepresentation() const; + Ref GetLanguageRepresentationIfAvailable() const; Ref GetType() const; Confidence> GetReturnType() const; diff --git a/binaryninjacore.h b/binaryninjacore.h index fd004a27..cd079fdc 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -3583,6 +3583,7 @@ extern "C" BINARYNINJACOREAPI BNHighLevelILFunction* BNGetFunctionHighLevelIL(BNFunction* func); BINARYNINJACOREAPI BNHighLevelILFunction* BNGetFunctionHighLevelILIfAvailable(BNFunction* func); BINARYNINJACOREAPI BNLanguageRepresentationFunction* BNGetFunctionLanguageRepresentation(BNFunction* func); + BINARYNINJACOREAPI BNLanguageRepresentationFunction* BNGetFunctionLanguageRepresentationIfAvailable(BNFunction* func); BINARYNINJACOREAPI BNRegisterValue BNGetRegisterValueAtInstruction( BNFunction* func, BNArchitecture* arch, uint64_t addr, uint32_t reg); BINARYNINJACOREAPI BNRegisterValue BNGetRegisterValueAfterInstruction( diff --git a/function.cpp b/function.cpp index bacfbab0..c93a8329 100644 --- a/function.cpp +++ b/function.cpp @@ -769,7 +769,19 @@ Ref Function::GetHighLevelILIfAvailable() const Ref Function::GetLanguageRepresentation() const { - return new LanguageRepresentationFunction(BNGetFunctionLanguageRepresentation(m_object)); + BNLanguageRepresentationFunction* function = BNGetFunctionLanguageRepresentation(m_object); + if (!function) + return nullptr; + return new LanguageRepresentationFunction(function); +} + + +Ref Function::GetLanguageRepresentationIfAvailable() const +{ + BNLanguageRepresentationFunction* function = BNGetFunctionLanguageRepresentationIfAvailable(m_object); + if (!function) + return nullptr; + return new LanguageRepresentationFunction(function); } -- cgit v1.3.1