make items larger

This commit is contained in:
Akash Mozumdar 2019-09-12 13:19:02 -04:00
parent 90bed9c2db
commit ab916126b9
2 changed files with 29 additions and 29 deletions

View File

@ -524,10 +524,7 @@ void MainWindow::FindHooks()
auto hooks = std::make_shared<QStringList>();
try
{
Host::FindHooks(processId, sp, [hooks, filter](HookParam hp, const std::wstring& text)
{
if (std::regex_search(text, filter)) hooks->push_back(S(Util::GenerateCode(hp) + L" => " + text));
});
Host::FindHooks(processId, sp, [=](HookParam hp, std::wstring text) { if (std::regex_search(text, filter)) *hooks << S(Util::GenerateCode(hp) + L" => " + text); });
}
catch (std::out_of_range) { return; }
std::thread([this, hooks]
@ -537,26 +534,28 @@ void MainWindow::FindHooks()
if (GetTickCount64() > cleanupTime) return;
else lastSize = hooks->size();
QMetaObject::invokeMethod(this, [this, hooks]
QString saveFileName;
QMetaObject::invokeMethod(this, [&]
{
auto hookList = new QListView(this);
hookList->setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint);
hookList->setAttribute(Qt::WA_DeleteOnClose);
hookList->resize({ 750, 300 });
hookList->setWindowTitle(SEARCH_FOR_HOOKS);
hookList->setUniformItemSizes(true);
hookList->setUniformItemSizes(true); // they aren't actually uniform, but this improves performance
hooks->push_back(QString(2000, '-')); // dumb hack: with uniform item sizes, the last item is assumed to be the largest
hookList->setModel(new QStringListModel(*hooks, hookList));
connect(hookList, &QListView::clicked, [this, hookList](QModelIndex i) { AddHook(i.data().toString().split(" => ")[0]); });
connect(hookList, &QListView::clicked, [this](QModelIndex i) { AddHook(i.data().toString().split(" => ")[0]); });
hookList->show();
QString saveFileName = QFileDialog::getSaveFileName(this, SAVE_SEARCH_RESULTS, "./results.txt", TEXT_FILES);
if (!saveFileName.isEmpty())
{
QTextFile saveFile(saveFileName, QIODevice::WriteOnly | QIODevice::Truncate);
for (const auto& hook : *hooks) saveFile.write(hook.toUtf8().append('\n')); // might OOM with .join('\n')
}
hooks->clear();
});
saveFileName = QFileDialog::getSaveFileName(this, SAVE_SEARCH_RESULTS, "./results.txt", TEXT_FILES);
}, Qt::BlockingQueuedConnection);
if (!saveFileName.isEmpty())
{
QTextFile saveFile(saveFileName, QIODevice::WriteOnly | QIODevice::Truncate);
for (auto hook = hooks->cbegin(); hook != hooks->cend(); ++hook) saveFile.write(hook->toUtf8().append('\n')); // QStringList::begin() makes a copy
}
hooks->clear();
}).detach();
}

View File

@ -19,18 +19,6 @@ namespace
constexpr int MAX_STRING_SIZE = 500, CACHE_SIZE = 0x40000, GOOD_PAGE = -1;
struct HookRecord
{
~HookRecord()
{
if (!address) return;
HookParam hp = {};
hp.offset = offset;
hp.type = USING_UNICODE | USING_STRING;
hp.address = address;
hp.padding = sp.padding;
hp.codepage = sp.codepage;
if (sp.hookPostProcessor) sp.hookPostProcessor(hp);
NotifyHookFound(hp, (wchar_t*)text);
}
uint64_t address = 0;
int offset = 0;
char text[MAX_STRING_SIZE] = {};
@ -247,10 +235,23 @@ void SearchForHooks(SearchParam spUser)
MH_ApplyQueued();
Sleep(1000);
for (auto addr : addresses) MH_RemoveHook((void*)addr);
ConsoleOutput(HOOK_SEARCH_FINISHED, sp.maxRecords - recordsAvailable);
for (int i = 0, j = 0; i < sp.maxRecords; ++i)
{
if (!records[i].address) continue;
if (++j % 100'000 == 0) ConsoleOutput("Textractor: %d results processed", j);
HookParam hp = {};
hp.offset = records[i].offset;
hp.type = USING_UNICODE | USING_STRING;
hp.address = records[i].address;
hp.padding = sp.padding;
hp.codepage = sp.codepage;
if (sp.hookPostProcessor) sp.hookPostProcessor(hp);
NotifyHookFound(hp, (wchar_t*)records[i].text);
}
records.reset();
VirtualFree(trampolines, 0, MEM_RELEASE);
for (int i = 0; i < CACHE_SIZE; ++i) signatureCache[i] = sumCache[i] = 0;
ConsoleOutput(HOOK_SEARCH_FINISHED, sp.maxRecords - recordsAvailable);
for (int i = 0; i < CACHE_SIZE; ++i) signatureCache[i] = sumCache[i] = pageCache[i] = 0;
}).detach();
}