Skip to content

Commit

Permalink
Merge pull request #5 from 0xricksanchez/default_arch
Browse files Browse the repository at this point in the history
  • Loading branch information
0xricksanchez authored Nov 28, 2024
2 parents d821bbb + a685aaa commit cf7045e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from binaryninja import Architecture, BinaryView
from binaryninjaui import UIAction, UIActionHandler, Menu
from binaryninjaui import UIAction, UIActionHandler, Menu, UIContext
from PySide6.QtWidgets import (
QApplication,
QWidget,
Expand Down Expand Up @@ -226,6 +226,13 @@ def check_bad_patterns(
class AssemblerWidget(QWidget):
def __init__(self, parent=None):
super(AssemblerWidget, self).__init__(parent)

# To get a binaryview we can use the UIContext of the currently opened file/db
view = UIContext.activeContext().getCurrentView()
# Get the actual BinaryView from the UI view
self.bv = view.getData() if view else None
# Now we can access the architecture
self._current_arch = self.bv.arch if self.bv else None
self.assembler = Assembler()
self.initUI()

Expand All @@ -238,6 +245,8 @@ def initUI(self) -> None:
self.arch_combo = QComboBox()
for arch in list(Architecture):
self.arch_combo.addItem(arch.name)
if self._current_arch:
self.arch_combo.setCurrentText(self._current_arch.name)
arch_layout.addWidget(arch_label)
arch_layout.addWidget(self.arch_combo)
layout.addLayout(arch_layout)
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
"type": [
"helper"
],
"version": "1.0.1"
"version": "1.0.2"
}

0 comments on commit cf7045e

Please sign in to comment.