2018-12-17 20:48:14 -05:00
|
|
|
#include "extension.h"
|
2018-12-18 16:32:28 -05:00
|
|
|
#include "text.h"
|
2018-12-17 20:48:14 -05:00
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QLayout>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
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(); }
|
2018-12-18 16:32:28 -05:00
|
|
|
catch (...) { return output->setText(INVALID_REGEX); }
|
|
|
|
output->setText(CURRENT_FILTER + newRegex);
|
2018-12-17 20:48:14 -05:00
|
|
|
});
|
|
|
|
QMainWindow::resize(350, 60);
|
|
|
|
QMainWindow::setCentralWidget(centralWidget);
|
2018-12-18 16:32:28 -05:00
|
|
|
QMainWindow::setWindowTitle(REGEX_FILTER);
|
2018-12-17 20:48:14 -05:00
|
|
|
QMainWindow::show();
|
|
|
|
}
|
|
|
|
}*window = nullptr;
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
switch (ul_reason_for_call)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
{
|
2018-12-18 12:15:18 -05:00
|
|
|
QTimer::singleShot(0, []
|
|
|
|
{
|
|
|
|
std::lock_guard l(m);
|
|
|
|
(window = new std::remove_pointer_t<decltype(window)>)->Initialize();
|
|
|
|
});
|
2018-12-17 20:48:14 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
{
|
|
|
|
if (lpReserved == NULL) // https://blogs.msdn.microsoft.com/oldnewthing/20120105-00/?p=8683
|
|
|
|
{
|
2018-12-18 12:15:18 -05:00
|
|
|
std::lock_guard l(m);
|
2018-12-17 20:48:14 -05:00
|
|
|
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;
|
|
|
|
}
|