summaryrefslogtreecommitdiff
path: root/view/sharedcache/ui/dscpicker.cpp
diff options
context:
space:
mode:
authorkat <kat@vector35.com>2024-10-23 21:56:29 -0400
committerkat <kat@vector35.com>2024-10-23 21:58:47 -0400
commit3006c68e108a18f9b8782bc937dc9ec7e2cb3b54 (patch)
treef589bb38909349142c09b6215244205aef0a57ac /view/sharedcache/ui/dscpicker.cpp
parent80fcccec8f686e0e5c89626b60af121a97baf856 (diff)
Initial commit of the alpha dyld_shared_cache view API Plugin.
This is an early release of our DSC processing plugin. We're still hard at work improving this feature. You should be able to just drop in a dyld_shared_cache and use the 'Shared Cache Triage' view to load and analyze images.
Diffstat (limited to 'view/sharedcache/ui/dscpicker.cpp')
-rw-r--r--view/sharedcache/ui/dscpicker.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/view/sharedcache/ui/dscpicker.cpp b/view/sharedcache/ui/dscpicker.cpp
new file mode 100644
index 00000000..33877675
--- /dev/null
+++ b/view/sharedcache/ui/dscpicker.cpp
@@ -0,0 +1,42 @@
+//
+// Created by kat on 5/22/23.
+//
+
+#include "dscpicker.h"
+#include <sharedcacheapi.h>
+#include "progresstask.h"
+
+#include <utility>
+
+using namespace BinaryNinja;
+
+void DisplayDSCPicker(UIContext* ctx, Ref<BinaryView> dscView)
+{
+ BackgroundThread::create(ctx ? ctx->mainWindow() : nullptr)->thenBackground(
+ [dscView=dscView](QVariant var) {
+ QStringList entries;
+ SharedCacheAPI::SCRef<SharedCacheAPI::SharedCache> cache = new SharedCacheAPI::SharedCache(dscView);
+
+ for (const auto& img : cache->GetAvailableImages())
+ entries.push_back(QString::fromStdString(img));
+
+ return entries;
+ })->thenMainThread([ctx](QVariant var){
+ QStringList entries = var.toStringList();
+
+ auto choiceDialog = new MetadataChoiceDialog(ctx ? ctx->mainWindow() : nullptr, "Pick Image", "Select", entries);
+ choiceDialog->AddWidthRequiredByItem(ctx, 300);
+ choiceDialog->AddHeightRequiredByItem(ctx, 150);
+ choiceDialog->exec();
+
+ if (choiceDialog->GetChosenEntry().has_value())
+ return QVariant(QString::fromStdString(entries.at((qsizetype)choiceDialog->GetChosenEntry().value().idx).toStdString()));
+ else
+ return QVariant("");
+ })->thenBackground([dscView=dscView](QVariant var){
+ if (var.toString().isEmpty())
+ return;
+ SharedCacheAPI::SCRef<SharedCacheAPI::SharedCache> cache = new SharedCacheAPI::SharedCache(dscView);
+ cache->LoadImageWithInstallName(var.toString().toStdString());
+ })->start();
+}