Skip to content

Commit

Permalink
Initial (disabled) experiment getting binja basic blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-carciofini committed Feb 21, 2024
1 parent 18a90ad commit 490cb87
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions pate_binja/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 490cb87

Please sign in to comment.