From a8c239498c4269dd1e0835c1aea115b0812a9001 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 10 Aug 2019 04:18:30 -0400 Subject: [PATCH] hide system processes --- GUI/mainwindow.cpp | 14 +++++++++----- GUI/mainwindow.h | 1 + text.cpp | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index dc32f1b..d5d6edb 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -44,6 +44,7 @@ extern const char* USE_JP_LOCALE; extern const char* FILTER_REPETITION; extern const char* AUTO_ATTACH; extern const char* ATTACH_SAVED_ONLY; +extern const char* SHOW_SYSTEM_PROCESSES; extern const char* DEFAULT_CODEPAGE; extern const char* FLUSH_DELAY; extern const char* MAX_BUFFER_SIZE; @@ -87,6 +88,7 @@ MainWindow::MainWindow(QWidget *parent) : TextThread::filterRepetition = settings.value(FILTER_REPETITION, TextThread::filterRepetition).toBool(); autoAttach = settings.value(AUTO_ATTACH, autoAttach).toBool(); autoAttachSavedOnly = settings.value(ATTACH_SAVED_ONLY, autoAttachSavedOnly).toBool(); + showSystemProcesses = settings.value(SHOW_SYSTEM_PROCESSES, showSystemProcesses).toBool(); TextThread::flushDelay = settings.value(FLUSH_DELAY, TextThread::flushDelay).toInt(); TextThread::maxBufferSize = settings.value(MAX_BUFFER_SIZE, TextThread::maxBufferSize).toInt(); Host::defaultCodepage = settings.value(DEFAULT_CODEPAGE, Host::defaultCodepage).toInt(); @@ -279,7 +281,8 @@ void MainWindow::AttachProcess() { QMultiHash allProcesses; for (auto [processId, processName] : Util::GetAllProcesses()) - if (processName) allProcesses.insert(QFileInfo(S(processName.value())).fileName(), processId); + if (processName && (showSystemProcesses || processName->find(L":\\Windows\\") == std::wstring::npos)) + allProcesses.insert(QFileInfo(S(processName.value())).fileName(), processId); QStringList processList(allProcesses.uniqueKeys()); processList.sort(Qt::CaseInsensitive); @@ -495,16 +498,16 @@ void MainWindow::FindHooks() hookList->resize({ 750, 300 }); hookList->setWindowTitle(SEARCH_FOR_HOOKS); for (auto [hp, text] : *hooks) - new QListWidgetItem(S(Util::GenerateCode(hp, processId) + L" -> " + text), hookList); - connect(hookList, &QListWidget::itemClicked, [this](QListWidgetItem* item) { AddHook(item->text().split(" -> ")[0]); }); + new QListWidgetItem(S(Util::GenerateCode(hp, processId) + L" => " + text), hookList); + connect(hookList, &QListWidget::itemClicked, [this](QListWidgetItem* item) { AddHook(item->text().split(" => ")[0]); }); hookList->show(); - QString saveFileName = QFileDialog::getSaveFileName(this, SAVE_SEARCH_RESULTS, "./Hooks.txt", TEXT_FILES, nullptr); + QString saveFileName = QFileDialog::getSaveFileName(this, SAVE_SEARCH_RESULTS, "./results.txt", TEXT_FILES, nullptr); if (!saveFileName.isEmpty()) { QTextFile saveFile(saveFileName, QIODevice::WriteOnly | QIODevice::Truncate); for (auto [hp, text] : *hooks) - saveFile.write(S(Util::GenerateCode(hp, processId) + L" -> " + text + L"\n").toUtf8()); + saveFile.write(S(Util::GenerateCode(hp, processId) + L" => " + text + L"\n").toUtf8()); } hooks->clear(); }); @@ -521,6 +524,7 @@ void MainWindow::Settings() { TextThread::filterRepetition, FILTER_REPETITION }, { autoAttach, AUTO_ATTACH }, { autoAttachSavedOnly, ATTACH_SAVED_ONLY }, + { showSystemProcesses, SHOW_SYSTEM_PROCESSES }, }) { auto checkBox = new QCheckBox(&dialog); diff --git a/GUI/mainwindow.h b/GUI/mainwindow.h index b9950b3..89de329 100644 --- a/GUI/mainwindow.h +++ b/GUI/mainwindow.h @@ -51,6 +51,7 @@ private: ExtenWindow* extenWindow; std::unordered_set alreadyAttached; bool autoAttach = false, autoAttachSavedOnly = true; + bool showSystemProcesses = false; uint64_t savedThreadCtx = 0, savedThreadCtx2 = 0; wchar_t savedThreadCode[1000] = {}; TextThread* current = nullptr; diff --git a/text.cpp b/text.cpp index e06616f..3ba37fc 100644 --- a/text.cpp +++ b/text.cpp @@ -70,6 +70,7 @@ const char* DOUBLE_CLICK_TO_REMOVE_HOOK = u8"Double click a hook to remove it"; const char* FILTER_REPETITION = u8"Filter repetition"; const char* AUTO_ATTACH = u8"Auto attach"; const char* ATTACH_SAVED_ONLY = u8"Auto attach (saved only)"; +const char* SHOW_SYSTEM_PROCESSES = u8"Show system processes"; const char* DEFAULT_CODEPAGE = u8"Default codepage"; const char* FLUSH_DELAY = u8"Flush delay"; const char* MAX_BUFFER_SIZE = u8"Max buffer size";