Writing a Python plugin that will export the binary version of the function(s) selected in the UI. #6065
Replies: 1 comment
-
There's a few ways you could do this: These would work for a single function:
However, if you want to select multiple functions your options are more limited and it requires a lot more work primarily because there's no existing UI/API around a multi-select so you'd need to write your own custom QT. Either to try to inspect/walk the existing UI elements to identify in the symbol list for example which functions are selected, or to render your own popup that would provide something like checkboxes. If you go that route, here's some boiler-plate code: from PySide6.QtWidgets import (
QApplication,
QDialog,
QVBoxLayout,
QListWidget,
QListWidgetItem,
QDialogButtonBox,
)
import sys
class MultiSelectDialog(QDialog):
def __init__(self, items, parent=None):
super().__init__(parent)
self.setWindowTitle("Select Items")
# Main layout
layout = QVBoxLayout(self)
# Scrollable list
self.list_widget = QListWidget(self)
self.list_widget.setSelectionMode(QListWidget.MultiSelection) # Enable multi-selection
for item in items:
QListWidgetItem(item, self.list_widget)
layout.addWidget(self.list_widget)
# Buttons
button_box = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, self)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
layout.addWidget(button_box)
def selected_items(self):
return [item.text() for item in self.list_widget.selectedItems()]
if __name__ == "__main__":
app = QApplication(sys.argv)
# Sample data
items = [f"Item {i}" for i in range(1, 101)] # Long list of items
dialog = MultiSelectDialog(items)
if dialog.exec():
print("Selected Items:", dialog.selected_items())
else:
print("No selection made.")
sys.exit(app.exec()) Adapt as required inside a BN script by making sure you first import binaryninjaui (which should load the appropriate PySide6 paths) and of course removing the main section. |
Beta Was this translation helpful? Give feedback.
-
Greetings,
I'd like to allow the user to select one or more functions in the UI and then export the original binary for each function, one at a time, to a process running on another server via a REST API call.
I've got the plugin installed and running, it reads a config file to get the server address, it prompts the user for some information, but then I'm stuck - how do I determine what function(s) the user has selected in the UI?
Thank you.
-David
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions