From 5b575ff6a87061221e1c17824b2b42af839ccc74 Mon Sep 17 00:00:00 2001 From: Brian Potchik Date: Tue, 8 Jul 2025 12:13:19 -0400 Subject: Various improvements for guided disassembly mode. --- python/architecture.py | 18 ++++++++++++++++-- python/function.py | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/architecture.py b/python/architecture.py index 099b56f1..a3307146 100644 --- a/python/architecture.py +++ b/python/architecture.py @@ -81,10 +81,11 @@ class BasicBlockAnalysisContext: _indirect_branches: List["variable.IndirectBranchInfo"] _indirect_no_return_calls: Set["function.ArchAndAddr"] _analysis_skip_override: core.FunctionAnalysisSkipOverride + _guided_analysis_mode: bool + _trigger_guided_on_invalid_instruction: bool _translate_tail_calls: bool _disallow_branch_to_string: bool _max_function_size: int - _halt_on_invalid_instruction: bool _max_size_reached: bool # In/Out @@ -157,10 +158,11 @@ class BasicBlockAnalysisContext: _indirect_branches=indirect_branches, _indirect_no_return_calls=indirect_no_return_calls, _analysis_skip_override=bn_bb_context.analysisSkipOverride, + _guided_analysis_mode=bn_bb_context.guidedAnalysisMode, + _trigger_guided_on_invalid_instruction=bn_bb_context.triggerGuidedOnInvalidInstruction, _translate_tail_calls=bn_bb_context.translateTailCalls, _disallow_branch_to_string=bn_bb_context.disallowBranchToString, _max_function_size=bn_bb_context.maxFunctionSize, - _halt_on_invalid_instruction=bn_bb_context.haltOnInvalidInstructions, _max_size_reached=bn_bb_context.maxSizeReached, _contextual_returns=contextual_returns, _contextual_returns_dirty=False, @@ -187,6 +189,18 @@ class BasicBlockAnalysisContext: return self._analysis_skip_override + @property + def guided_analysis_mode(self) -> bool: + """Get the setting that determines if functions start in guided analysis mode.""" + + return self._guided_analysis_mode + + @property + def trigger_guided_on_invalid_instruction(self) -> bool: + """Get the setting that determines if guided mode should be triggered on invalid instructions.""" + + return self._trigger_guided_on_invalid_instruction + @property def translate_tail_calls(self) -> bool: """Get setting from context that determines if tail calls should be translated.""" diff --git a/python/function.py b/python/function.py index 37bd3396..9ea8093b 100644 --- a/python/function.py +++ b/python/function.py @@ -2326,6 +2326,22 @@ class Function: address_list[i].address = addresses[i][1] core.BNRemoveGuidedSourceBlocks(self.handle, address_list, len(addresses)) + def is_guided_source_block( + self, arch: 'architecture.Architecture', addr: int + ) -> bool: + """ + ``is_guided_source_block`` checks if the given address is a guided source block. + + :param architecture.Architecture arch: Architecture of the address to check + :param int addr: Address to check + :rtype: bool + :Example: + + >>> current_function.is_guided_source_block(arch, 0x400000) + True + """ + return core.BNIsGuidedSourceBlock(self.handle, arch.handle, addr) + def get_guided_source_blocks( self ) -> List[Tuple['architecture.Architecture', int]]: -- cgit v1.3.1