11from binaryninja import Architecture , BinaryView
2- from binaryninjaui import UIAction , UIActionHandler , Menu
2+ from binaryninjaui import UIAction , UIActionHandler , Menu , UIContext
33from PySide6 .QtWidgets import (
44 QApplication ,
55 QWidget ,
@@ -226,6 +226,13 @@ def check_bad_patterns(
226226class AssemblerWidget (QWidget ):
227227 def __init__ (self , parent = None ):
228228 super (AssemblerWidget , self ).__init__ (parent )
229+
230+ # To get a binaryview we can use the UIContext of the currently opened file/db
231+ view = UIContext .activeContext ().getCurrentView ()
232+ # Get the actual BinaryView from the UI view
233+ self .bv = view .getData () if view else None
234+ # Now we can access the architecture
235+ self ._current_arch = self .bv .arch if self .bv else None
229236 self .assembler = Assembler ()
230237 self .initUI ()
231238
@@ -238,6 +245,8 @@ def initUI(self) -> None:
238245 self .arch_combo = QComboBox ()
239246 for arch in list (Architecture ):
240247 self .arch_combo .addItem (arch .name )
248+ if self ._current_arch :
249+ self .arch_combo .setCurrentText (self ._current_arch .name )
241250 arch_layout .addWidget (arch_label )
242251 arch_layout .addWidget (self .arch_combo )
243252 layout .addLayout (arch_layout )
0 commit comments