Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libbs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "3.3.4"
__version__ = "3.4.0"


import logging
Expand Down
4 changes: 2 additions & 2 deletions libbs/api/decompiler_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
4 changes: 2 additions & 2 deletions libbs/api/decompiler_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion libbs/decompilers/binja/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""

Expand Down
4 changes: 2 additions & 2 deletions libbs/decompilers/ghidra/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions libbs/decompilers/ida/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion libbs/ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
Loading