diff --git a/libbs/__init__.py b/libbs/__init__.py index 4d0d6c4..5034083 100644 --- a/libbs/__init__.py +++ b/libbs/__init__.py @@ -1,4 +1,4 @@ -__version__ = "3.3.4" +__version__ = "3.4.0" import logging diff --git a/libbs/api/decompiler_client.py b/libbs/api/decompiler_client.py index 60f17c9..95c4fee 100644 --- a/libbs/api/decompiler_client.py +++ b/libbs/api/decompiler_client.py @@ -504,9 +504,9 @@ def gui_show_type(self, type_name: str) -> None: """Show a type in the GUI""" return self._send_request({"type": "method_call", "method_name": "gui_show_type", "args": [type_name]}) - def gui_ask_for_string(self, question: str, title: str = "Plugin Question") -> str: + def gui_ask_for_string(self, question: str, title: str = "Plugin Question", default: str = "") -> str: """Ask for a string input""" - return self._send_request({"type": "method_call", "method_name": "gui_ask_for_string", "args": [question, title]}) + return self._send_request({"type": "method_call", "method_name": "gui_ask_for_string", "args": [question, title, default]}) def gui_ask_for_choice(self, question: str, choices: list, title: str = "Plugin Question") -> str: """Ask for a choice from a list""" diff --git a/libbs/api/decompiler_interface.py b/libbs/api/decompiler_interface.py index 022d89e..dec65cf 100644 --- a/libbs/api/decompiler_interface.py +++ b/libbs/api/decompiler_interface.py @@ -195,13 +195,13 @@ def gui_show_type(self, type_name: str) -> None: def gui_register_ctx_menu(self, name, action_string, callback_func, category=None) -> bool: raise NotImplementedError - def gui_ask_for_string(self, question, title="Plugin Question") -> str: + def gui_ask_for_string(self, question, title="Plugin Question", default="") -> str: """ Opens a GUI dialog box that asks the user for a string. If not overriden by the decompiler interface, this will default to a Qt dialog box that is based on the decompilers Qt version. """ from libbs.ui.utils import gui_ask_for_string - return gui_ask_for_string(question, title=title) + return gui_ask_for_string(question, title=title, default=default) def gui_ask_for_choice(self, question: str, choices: list, title="Plugin Question") -> str: """ diff --git a/libbs/decompilers/binja/interface.py b/libbs/decompilers/binja/interface.py index 3142182..3a33d75 100644 --- a/libbs/decompilers/binja/interface.py +++ b/libbs/decompilers/binja/interface.py @@ -145,7 +145,7 @@ def gui_register_ctx_menu(self, name, action_string, callback_func, category=Non ) return True - def gui_ask_for_string(self, question, title="Plugin Question") -> str: + def gui_ask_for_string(self, question, title="Plugin Question", default="") -> str: resp = binaryninja.get_text_line_input(question, title) return resp.decode() if resp else "" diff --git a/libbs/decompilers/ghidra/interface.py b/libbs/decompilers/ghidra/interface.py index 0bcb3aa..9daf21e 100644 --- a/libbs/decompilers/ghidra/interface.py +++ b/libbs/decompilers/ghidra/interface.py @@ -167,8 +167,8 @@ def callback_func_wrap(*args, **kwargs): ) return True - def gui_ask_for_string(self, question, title="Plugin Question") -> str: - answer = self.flat_api.askString(title, question) + def gui_ask_for_string(self, question, title="Plugin Question", default="") -> str: + answer = self.flat_api.askString(title, question, default) return answer if answer else "" def gui_ask_for_choice(self, question: str, choices: list, title="Plugin Question") -> str: diff --git a/libbs/decompilers/ida/interface.py b/libbs/decompilers/ida/interface.py index 1eeb243..af5ba53 100755 --- a/libbs/decompilers/ida/interface.py +++ b/libbs/decompilers/ida/interface.py @@ -106,8 +106,8 @@ def dec_version(self): # GUI # - def gui_ask_for_string(self, question, title="Plugin Question") -> str: - resp = idaapi.ask_str("", 0, question) + def gui_ask_for_string(self, question, title="Plugin Question", default="") -> str: + resp = idaapi.ask_str(default, 0, question) return resp if resp else "" def gui_ask_for_choice(self, question: str, choices: list, title="Plugin Question") -> str: diff --git a/libbs/ui/utils.py b/libbs/ui/utils.py index 94c9fee..47b3f50 100644 --- a/libbs/ui/utils.py +++ b/libbs/ui/utils.py @@ -19,7 +19,7 @@ def gui_popup_text(text, title="Plugin Info") -> bool: return False -def gui_ask_for_string(question, title="Plugin Question") -> str: +def gui_ask_for_string(question, title="Plugin Question", default="") -> str: dialog = QDialog() dialog.setWindowTitle(title) @@ -31,6 +31,8 @@ def gui_ask_for_string(question, title="Plugin Question") -> str: # Text input field text_input = QLineEdit() + if default: + text_input.setText(default) layout.addWidget(text_input) # Submit button