summaryrefslogtreecommitdiff
path: root/plugins/warp/ui/plugin.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2026-03-13 12:24:18 -0700
committerMason Reed <35282038+emesare@users.noreply.github.com>2026-03-24 18:46:48 -0700
commit3c88b11e5df33116580ac008e36092775df66135 (patch)
treecd64fbe149f05683ddabcccd0db7b87356f1f8cf /plugins/warp/ui/plugin.cpp
parentf325aa7b6026a1daef84931baeb1f50d7da10c10 (diff)
[WARP] Improved UX and API
- Exposes WARP type objects directly - Adds processor API (for generating warp files directly) - Adds file and chunk API - Misc cleanup - Simplified the amount of commands - Replaced the "Create" commands with a purpose built processor dialog - Added a native QT viewer for WARP files - Simplified committing to a remote with a purpose built commit dialog
Diffstat (limited to 'plugins/warp/ui/plugin.cpp')
-rw-r--r--plugins/warp/ui/plugin.cpp77
1 files changed, 56 insertions, 21 deletions
diff --git a/plugins/warp/ui/plugin.cpp b/plugins/warp/ui/plugin.cpp
index e99059b9..0cf8deea 100644
--- a/plugins/warp/ui/plugin.cpp
+++ b/plugins/warp/ui/plugin.cpp
@@ -1,12 +1,15 @@
#include "plugin.h"
-
-#include <QToolBar>
-
#include "matched.h"
#include "matches.h"
#include "symbollist.h"
#include "viewframe.h"
+#include "shared/processordialog.h"
#include "shared/fetchdialog.h"
+#include "shared/file.h"
+
+#include <QToolBar>
+#include <QVBoxLayout>
+#include <utility>
using namespace BinaryNinja;
@@ -61,7 +64,7 @@ void ShowNetworkNotice()
}
}
-WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP"), m_data(data)
+WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP"), m_data(std::move(data))
{
m_logger = LogRegistry::CreateLogger("WARP UI");
m_currentFrame = nullptr;
@@ -85,30 +88,25 @@ WarpSidebarWidget::WarpSidebarWidget(BinaryViewRef data) : SidebarWidget("WARP")
});
fetchAction->setToolTip("Fetch data from WARP containers");
- auto commitIcon = GetColoredIcon(":/icons/images/arrow-push.png", getThemeColor(BlueStandardHighlightColor));
- auto commitAction = headerToolbar->addAction(commitIcon, "Commit a WARP file to a source", [this]() {
- UIActionHandler* handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
- handler->executeAction("WARP\\Commit File");
+ auto processIcon = GetColoredIcon(":/icons/images/plus.png", getThemeColor(BlueStandardHighlightColor));
+ auto processAction = headerToolbar->addAction(processIcon, "Process files or views for WARP", [this]() {
+ auto* dialog = new ProcessorDialog(this);
+ dialog->setAttribute(Qt::WA_DeleteOnClose);
+ dialog->onAddBinaryView(m_data);
+ dialog->show();
});
- commitAction->setToolTip("Commit a WARP file to a source");
+ processAction->setToolTip("Process files or views for WARP");
// We want to make it clear that the container actions for fetching and pushing are seperate.
headerToolbar->addSeparator();
- auto loadIcon = GetColoredIcon(":/icons/images/file-add.png", getThemeColor(BlueStandardHighlightColor));
+ auto loadIcon = GetColoredIcon(":/icons/images/archive.png", getThemeColor(BlueStandardHighlightColor));
auto loadAction = headerToolbar->addAction(loadIcon, "Load Signature File", [this]() {
UIActionHandler* handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
handler->executeAction("WARP\\Load File");
});
loadAction->setToolTip("Load a signature file to match against");
- auto saveIcon = GetColoredIcon(":/icons/images/edit.png", getThemeColor(BlueStandardHighlightColor));
- auto saveAction = headerToolbar->addAction(saveIcon, "Create Signature File", [this]() {
- UIActionHandler* handler = m_currentFrame->getCurrentViewInterface()->actionHandler();
- handler->executeAction("WARP\\Create\\From Current View");
- });
- saveAction->setToolTip("Save data to a signature file");
-
headerToolbar->addSeparator();
static auto matcherStopIcon = GetColoredIcon(":/icons/images/stop.png", getThemeColor(RedStandardHighlightColor));
@@ -234,10 +232,8 @@ void WarpSidebarWidget::notifyViewLocationChanged(View* view, const ViewLocation
// Warp sidebar really should only update if it is visible, otherwise its a waste of cycles.
if (!this->isVisible())
return;
- auto function = location.getFunction();
- // TODO: Only update if the function exists?
// NOTE: The function called will exit early if it is the same function.
- m_currentFunctionWidget->SetCurrentFunction(function);
+ m_currentFunctionWidget->SetCurrentFunction(location.getFunction());
}
void WarpSidebarWidget::focus()
@@ -249,6 +245,45 @@ void WarpSidebarWidget::focus()
WarpSidebarWidgetType::WarpSidebarWidgetType() : SidebarWidgetType(QImage(":/icons/images/warp.png"), "WARP") {}
+void RegisterCommands()
+{
+ RegisterPluginAction(
+ "Fetch",
+ [](const UIActionContext& context) {
+ WarpFetchDialog dlg(context.binaryView, WarpFetcher::Global(), nullptr);
+ dlg.exec();
+ },
+ [](const UIActionContext& context) { return context.binaryView != nullptr; });
+ RegisterPluginAction("Process", [](const UIActionContext& context) {
+ auto* dlg = new ProcessorDialog(context.widget);
+ dlg->setAttribute(Qt::WA_DeleteOnClose);
+ if (context.binaryView)
+ dlg->onAddBinaryView(context.binaryView);
+ dlg->show();
+ });
+ RegisterPluginAction("View File", [](const UIActionContext& context) {
+ std::string path;
+ if (!GetOpenFileNameInput(path, "Open WARP File", "*.warp"))
+ return;
+ auto file = Warp::File::FromPath(path);
+ if (!file)
+ return;
+
+ auto* dlg = new QDialog(context.widget);
+ dlg->setWindowTitle(QString::fromStdString("WARP File: " + path));
+ dlg->setAttribute(Qt::WA_DeleteOnClose);
+
+ auto* layout = new QVBoxLayout(dlg);
+ layout->setContentsMargins(10, 10, 10, 10);
+ auto* fileWidget = new FileWidget(dlg);
+ fileWidget->setFile(file);
+ layout->addWidget(fileWidget);
+
+ dlg->resize(1000, 700);
+ dlg->show();
+ });
+}
+
extern "C"
{
BN_DECLARE_UI_ABI_VERSION
@@ -267,7 +302,7 @@ extern "C"
BINARYNINJAPLUGIN bool UIPluginInit()
#endif
{
- RegisterWarpFetchFunctionsCommand();
+ RegisterCommands();
Sidebar::addSidebarWidgetType(new WarpSidebarWidgetType());
return true;
}