summaryrefslogtreecommitdiff
path: root/examples/triage/triage.cpp
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2019-04-02 15:30:45 -0400
committerRusty Wagner <rusty@vector35.com>2019-04-02 15:36:40 -0400
commit73a9399f5d1d86c7e291498b7fe836550f2f76ab (patch)
treee7c7cfe9a2f27a93ddac41cf600e7bc1fc638a83 /examples/triage/triage.cpp
parentc17af471c48ea092434917c803f9c88fe91022a6 (diff)
Add a C++ version of the triage plugin (no Makefile yet)
Diffstat (limited to 'examples/triage/triage.cpp')
-rw-r--r--examples/triage/triage.cpp82
1 files changed, 82 insertions, 0 deletions
diff --git a/examples/triage/triage.cpp b/examples/triage/triage.cpp
new file mode 100644
index 00000000..d88180a0
--- /dev/null
+++ b/examples/triage/triage.cpp
@@ -0,0 +1,82 @@
+#include "uitypes.h"
+#include "view.h"
+#include "files.h"
+#include "byte.h"
+
+
+extern "C"
+{
+#ifdef DEMO_VERSION
+ bool TriagePluginInit()
+#else
+ BINARYNINJAPLUGIN bool UIPluginInit()
+#endif
+ {
+ BinaryNinja::Settings().RegisterGroup("triage", "Triage");
+ BinaryNinja::Settings().RegisterSetting("triage.always_prefer",
+ R"({
+ "title" : "Always Prefer Triage Summary View",
+ "type" : "boolean",
+ "default" : false,
+ "description" : "Always prefer opening binaries in Triage Summary view, even when performing full analysis."
+ })");
+
+ BinaryNinja::Settings().RegisterSetting("triage.prefer_for_raw",
+ R"({
+ "title" : "Prefer Triage Summary View for Raw Files",
+ "type" : "boolean",
+ "default" : true,
+ "description" : "Prefer opening raw files in Triage Summary view."
+ })");
+
+ ViewType::registerViewType(new TriageViewType());
+
+ BinaryNinja::Settings().RegisterSetting("triage.analysis_mode",
+ R"({
+ "title" : "Triage Analysis Mode",
+ "type" : "string",
+ "default" : "basic",
+ "description" : "Controls the amount of analysis performed on functions when opening for triage.",
+ "enum" : ["controlFlow", "basic", "full"],
+ "enumDescriptions" : [
+ "Only perform control flow analysis on the binary. Cross references are valid only for direct function calls.",
+ "Perform fast initial analysis of the binary. This mode does not analyze types or data flow through stack variables.",
+ "Perform full analysis of the binary." ]
+ })");
+
+ BinaryNinja::Settings().RegisterSetting("triage.linear_sweep",
+ R"({
+ "title" : "Triage Linear Sweep Mode",
+ "type" : "string",
+ "default" : "partial",
+ "description" : "Controls the level of linear sweep performed when opening for triage.",
+ "enum" : ["none", "partial", "full"],
+ "enumDescriptions" : [
+ "Do not perform linear sweep of the binary.",
+ "Perform linear sweep on the binary, but skip the control flow graph analysis phase.",
+ "Perform full linear sweep on the binary." ]
+ })");
+
+ UIAction::registerAction("Open for Triage...", QKeySequence("Ctrl+Alt+O"));
+ UIAction::registerAction("Open Selected Files");
+
+ UIActionHandler::globalActions()->bindAction("Open for Triage...", UIAction([](const UIActionContext& context) {
+ UIContext* currentContext = context.context;
+ if (!currentContext)
+ return;
+
+ // Do not try to set the parent window when creating tabs, as this will create a parent relationship in
+ // the bindings and will cause the widget to be destructed early. The correct parent will be assigned
+ // when createTabForWidget is called.
+ TriageFilePicker* fp = new TriageFilePicker(currentContext);
+ currentContext->createTabForWidget("Open for Triage", fp);
+ }));
+
+ Menu::mainMenu("File")->addAction("Open for Triage...", "Open");
+
+ UIContext::registerFileOpenMode("Triage...", "Open file(s) for quick analysis in the Triage Summary view.", "Open for Triage...");
+
+ ViewType::registerViewType(new ByteViewType());
+ return true;
+ }
+}