summaryrefslogtreecommitdiff
path: root/interaction.cpp
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2023-03-16 14:26:49 -0400
committerGlenn Smith <glenn@vector35.com>2023-11-01 18:31:16 -0400
commit4b6fb132a97a7852e69a746e2e259bf423b14969 (patch)
tree307170791865c804a41a7592a1631069093cbc8e /interaction.cpp
parent59f28bc770f664917dbd01a5e08c716e58f0db70 (diff)
Add interaction.get_large_choice_input for large numbers of options
Diffstat (limited to 'interaction.cpp')
-rw-r--r--interaction.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/interaction.cpp b/interaction.cpp
index 7bc1d2fa..037edca6 100644
--- a/interaction.cpp
+++ b/interaction.cpp
@@ -255,7 +255,7 @@ static bool GetAddressInputCallback(
static bool GetChoiceInputCallback(
- void* ctxt, size_t* result, const char* prompt, const char* title, const char** choices, size_t count)
+ void* ctxt, size_t* result, const char* prompt, const char* title, const char** choices, size_t count)
{
InteractionHandler* handler = (InteractionHandler*)ctxt;
vector<string> choiceStrs;
@@ -265,6 +265,17 @@ static bool GetChoiceInputCallback(
}
+static bool GetLargeChoiceInputCallback(
+ void* ctxt, size_t* result, const char* prompt, const char* title, const char** choices, size_t count)
+{
+ InteractionHandler* handler = (InteractionHandler*)ctxt;
+ vector<string> choiceStrs;
+ for (size_t i = 0; i < count; i++)
+ choiceStrs.push_back(choices[i]);
+ return handler->GetLargeChoiceInput(*result, prompt,title, choiceStrs);
+}
+
+
static bool GetOpenFileNameInputCallback(void* ctxt, char** result, const char* prompt, const char* ext)
{
InteractionHandler* handler = (InteractionHandler*)ctxt;
@@ -445,6 +456,7 @@ void BinaryNinja::RegisterInteractionHandler(InteractionHandler* handler)
cb.getIntegerInput = GetIntegerInputCallback;
cb.getAddressInput = GetAddressInputCallback;
cb.getChoiceInput = GetChoiceInputCallback;
+ cb.getLargeChoiceInput = GetLargeChoiceInputCallback;
cb.getOpenFileNameInput = GetOpenFileNameInputCallback;
cb.getSaveFileNameInput = GetSaveFileNameInputCallback;
cb.getDirectoryNameInput = GetDirectoryNameInputCallback;
@@ -533,6 +545,17 @@ bool BinaryNinja::GetChoiceInput(size_t& idx, const string& prompt, const string
}
+bool BinaryNinja::GetLargeChoiceInput(size_t& idx, const string& prompt, const string& title, const vector<string>& choices)
+{
+ const char** choiceStrs = new const char*[choices.size()];
+ for (size_t i = 0; i < choices.size(); i++)
+ choiceStrs[i] = choices[i].c_str();
+ bool ok = BNGetLargeChoiceInput(&idx, prompt.c_str(), title.c_str(), choiceStrs, choices.size());
+ delete[] choiceStrs;
+ return ok;
+}
+
+
bool BinaryNinja::GetOpenFileNameInput(string& result, const string& prompt, const string& ext)
{
char* value = nullptr;