summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2025-07-08 12:13:19 -0400
committerBrian Potchik <brian@vector35.com>2025-07-08 12:13:19 -0400
commit5b575ff6a87061221e1c17824b2b42af839ccc74 (patch)
tree5f37836f732f1af49a048c9a957250e2bc57984b /python
parent33e9108b92a73782e271852c6b438c2937706fbe (diff)
Various improvements for guided disassembly mode.
Diffstat (limited to 'python')
-rw-r--r--python/architecture.py18
-rw-r--r--python/function.py16
2 files changed, 32 insertions, 2 deletions
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,
@@ -188,6 +190,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]]: