summaryrefslogtreecommitdiff
path: root/python/flowgraph.py
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2019-02-28 22:18:52 -0500
committerRusty Wagner <rusty@vector35.com>2019-03-20 12:58:42 -0400
commit4ed3228ecdb1a6ec5b22341ae2ddd1b090577628 (patch)
tree9acbe4a714d6929b5fc26154a82c92a48da4a44c /python/flowgraph.py
parent6e05d56c53c31ac2b87cc64b48d6b501b1ca0650 (diff)
Add flow graph options for additional UI features
Diffstat (limited to 'python/flowgraph.py')
-rw-r--r--python/flowgraph.py76
1 files changed, 75 insertions, 1 deletions
diff --git a/python/flowgraph.py b/python/flowgraph.py
index 4d2bd3ba..ce92e47b 100644
--- a/python/flowgraph.py
+++ b/python/flowgraph.py
@@ -24,7 +24,7 @@ import traceback
# Binary Ninja components
import binaryninja
-from binaryninja.enums import (BranchType, InstructionTextTokenType, HighlightStandardColor)
+from binaryninja.enums import (BranchType, InstructionTextTokenType, HighlightStandardColor, FlowGraphOption)
from binaryninja import _binaryninjacore as core
from binaryninja import function
from binaryninja import binaryview
@@ -411,6 +411,20 @@ class FlowGraph(object):
core.BNSetFunctionForFlowGraph(self.handle, func)
@property
+ def view(self):
+ """Binary view for a flow graph"""
+ view = core.BNGetViewForFlowGraph(self.handle)
+ if view is None:
+ return None
+ return binaryview.BinaryView(handle = view)
+
+ @view.setter
+ def view(self, view):
+ if view is not None:
+ view = view.handle
+ core.BNSetViewForFlowGraph(self.handle, view)
+
+ @property
def complete(self):
"""Whether flow graph layout is complete (read-only)"""
return core.BNIsFlowGraphLayoutComplete(self.handle)
@@ -503,6 +517,60 @@ class FlowGraph(object):
else:
raise TypeError("expected IL function for setting il_function property")
+ @property
+ def uses_block_highlights(self):
+ """Set if flow graph uses the standard basic block highlighting settings"""
+ return self.is_option_set(FlowGraphOption.FlowGraphUsesBlockHighlights)
+
+ @uses_block_highlights.setter
+ def uses_block_highlights(self, value):
+ self.set_option(FlowGraphOption.FlowGraphUsesBlockHighlights, value)
+
+ @property
+ def uses_instruction_highlights(self):
+ """Set if flow graph uses the standard instruction highlighting settings"""
+ return self.is_option_set(FlowGraphOption.FlowGraphUsesInstructionHighlights)
+
+ @uses_instruction_highlights.setter
+ def uses_instruction_highlights(self, value):
+ self.set_option(FlowGraphOption.FlowGraphUsesInstructionHighlights, value)
+
+ @property
+ def includes_user_comments(self):
+ """Set if flow graph includes comments made by the user"""
+ return self.is_option_set(FlowGraphOption.FlowGraphIncludesUserComments)
+
+ @includes_user_comments.setter
+ def includes_user_comments(self, value):
+ self.set_option(FlowGraphOption.FlowGraphIncludesUserComments, value)
+
+ @property
+ def allows_patching(self):
+ """Set if flow graph should allow modification of code from within the graph view"""
+ return self.is_option_set(FlowGraphOption.FlowGraphAllowsPatching)
+
+ @allows_patching.setter
+ def allows_patching(self, value):
+ self.set_option(FlowGraphOption.FlowGraphAllowsPatching, value)
+
+ @property
+ def allows_inline_instruction_editing(self):
+ """Set if flow graph should allow inline instruction editing (assembly only)"""
+ return self.is_option_set(FlowGraphOption.FlowGraphAllowsInlineInstructionEditing)
+
+ @allows_inline_instruction_editing.setter
+ def allows_inline_instruction_editing(self, value):
+ self.set_option(FlowGraphOption.FlowGraphAllowsInlineInstructionEditing, value)
+
+ @property
+ def shows_secondary_reg_highlighting(self):
+ """Set if flow graph should highlight associated registers in the UI"""
+ return self.is_option_set(FlowGraphOption.FlowGraphShowsSecondaryRegisterHighlighting)
+
+ @shows_secondary_reg_highlighting.setter
+ def shows_secondary_reg_highlighting(self, value):
+ self.set_option(FlowGraphOption.FlowGraphShowsSecondaryRegisterHighlighting, value)
+
def __setattr__(self, name, value):
try:
object.__setattr__(self, name, value)
@@ -604,6 +672,12 @@ class FlowGraph(object):
"""
return None
+ def set_option(self, option, value = True):
+ core.BNSetFlowGraphOption(self.handle, option, value)
+
+ def is_option_set(self, option):
+ return core.BNIsFlowGraphOptionSet(self.handle, option)
+
class CoreFlowGraph(FlowGraph):
def __init__(self, handle):