MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / openSelectedFiles

Method openSelectedFiles

examples/triage/files.cpp:66–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64
65
66void TriageFilePicker::openSelectedFiles()
67{
68 std::vector<QString> failedToOpen;
69 std::set<QString> files;
70 SettingsRef settings = BinaryNinja::Settings::Instance();
71
72 for (auto& index : m_tree->selectionModel()->selectedIndexes())
73 if (m_model->fileInfo(index).isFile())
74 files.insert(m_model->fileInfo(index).absoluteFilePath());
75
76 for (auto& filename : files)
77 {
78 QSettings().setValue("triage/recentFile", filename);
79
80 FileContext* f = FileContext::openFilename(filename);
81 if (!f)
82 {
83 failedToOpen.push_back(filename);
84 continue;
85 }
86
87 for (auto data : f->getAllDataViews())
88 {
89 settings->Set("analysis.mode", settings->Get<std::string>("triage.analysisMode"), data);
90 settings->Set("triage.preferSummaryView", true, data);
91 if (data->GetTypeName() != "Raw")
92 {
93 std::string linearSweepMode = settings->Get<std::string>("triage.linearSweep");
94 if (linearSweepMode == "none")
95 {
96 settings->Set("analysis.linearSweep.autorun", false, data);
97 settings->Set("analysis.signatureMatcher.autorun", false, data);
98 }
99 else if (linearSweepMode == "partial")
100 {
101 settings->Set("analysis.linearSweep.autorun", true, data);
102 settings->Set("analysis.linearSweep.controlFlowGraph", false, data);
103 settings->Set("analysis.signatureMatcher.autorun", true, data);
104 }
105 else if (linearSweepMode == "full")
106 {
107 settings->Set("analysis.linearSweep.autorun", true, data);
108 settings->Set("analysis.linearSweep.controlFlowGraph", true, data);
109 settings->Set("analysis.signatureMatcher.autorun", true, data);
110 }
111 }
112 }
113
114 m_context->openFileContext(f);
115 }
116
117 if (failedToOpen.size() > 0)
118 {
119 QString message = "Unable to open:\n";
120 for (auto& name : failedToOpen)
121 message += name + "\n";
122 QMessageBox::critical(this, "Error", message);
123 }

Callers

nothing calls this directly

Calls 5

push_backMethod · 0.80
insertMethod · 0.45
SetMethod · 0.45
GetTypeNameMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected