From b079d1a1e19151f5c39de84c2e1e6cc6a91abc74 Mon Sep 17 00:00:00 2001 From: Brandon Miller Date: Fri, 25 Apr 2025 13:30:45 -0400 Subject: Perform BB analysis from Architecture C++ API This commit moves AnalyzeBasicBlocks from the binary ninja core to the API and allows architecture plugins to optionally override AnalyzeBasicBlocks for a custom implementation Supply ABB inputs in BNBasicBlockAnalysisContext Register default analyze basic blocks callback This allows the nanomips and rust core architecture plugins to work again while using the C++ API DefaultAnalyzeBasicBlocks Use default ABB from Python plugins Fix bug in API ArchAndAddr operator overload Python APIs for basic block analysis --- python/binaryview.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'python/binaryview.py') diff --git a/python/binaryview.py b/python/binaryview.py index a03cb7bc..4761758a 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -4972,6 +4972,43 @@ class BinaryView: """ core.BNAbortAnalysis(self.handle) + @property + def analysis_is_aborted(self) -> bool: + """ + ``analysis_is_aborted`` checks if the analysis has been aborted. + + .. note:: This property is intended for use by architecture plugins only. + + :return: True if the analysis has been aborted, False otherwise + :rtype: bool + """ + + return core.BNAnalysisIsAborted(self.handle) + + def should_skip_target_analysis(self, source_location: '_function.ArchAndAddr', source_function: '_function.Function', + end: int, target_location: '_function.ArchAndAddr') -> bool: + """ + ``should_skip_target_analysis`` checks if target analysis should be skipped. + + .. note:: This method is intended for use by architecture plugins only. + + :param _function.ArchAndAddr source_location: The source location. + :param _function.Function source_function: The source function. + :param int end: The end address of the source branch instruction. + :param _function.ArchAndAddr target_location: The target location. + :return: True if the target analysis should be skipped, False otherwise + :rtype: bool + """ + + bn_src_arch_and_addr = core.BNArchitectureAndAddress() + bn_src_arch_and_addr.arch = source_location.arch.handle + bn_src_arch_and_addr.address = source_location.addr + bn_target_arch_and_addr = core.BNArchitectureAndAddress() + bn_target_arch_and_addr.arch = target_location.arch.handle + bn_target_arch_and_addr.address = target_location.addr + return core.BNShouldSkipTargetAnalysis(self.handle, bn_src_arch_and_addr, source_function.handle, end, + bn_target_arch_and_addr) + def define_data_var( self, addr: int, var_type: StringOrType, name: Optional[Union[str, '_types.CoreSymbol']] = None ) -> None: -- cgit v1.3.1