1
1
from binaryninja import Architecture , BinaryView
2
- from binaryninjaui import UIAction , UIActionHandler , Menu
2
+ from binaryninjaui import UIAction , UIActionHandler , Menu , UIContext
3
3
from PySide6 .QtWidgets import (
4
4
QApplication ,
5
5
QWidget ,
@@ -226,6 +226,13 @@ def check_bad_patterns(
226
226
class AssemblerWidget (QWidget ):
227
227
def __init__ (self , parent = None ):
228
228
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
229
236
self .assembler = Assembler ()
230
237
self .initUI ()
231
238
@@ -238,6 +245,8 @@ def initUI(self) -> None:
238
245
self .arch_combo = QComboBox ()
239
246
for arch in list (Architecture ):
240
247
self .arch_combo .addItem (arch .name )
248
+ if self ._current_arch :
249
+ self .arch_combo .setCurrentText (self ._current_arch .name )
241
250
arch_layout .addWidget (arch_label )
242
251
arch_layout .addWidget (self .arch_combo )
243
252
layout .addLayout (arch_layout )
0 commit comments