From 0fdf63426e186102906c1fb8b8e7107c058023ae Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Tue, 15 Jul 2025 20:25:48 -0400 Subject: Finish guided analysis feature and add unit tests. --- binaryninjaapi.h | 1 + binaryninjacore.h | 3 ++- function.cpp | 6 ++++++ python/function.py | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 595c827e..50312bbc 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -11602,6 +11602,7 @@ namespace BinaryNinja { void RemoveGuidedSourceBlocks(const std::vector& addresses); bool IsGuidedSourceBlock(Architecture* arch, uint64_t addr) const; std::vector GetGuidedSourceBlocks(); + bool HasGuidedSourceBlocks() const; std::vector GetIndirectBranches(); std::vector GetIndirectBranchesAt(Architecture* arch, uint64_t addr); diff --git a/binaryninjacore.h b/binaryninjacore.h index dd1c8c56..93a15b54 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -37,7 +37,7 @@ // Current ABI version for linking to the core. This is incremented any time // there are changes to the API that affect linking, including new functions, // new types, or modifications to existing functions or types. -#define BN_CURRENT_CORE_ABI_VERSION 124 +#define BN_CURRENT_CORE_ABI_VERSION 125 // Minimum ABI version that is supported for loading of plugins. Plugins that // are linked to an ABI version less than this will not be able to load and @@ -5170,6 +5170,7 @@ extern "C" BINARYNINJACOREAPI void BNRemoveGuidedSourceBlocks(BNFunction* func, BNArchitectureAndAddress* addresses, size_t count); BINARYNINJACOREAPI bool BNIsGuidedSourceBlock(BNFunction* func, BNArchitecture* arch, uint64_t addr); BINARYNINJACOREAPI BNArchitectureAndAddress* BNGetGuidedSourceBlocks(BNFunction* func, size_t* count); + BINARYNINJACOREAPI bool BNHasGuidedSourceBlocks(BNFunction* func); BINARYNINJACOREAPI void BNFreeArchitectureAndAddressList(BNArchitectureAndAddress* addresses); BINARYNINJACOREAPI BNIndirectBranchInfo* BNGetIndirectBranches(BNFunction* func, size_t* count); diff --git a/function.cpp b/function.cpp index 1b2c0a46..1d35aa7d 100644 --- a/function.cpp +++ b/function.cpp @@ -1750,6 +1750,12 @@ std::vector Function::GetGuidedSourceBlocks() } +bool Function::HasGuidedSourceBlocks() const +{ + return BNHasGuidedSourceBlocks(m_object); +} + + vector Function::GetIndirectBranches() { size_t count; diff --git a/python/function.py b/python/function.py index eb80f9b0..b4343d00 100644 --- a/python/function.py +++ b/python/function.py @@ -2352,6 +2352,9 @@ class Function: if addresses is not None: core.BNFreeArchitectureAndAddressList(addresses) + def has_guided_source_blocks(self) -> bool: + return core.BNHasGuidedSourceBlocks(self.handle) + def get_indirect_branches_at( self, addr: int, arch: Optional['architecture.Architecture'] = None ) -> List['variable.IndirectBranchInfo']: -- cgit v1.3.1