From c85a0a26c12fcef22ee0df37a54716d139c589cf Mon Sep 17 00:00:00 2001 From: Xusheng Date: Fri, 5 Jul 2024 13:15:48 +0800 Subject: Expose Function::UsesIncomingGlobalPointer through the API. Fix https://github.com/Vector35/binaryninja-api/issues/5686 --- binaryninjaapi.h | 1 + binaryninjacore.h | 1 + function.cpp | 6 ++++++ python/function.py | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index c37a1a3d..0a1fab7c 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -10793,6 +10793,7 @@ namespace BinaryNinja { std::vector GetTypeTokens(DisassemblySettings* settings = nullptr); Confidence GetGlobalPointerValue() const; + bool UsesIncomingGlobalPointer() const; Confidence GetRegisterValueAtExit(uint32_t reg) const; /*! Whether the function is too large to automatically perform analysis diff --git a/binaryninjacore.h b/binaryninjacore.h index 16d86fc7..081f0d4b 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -4416,6 +4416,7 @@ extern "C" BNFunction* func, BNDisassemblySettings* settings, size_t* count); BINARYNINJACOREAPI BNRegisterValueWithConfidence BNGetFunctionGlobalPointerValue(BNFunction* func); + BINARYNINJACOREAPI bool BNFunctionUsesIncomingGlobalPointer(BNFunction* func); BINARYNINJACOREAPI BNRegisterValueWithConfidence BNGetFunctionRegisterValueAtExit(BNFunction* func, uint32_t reg); BINARYNINJACOREAPI BNBoolWithConfidence BNIsFunctionInlinedDuringAnalysis(BNFunction* func); diff --git a/function.cpp b/function.cpp index 2838f079..8497ccec 100644 --- a/function.cpp +++ b/function.cpp @@ -2399,6 +2399,12 @@ Confidence Function::GetGlobalPointerValue() const } +bool Function::UsesIncomingGlobalPointer() const +{ + return BNFunctionUsesIncomingGlobalPointer(m_object); +} + + Confidence Function::GetRegisterValueAtExit(uint32_t reg) const { BNRegisterValueWithConfidence value = BNGetFunctionRegisterValueAtExit(m_object, reg); diff --git a/python/function.py b/python/function.py index e43570a7..e21716ac 100644 --- a/python/function.py +++ b/python/function.py @@ -1821,6 +1821,11 @@ class Function: result = core.BNGetFunctionGlobalPointerValue(self.handle) return variable.RegisterValue.from_BNRegisterValue(result, self.arch) + @property + def uses_incoming_global_pointer(self) -> bool: + """Whether the function uses the incoming global pointer value""" + return core.BNFunctionUsesIncomingGlobalPointer(self.handle) + @property def comment(self) -> str: """Gets the comment for the current function""" -- cgit v1.3.1