From 490cb877e538390f0515d0808d57076c1f427537 Mon Sep 17 00:00:00 2001 From: Jim Carciofini Date: Wed, 21 Feb 2024 11:44:21 -0600 Subject: [PATCH] Initial (disabled) experiment getting binja basic blocks. --- pate_binja/view.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/pate_binja/view.py b/pate_binja/view.py index b45d5cfb..10b2320c 100644 --- a/pate_binja/view.py +++ b/pate_binja/view.py @@ -10,7 +10,7 @@ from typing import Optional from binaryninja import show_graph_report, execute_on_main_thread_and_wait, BinaryView, OpenFileNameField, interaction, \ - MultilineTextField + MultilineTextField, load from binaryninja.enums import BranchType, HighlightStandardColor, EdgePenStyle, ThemeColor from binaryninja.flowgraph import FlowGraph, FlowGraphNode, FlowGraphEdge, EdgeStyle from binaryninja.plugin import BackgroundTaskThread @@ -145,7 +145,7 @@ def __init__(self, bv, run_fn, pate_widget: PateWidget, replay=False, show_ce_tr self.pBv = None def run(self): - + #self.loadBinaryViews() x = self.run_fn(self.replay) if self.trace_file: with open(self.trace_file, "w") as trace: @@ -157,6 +157,27 @@ def run(self): self.proc = proc self._command_loop(proc, self.show_ce_trace) + def loadBinaryViews(self): + # TODO: May need a progress feedback. Can this take a significant amount of time? + config = self.pate_widget.config + if config: + cwd = config.get('cwd') + original = config.get('original') + patched = config.get('patched') + if cwd and original: + self.oBv = load(os.path.join(cwd, original)) + self.oBv.add_analysis_completion_event(lambda: print('finished loading', original)) + if cwd and patched: + self.pBv = load(os.path.join(cwd, patched)) + self.pBv.add_analysis_completion_event(lambda: print('finished loading', patched)) + # TODO: close binary views when finished + self.hackaroo() + + def hackaroo(self): + a = 0x400c + bb = self.oBv.get_basic_blocks_at(a) + print(bb) + def cancel(self) -> None: if self.proc and self.is_alive(): # Terminate the process group (SIGINT does not work so using SIGKILL)