7
7
8
8
#include " action.h"
9
9
#include " fetcher.h"
10
+ #include " misc.h"
10
11
11
12
using namespace BinaryNinja ;
12
13
@@ -35,8 +36,6 @@ WarpFetchDialog::WarpFetchDialog(BinaryViewRef bv,
35
36
for (const auto &c: m_containers)
36
37
m_containerCombo->addItem (QString::fromStdString (c->GetName ()));
37
38
38
- // TODO: Need to add tooltip to explain that a source must have atleast one of these tags to be considered.
39
-
40
39
// Tags editor
41
40
m_tagsList = new QListWidget (this );
42
41
m_addTagBtn = new QPushButton (this );
@@ -67,13 +66,13 @@ WarpFetchDialog::WarpFetchDialog(BinaryViewRef bv,
67
66
m_tagsList->setToolTip (" A source must have atleast ONE of these tags to be considered" );
68
67
69
68
// Defaults from processor tags
70
- for (const auto &t: m_fetchProcessor-> GetTags ( ))
69
+ for (const auto &t: GetAllowedTagsFromView (m_bv ))
71
70
AddListItem (m_tagsList, QString::fromStdString (t));
72
71
73
72
// Batch size and matcher checkbox
74
73
m_batchSize = new QSpinBox (this );
75
74
m_batchSize->setRange (10 , 1000 );
76
- m_batchSize->setValue (100 );
75
+ m_batchSize->setValue (GetBatchSizeFromView (m_bv) );
77
76
m_batchSize->setToolTip (" Number of functions to fetch in each batch" );
78
77
79
78
m_rerunMatcher = new QCheckBox (" Re-run matcher after fetch" , this );
@@ -84,17 +83,14 @@ WarpFetchDialog::WarpFetchDialog(BinaryViewRef bv,
84
83
m_clearProcessed->setChecked (false );
85
84
86
85
form->addRow (new QLabel (" Container: " ), m_containerCombo);
87
- // TODO: Need to plumb this through to the fetcher, and also likely have a blacklisted or whitelist mode for this dialog.
88
- // TODO: Alos wan to prefill the list of sources from the view/global settings.
89
- // form->addRow(new QLabel("Allowed Sources: "), srcWrapper);
90
86
form->addRow (new QLabel (" Allowed Tags: " ), tagWrapper);
91
87
form->addRow (new QLabel (" Batch Size: " ), m_batchSize);
92
88
form->addRow (m_rerunMatcher);
93
89
form->addRow (m_clearProcessed);
94
90
95
91
auto buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this );
96
92
connect (buttons, &QDialogButtonBox::accepted, this , &WarpFetchDialog::onAccept);
97
- connect (buttons, &QDialogButtonBox::rejected, this , &QDialog::reject );
93
+ connect (buttons, &QDialogButtonBox::rejected, this , &WarpFetchDialog::onReject );
98
94
99
95
auto root = new QVBoxLayout (this );
100
96
root->addLayout (form);
@@ -149,12 +145,12 @@ void WarpFetchDialog::onAccept()
149
145
if (idx > 0 ) // 0 == All Containers
150
146
containerIndex = static_cast <size_t >(idx - 1 );
151
147
152
- auto tags = collectTags ();
153
148
const auto batch = static_cast <size_t >(m_batchSize->value ());
154
149
const bool rerun = m_rerunMatcher->isChecked ();
155
150
156
- // Persist tags to the shared processor for consistency across navigation
157
- m_fetchProcessor->SetTags (tags);
151
+ const auto tags = collectTags ();
152
+ // Persist tags to the view settings.
153
+ SetTagsToView (m_bv, tags);
158
154
159
155
if (m_clearProcessed->isChecked ())
160
156
m_fetchProcessor->ClearProcessed ();
@@ -165,8 +161,16 @@ void WarpFetchDialog::onAccept()
165
161
accept ();
166
162
}
167
163
164
+ void WarpFetchDialog::onReject ()
165
+ {
166
+ const auto tags = collectTags ();
167
+ // Persist tags to the view settings.
168
+ SetTagsToView (m_bv, tags);
169
+ reject ();
170
+ }
171
+
168
172
void WarpFetchDialog::runBatchedFetch (const std::optional<size_t > &containerIndex,
169
- const std::vector<Warp::SourceTag> &tags ,
173
+ const std::vector<Warp::SourceTag> &allowedTags ,
170
174
size_t batchSize,
171
175
bool rerunMatcher)
172
176
{
@@ -186,7 +190,7 @@ void WarpFetchDialog::runBatchedFetch(const std::optional<size_t> &containerInde
186
190
auto bv = m_bv;
187
191
188
192
// TODO: Too many captures in this thing lol.
189
- WorkerInteractiveEnqueue ([fetcher, bv, funcs = std::move (funcs), batchSize, rerunMatcher, task]() mutable {
193
+ WorkerInteractiveEnqueue ([fetcher, bv, funcs = std::move (funcs), batchSize, rerunMatcher, task, allowedTags ]() mutable {
190
194
size_t processed = 0 ;
191
195
size_t batchIndex = 0 ;
192
196
@@ -198,7 +202,7 @@ void WarpFetchDialog::runBatchedFetch(const std::optional<size_t> &containerInde
198
202
for (size_t i = 0 ; i < thisBatchCount; ++i)
199
203
fetcher->AddPendingFunction (funcs[processed + i]);
200
204
201
- fetcher->FetchPendingFunctions ();
205
+ fetcher->FetchPendingFunctions (allowedTags );
202
206
203
207
++batchIndex;
204
208
processed += thisBatchCount;
@@ -219,8 +223,6 @@ void RegisterWarpFetchFunctionsCommand()
219
223
{
220
224
// Register a UI action and bind it globally. Add it to the Tools menu.
221
225
const QString actionName = " WARP\\ Fetch" ;
222
-
223
- // TODO: Because we register this in every widget this will happen, this is bad behavior!
224
226
if (!UIAction::isActionRegistered (actionName))
225
227
UIAction::registerAction (actionName);
226
228
0 commit comments