From 72221106ace5b254b85cc1a0003c1d8673ecd874 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 25 Aug 2018 17:08:45 -0400 Subject: [PATCH] change name convention --- GUI/extensions.cpp | 11 +++++------ GUI/mainwindow.cpp | 19 ++++++++----------- extensions/CMakeLists.txt | 10 +++++----- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/GUI/extensions.cpp b/GUI/extensions.cpp index 95a206a..820f0c3 100644 --- a/GUI/extensions.cpp +++ b/GUI/extensions.cpp @@ -11,15 +11,14 @@ std::map LoadExtensions() std::map extensionNames; QStringList files = QDir().entryList(); for (auto file : files) - if (file.endsWith("_nexthooker_extension.dll")) + if (file.split("_").size() > 1 && file.split("_")[0].toInt() && file.endsWith(".dll")) if (GetProcAddress(GetModuleHandleW(file.toStdWString().c_str()), "OnNewSentence") || GetProcAddress(LoadLibraryW(file.toStdWString().c_str()), "OnNewSentence")) { - QString extensionNumber = file.split("_")[0]; - newExtensions[extensionNumber.toInt()] = (ExtensionFunction)GetProcAddress(GetModuleHandleW(file.toStdWString().c_str()), "OnNewSentence"); - file.chop(sizeof("_nexthooker_extension.dll") - 1); - file.remove(0, extensionNumber.length() + 1); - extensionNames[extensionNumber.toInt()] = file; + int extensionNumber = file.split("_")[0].toInt(); + newExtensions[extensionNumber] = (ExtensionFunction)GetProcAddress(GetModuleHandleW(file.toStdWString().c_str()), "OnNewSentence"); + file.chop(sizeof("dll")); + extensionNames[extensionNumber] = file.split("_")[1]; } extenMutex.lock(); extensions = newExtensions; diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index ebf1837..c35def0 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -58,12 +58,12 @@ void MainWindow::AddProcess(unsigned int processId) QString processName = GetFullModuleName(processId); QString allData = file.readAll(); QStringList allProcesses = allData.split("\r", QString::SkipEmptyParts); - for (int i = allProcesses.length() - 1; i >= 0; --i) - if (allProcesses.at(i).contains(processName)) + for (int i = allProcesses.size() - 1; i >= 0; --i) + if (allProcesses[i].contains(processName)) { - QStringList hooks = allProcesses.at(i).split(" , "); - for (int j = 1; j < hooks.length(); ++j) - Host::InsertHook(processId, ParseCode(hooks.at(j)).value_or(HookParam())); + QStringList hooks = allProcesses[i].split(" , "); + for (int j = 1; j < hooks.size(); ++j) + Host::InsertHook(processId, ParseCode(hooks[j]).value_or(HookParam())); return; } } @@ -244,12 +244,9 @@ void MainWindow::on_ttCombo_activated(int index) void MainWindow::on_addExtenButton_clicked() { QString extenFileName = QFileDialog::getOpenFileName(this, "Select Extension dll", "C:\\", "Extensions (*.dll)"); - if (!extenFileName.length()) return; + if (!extenFileName.size()) return; QString extenName = extenFileName.split("/")[extenFileName.split("/").count() - 1]; - extenName.chop(4); - QString copyTo = QString::number(extenCombo->itemText(extenCombo->count() - 1).split(":")[0].toInt() + 1) + "_" + - extenName + - "_nexthooker_extension.dll"; + QString copyTo = QString::number(extenCombo->itemText(extenCombo->count() - 1).split(":")[0].toInt() + 1) + "_" + extenName; QFile::copy(extenFileName, copyTo); ReloadExtensions(); } @@ -257,7 +254,7 @@ void MainWindow::on_addExtenButton_clicked() void MainWindow::on_rmvExtenButton_clicked() { if (extenCombo->currentText().size() == 0) return; - QString extenFileName = extenCombo->currentText().split(":")[0] + "_" + extenCombo->currentText().split(": ")[1] + "_nexthooker_extension.dll"; + QString extenFileName = extenCombo->currentText().split(":")[0] + "_" + extenCombo->currentText().split(": ")[1] + ".dll"; FreeLibrary(GetModuleHandleW(extenFileName.toStdWString().c_str())); QFile::remove(extenFileName); ReloadExtensions(); diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 22389ee..987c4c5 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_policy(SET CMP0037 OLD) -add_library(1_Remove\ Repetition_nexthooker_extension SHARED removerepeat.cpp) -add_library(2_Copy\ to\ Clipboard_nexthooker_extension SHARED copyclipboard.cpp) -add_library(3_Google\ Translate_nexthooker_extension SHARED googletranslate.cpp) -add_library(4_Extra\ Newlines_nexthooker_extension SHARED extranewlines.cpp) +add_library(1_Remove\ Repetition SHARED removerepeat.cpp) +add_library(2_Copy\ to\ Clipboard SHARED copyclipboard.cpp) +add_library(3_Google\ Translate SHARED googletranslate.cpp) +add_library(4_Extra\ Newlines SHARED extranewlines.cpp) -target_link_libraries(3_Google\ Translate_nexthooker_extension winhttp.lib) \ No newline at end of file +target_link_libraries(3_Google\ Translate winhttp.lib) \ No newline at end of file