diff --git a/deploy.ps1 b/deploy.ps1 index 15b0605..f7b662a 100644 --- a/deploy.ps1 +++ b/deploy.ps1 @@ -13,7 +13,6 @@ Compress-Archive -Force -DestinationPath Textractor -Path @( "Google Translate.dll", "Regex Filter.dll", "Remove Repetition.dll", - "Thread Linker.dll", "Extensions.txt" ) @@ -32,6 +31,5 @@ Compress-Archive -Force -DestinationPath Textractor -Path @( "Google Translate.dll", "Regex Filter.dll", "Remove Repetition.dll", - "Thread Linker.dll", "Extensions.txt" ) \ No newline at end of file diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 797cd8e..440cd72 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -4,15 +4,13 @@ find_qt5(Core Widgets) cmake_policy(SET CMP0037 OLD) -add_library(Bing\ Translate SHARED bingtranslate/bingtranslate.cpp extensionimpl.cpp) -add_library(Copy\ to\ Clipboard SHARED copyclipboard/copyclipboard.cpp extensionimpl.cpp) -add_library(Extra\ Newlines SHARED extranewlines/extranewlines.cpp extensionimpl.cpp) -add_library(Google\ Translate SHARED googletranslate/googletranslate.cpp extensionimpl.cpp) -add_library(Regex\ Filter SHARED regexfilter/regexfilter.cpp regexfilter/window.cpp extensionimpl.cpp) -add_library(Remove\ Repetition SHARED removerepeat/removerepeat.cpp extensionimpl.cpp) -add_library(Thread\ Linker SHARED threadlinker/threadlinker.cpp threadlinker/window.cpp extensionimpl.cpp) +add_library(Bing\ Translate SHARED bingtranslate.cpp extensionimpl.cpp) +add_library(Copy\ to\ Clipboard SHARED copyclipboard.cpp extensionimpl.cpp) +add_library(Extra\ Newlines SHARED extranewlines.cpp extensionimpl.cpp) +add_library(Google\ Translate SHARED googletranslate.cpp extensionimpl.cpp) +add_library(Regex\ Filter SHARED regexfilter.cpp extensionimpl.cpp) +add_library(Remove\ Repetition SHARED removerepeat.cpp extensionimpl.cpp) target_link_libraries(Bing\ Translate winhttp Qt5::Widgets) target_link_libraries(Google\ Translate winhttp Qt5::Widgets) target_link_libraries(Regex\ Filter Qt5::Widgets) -target_link_libraries(Thread\ Linker Qt5::Widgets) diff --git a/extensions/bingtranslate/bingtranslate.cpp b/extensions/bingtranslate.cpp similarity index 99% rename from extensions/bingtranslate/bingtranslate.cpp rename to extensions/bingtranslate.cpp index 7b2bf1b..8c48ce7 100644 --- a/extensions/bingtranslate/bingtranslate.cpp +++ b/extensions/bingtranslate.cpp @@ -1,4 +1,4 @@ -#include "../extension.h" +#include "extension.h" #include #include #include diff --git a/extensions/copyclipboard/copyclipboard.cpp b/extensions/copyclipboard.cpp similarity index 95% rename from extensions/copyclipboard/copyclipboard.cpp rename to extensions/copyclipboard.cpp index 8bd84ed..4c9d39a 100644 --- a/extensions/copyclipboard/copyclipboard.cpp +++ b/extensions/copyclipboard.cpp @@ -1,4 +1,4 @@ -#include "../extension.h" +#include "extension.h" bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) { diff --git a/extensions/extranewlines/extranewlines.cpp b/extensions/extranewlines.cpp similarity index 86% rename from extensions/extranewlines/extranewlines.cpp rename to extensions/extranewlines.cpp index 8e0555d..d0fb344 100644 --- a/extensions/extranewlines/extranewlines.cpp +++ b/extensions/extranewlines.cpp @@ -1,4 +1,4 @@ -#include "../extension.h" +#include "extension.h" bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) { diff --git a/extensions/googletranslate/googletranslate.cpp b/extensions/googletranslate.cpp similarity index 99% rename from extensions/googletranslate/googletranslate.cpp rename to extensions/googletranslate.cpp index 93dc96b..c588b3a 100644 --- a/extensions/googletranslate/googletranslate.cpp +++ b/extensions/googletranslate.cpp @@ -1,4 +1,4 @@ -#include "../extension.h" +#include "extension.h" #include #include #include diff --git a/extensions/regexfilter.cpp b/extensions/regexfilter.cpp new file mode 100644 index 0000000..1c7b299 --- /dev/null +++ b/extensions/regexfilter.cpp @@ -0,0 +1,64 @@ +#include "extension.h" +#include +#include +#include +#include +#include + +std::wregex regex; +std::mutex m; + +struct : QMainWindow { + void Initialize() + { + auto centralWidget = new QWidget(this); + auto layout = new QVBoxLayout(centralWidget); + auto input = new QLineEdit(centralWidget); + auto output = new QLabel(centralWidget); + output->setAlignment(Qt::AlignCenter); + layout->addWidget(input); + layout->addWidget(output); + connect(input, &QLineEdit::textEdited, [=](QString newRegex) + { + std::lock_guard l(m); + try { regex = newRegex.toStdWString(); } + catch (...) { return output->setText("Invalid regex"); } + output->setText("Currently filtering: " + newRegex); + }); + QMainWindow::resize(350, 60); + QMainWindow::setCentralWidget(centralWidget); + QMainWindow::setWindowTitle("Regex Filter"); + QMainWindow::show(); + } +}*window = nullptr; + +BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + std::lock_guard l(m); + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + { + QTimer::singleShot(0, [] { (window = new std::remove_pointer_t)->Initialize(); }); + } + break; + case DLL_PROCESS_DETACH: + { + if (lpReserved == NULL) // https://blogs.msdn.microsoft.com/oldnewthing/20120105-00/?p=8683 + { + delete window; + window = nullptr; + } + } + break; + } + return TRUE; +} + +bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) +{ + std::lock_guard l(m); + if (window == nullptr || sentenceInfo["hook address"] == -1) return false; + sentence = std::regex_replace(sentence, regex, L""); + return true; +} diff --git a/extensions/regexfilter/regexfilter.cpp b/extensions/regexfilter/regexfilter.cpp deleted file mode 100644 index 658bead..0000000 --- a/extensions/regexfilter/regexfilter.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "../extension.h" -#include "window.h" -#include - -Window* w = nullptr; - -BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - { - QTimer::singleShot(0, [] { (w = new Window)->show(); }); - } - break; - case DLL_PROCESS_DETACH: - { - if (lpReserved == NULL) delete w; // https://blogs.msdn.microsoft.com/oldnewthing/20120105-00/?p=8683 - } - break; - } - return TRUE; -} - -bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) -{ - if (w == nullptr || sentenceInfo["hook address"] == -1) return false; - std::lock_guard l(w->m); - sentence = std::regex_replace(sentence, w->regex, L""); - return true; -} \ No newline at end of file diff --git a/extensions/regexfilter/window.cpp b/extensions/regexfilter/window.cpp deleted file mode 100644 index 8a7b7dc..0000000 --- a/extensions/regexfilter/window.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "window.h" -#include "ui_window.h" -#include - -Window::Window(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::Window) -{ - ui->setupUi(this); -} - -Window::~Window() -{ - delete ui; -} - -void Window::on_regexInput_textEdited(const QString& newRegex) -{ - QLabel* info = findChild("info"); - std::lock_guard l(m); - try { regex = newRegex.toStdWString(); } - catch (...) { return findChild("info")->setText("Invalid regex"); } - findChild("info")->setText("Currently filtering: " + newRegex); -} diff --git a/extensions/regexfilter/window.h b/extensions/regexfilter/window.h deleted file mode 100644 index 704c624..0000000 --- a/extensions/regexfilter/window.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef WINDOW_H -#define WINDOW_H - -#include "common.h" -#include -#include - -namespace Ui -{ - class Window; -} - -class Window : public QMainWindow -{ - Q_OBJECT - -public: - explicit Window(QWidget *parent = nullptr); - ~Window(); - - Ui::Window* ui; - std::mutex m; - std::wregex regex; - -private slots: - void on_regexInput_textEdited(const QString& regex); -}; - -#endif // WINDOW_H diff --git a/extensions/regexfilter/window.ui b/extensions/regexfilter/window.ui deleted file mode 100644 index 1b1f9f1..0000000 --- a/extensions/regexfilter/window.ui +++ /dev/null @@ -1,36 +0,0 @@ - - - Window - - - - 0 - 0 - 350 - 60 - - - - Regex Filter - - - - - - - - - - - - - Qt::AlignCenter - - - - - - - - - diff --git a/extensions/removerepeat/removerepeat.cpp b/extensions/removerepeat.cpp similarity index 97% rename from extensions/removerepeat/removerepeat.cpp rename to extensions/removerepeat.cpp index 9065efb..5544887 100644 --- a/extensions/removerepeat/removerepeat.cpp +++ b/extensions/removerepeat.cpp @@ -1,4 +1,4 @@ -#include "../extension.h" +#include "extension.h" void RemoveRepeatedChars(std::wstring& sentence) { diff --git a/extensions/threadlinker/threadlinker.cpp b/extensions/threadlinker/threadlinker.cpp deleted file mode 100644 index 95d9256..0000000 --- a/extensions/threadlinker/threadlinker.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "../extension.h" -#include "window.h" -#include - -Window* w = nullptr; - -BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - { - QTimer::singleShot(0, [] { (w = new Window)->show(); }); - } - break; - case DLL_PROCESS_DETACH: - { - if (lpReserved == NULL) delete w; // https://blogs.msdn.microsoft.com/oldnewthing/20120105-00/?p=8683 - } - break; - } - return TRUE; -} - -bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) -{ - if (w == nullptr) return false; - std::lock_guard l(w->m); - - static std::unordered_map queuedWritesByHandle; - int64_t textHandle = sentenceInfo["text handle"]; - for (auto linkedHandle : w->linkedTextHandles[textHandle]) queuedWritesByHandle[linkedHandle] += L"\r\n" + sentence; - if (queuedWritesByHandle[textHandle].empty()) return false; - sentence += queuedWritesByHandle[textHandle]; - queuedWritesByHandle[textHandle].clear(); - return true; -} diff --git a/extensions/threadlinker/window.cpp b/extensions/threadlinker/window.cpp deleted file mode 100644 index 3d7688c..0000000 --- a/extensions/threadlinker/window.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "window.h" -#include "ui_window.h" -#include - -Window::Window(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::Window) -{ - ui->setupUi(this); - threadLinkList = findChild("threadLinkList"); -} - -Window::~Window() -{ - delete ui; -} - -void Window::on_linkButton_clicked() -{ - bool ok1, ok2, ok3, ok4; - int from = QInputDialog::getText(this, "Link From", "Thread number to link from?", QLineEdit::Normal, "", &ok1, Qt::WindowCloseButtonHint).toInt(&ok2, 16); - int to = QInputDialog::getText(this, "Link To", "Thread number to link to?", QLineEdit::Normal, "", &ok3, Qt::WindowCloseButtonHint).toInt(&ok4, 16); - if (ok1 && ok2 && ok3 && ok4) - { - std::lock_guard l(m); - linkedTextHandles[from].insert(to); - threadLinkList->addItem(QString::number(from, 16) + "->" + QString::number(to, 16)); - } -} - -void Window::on_unlinkButton_clicked() -{ - std::lock_guard l(m); - QStringList link = threadLinkList->currentItem()->text().split("->"); - threadLinkList->takeItem(threadLinkList->currentRow()); - linkedTextHandles[link[0].toInt(nullptr, 16)].erase(link[1].toInt(nullptr, 16)); -} diff --git a/extensions/threadlinker/window.h b/extensions/threadlinker/window.h deleted file mode 100644 index 9a0df0d..0000000 --- a/extensions/threadlinker/window.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef WINDOW_H -#define WINDOW_H - -#include "common.h" -#include -#include - -namespace Ui -{ - class Window; -} - -class Window : public QMainWindow -{ - Q_OBJECT - -public: - explicit Window(QWidget *parent = nullptr); - ~Window(); - - Ui::Window* ui; - std::mutex m; - std::unordered_map> linkedTextHandles; - -private slots: - void on_linkButton_clicked(); - void on_unlinkButton_clicked(); - -private: - QListWidget* threadLinkList; -}; - -#endif // WINDOW_H diff --git a/extensions/threadlinker/window.ui b/extensions/threadlinker/window.ui deleted file mode 100644 index 606b000..0000000 --- a/extensions/threadlinker/window.ui +++ /dev/null @@ -1,79 +0,0 @@ - - - Window - - - - 0 - 0 - 400 - 300 - - - - Thread Linker - - - - QObject - { - font: 10pt "MS Shell Dlg 2"; - } - #textOutput - { - font: 13pt "MS Shell Dlg 2"; - } - QPushButton, QComboBox - { - padding-top: 3px; - padding-bottom: 3px; - padding-right: 5px; - padding-left: 5px; - text-align: left; - } - - - - - - - - - - - - - - Qt::Vertical - - - - - - - Link - - - - - - - Unlink - - - - - - - Qt::Vertical - - - - - - - - - - -