forked from Public-Mirror/Textractor
eh who needs moc anyway
This commit is contained in:
parent
29822c89c8
commit
464c001773
@ -1,7 +1,7 @@
|
|||||||
#include "extenwindow.h"
|
#include "extenwindow.h"
|
||||||
#include "ui_extenwindow.h"
|
#include "ui_extenwindow.h"
|
||||||
#include "text.h"
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
|
#include "text.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
@ -83,6 +83,9 @@ ExtenWindow::ExtenWindow(QWidget* parent) :
|
|||||||
|
|
||||||
ui->extenList->installEventFilter(this);
|
ui->extenList->installEventFilter(this);
|
||||||
|
|
||||||
|
connect(ui->addButton, &QPushButton::clicked, [&] { Add(QFileDialog::getOpenFileName(this, SELECT_EXTENSION, "C:\\", EXTENSION_FILES)); });
|
||||||
|
connect(ui->rmvButton, &QPushButton::clicked, [&] { if (auto extenName = ui->extenList->currentItem()) Unload(extenName->text()); Sync(); });
|
||||||
|
|
||||||
for (auto extenName : QString(QAutoFile(EXTEN_SAVE_FILE, QIODevice::ReadOnly)->readAll()).split(">")) Load(extenName);
|
for (auto extenName : QString(QAutoFile(EXTEN_SAVE_FILE, QIODevice::ReadOnly)->readAll()).split(">")) Load(extenName);
|
||||||
Sync();
|
Sync();
|
||||||
}
|
}
|
||||||
@ -134,14 +137,3 @@ void ExtenWindow::dropEvent(QDropEvent* event)
|
|||||||
{
|
{
|
||||||
for (auto file : event->mimeData()->urls()) Add(file.toLocalFile());
|
for (auto file : event->mimeData()->urls()) Add(file.toLocalFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtenWindow::on_addButton_clicked()
|
|
||||||
{
|
|
||||||
Add(QFileDialog::getOpenFileName(this, SELECT_EXTENSION, "C:\\", EXTENSION_FILES));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExtenWindow::on_rmvButton_clicked()
|
|
||||||
{
|
|
||||||
if (auto extenName = ui->extenList->currentItem()) Unload(extenName->text());
|
|
||||||
Sync();
|
|
||||||
}
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
#include <QListWidget>
|
|
||||||
#include <QDragEnterEvent>
|
#include <QDragEnterEvent>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
|
|
||||||
@ -14,16 +13,10 @@ bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std
|
|||||||
|
|
||||||
class ExtenWindow : public QMainWindow
|
class ExtenWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ExtenWindow(QWidget* parent = nullptr);
|
explicit ExtenWindow(QWidget* parent = nullptr);
|
||||||
~ExtenWindow();
|
~ExtenWindow();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_addButton_clicked();
|
|
||||||
void on_rmvButton_clicked();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Add(QFileInfo extenFile);
|
void Add(QFileInfo extenFile);
|
||||||
void Sync();
|
void Sync();
|
||||||
|
@ -19,11 +19,6 @@ TextThread::~TextThread()
|
|||||||
OnDestroy(this);
|
OnDestroy(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring TextThread::GetStorage()
|
|
||||||
{
|
|
||||||
return storage->c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextThread::AddSentence(std::wstring sentence)
|
void TextThread::AddSentence(std::wstring sentence)
|
||||||
{
|
{
|
||||||
if (Output(this, sentence)) storage->append(sentence);
|
if (Output(this, sentence)) storage->append(sentence);
|
||||||
|
@ -19,10 +19,10 @@ public:
|
|||||||
TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring> name = {});
|
TextThread(ThreadParam tp, HookParam hp, std::optional<std::wstring> name = {});
|
||||||
~TextThread();
|
~TextThread();
|
||||||
|
|
||||||
std::wstring GetStorage();
|
|
||||||
void AddSentence(std::wstring sentence);
|
void AddSentence(std::wstring sentence);
|
||||||
void Push(const BYTE* data, int len);
|
void Push(const BYTE* data, int len);
|
||||||
|
|
||||||
|
const ThreadSafePtr<std::wstring> storage;
|
||||||
const int64_t handle;
|
const int64_t handle;
|
||||||
const std::wstring name;
|
const std::wstring name;
|
||||||
const ThreadParam tp;
|
const ThreadParam tp;
|
||||||
@ -32,7 +32,6 @@ private:
|
|||||||
void Flush();
|
void Flush();
|
||||||
|
|
||||||
struct TimerDeleter { void operator()(void* h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } };
|
struct TimerDeleter { void operator()(void* h) { DeleteTimerQueueTimer(NULL, h, INVALID_HANDLE_VALUE); } };
|
||||||
ThreadSafePtr<std::wstring> storage;
|
|
||||||
std::wstring buffer;
|
std::wstring buffer;
|
||||||
std::unordered_set<wchar_t> repeatingChars;
|
std::unordered_set<wchar_t> repeatingChars;
|
||||||
std::mutex bufferMutex;
|
std::mutex bufferMutex;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
#include "defs.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "extenwindow.h"
|
#include "extenwindow.h"
|
||||||
#include "setdialog.h"
|
#include "setdialog.h"
|
||||||
@ -7,8 +8,6 @@
|
|||||||
#include "host/util.h"
|
#include "host/util.h"
|
||||||
#include <Psapi.h>
|
#include <Psapi.h>
|
||||||
#include <winhttp.h>
|
#include <winhttp.h>
|
||||||
#include <QFrame>
|
|
||||||
#include <QLayout>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
|
||||||
@ -19,12 +18,12 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
for (auto[text, slot] : Array<std::tuple<QString, void(MainWindow::*)()>>{
|
for (auto[text, slot] : Array<std::tuple<QString, void(MainWindow::*)()>>{
|
||||||
{ ATTACH, &MainWindow::on_attachButton_clicked },
|
{ ATTACH, &MainWindow::AttachProcess },
|
||||||
{ DETACH, &MainWindow::on_detachButton_clicked },
|
{ DETACH, &MainWindow::DetachProcess },
|
||||||
{ ADD_HOOK, &MainWindow::on_hookButton_clicked },
|
{ ADD_HOOK, &MainWindow::AddHook },
|
||||||
{ SAVE_HOOKS, &MainWindow::on_saveButton_clicked },
|
{ SAVE_HOOKS, &MainWindow::SaveHooks },
|
||||||
{ SETTINGS, &MainWindow::on_setButton_clicked },
|
{ SETTINGS, &MainWindow::Settings },
|
||||||
{ EXTENSIONS, &MainWindow::on_extenButton_clicked }
|
{ EXTENSIONS, &MainWindow::Extensions }
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
QPushButton* button = new QPushButton(ui->processFrame);
|
QPushButton* button = new QPushButton(ui->processFrame);
|
||||||
@ -34,10 +33,14 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
ui->processLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
ui->processLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
||||||
|
|
||||||
|
connect(ui->ttCombo, (void(QComboBox::*)(int))&QComboBox::activated, this, &MainWindow::ViewThread);
|
||||||
|
|
||||||
|
QSettings settings(CONFIG_FILE, QSettings::IniFormat);
|
||||||
if (settings.contains(WINDOW)) setGeometry(settings.value(WINDOW).toRect());
|
if (settings.contains(WINDOW)) setGeometry(settings.value(WINDOW).toRect());
|
||||||
if (settings.contains(FLUSH_DELAY)) TextThread::flushDelay = settings.value(FLUSH_DELAY).toInt();
|
if (settings.contains(FLUSH_DELAY)) TextThread::flushDelay = settings.value(FLUSH_DELAY).toInt();
|
||||||
if (settings.contains(MAX_BUFFER_SIZE)) TextThread::maxBufferSize = settings.value(MAX_BUFFER_SIZE).toInt();
|
if (settings.contains(MAX_BUFFER_SIZE)) TextThread::maxBufferSize = settings.value(MAX_BUFFER_SIZE).toInt();
|
||||||
if (settings.contains(DEFAULT_CODEPAGE)) TextThread::defaultCodepage = settings.value(DEFAULT_CODEPAGE).toInt();
|
if (settings.contains(DEFAULT_CODEPAGE)) TextThread::defaultCodepage = settings.value(DEFAULT_CODEPAGE).toInt();
|
||||||
|
settings.sync();
|
||||||
|
|
||||||
Host::Start(
|
Host::Start(
|
||||||
[&](DWORD processId) { ProcessConnected(processId); },
|
[&](DWORD processId) { ProcessConnected(processId); },
|
||||||
@ -68,6 +71,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
QSettings settings(CONFIG_FILE, QSettings::IniFormat);
|
||||||
settings.setValue(WINDOW, geometry());
|
settings.setValue(WINDOW, geometry());
|
||||||
settings.sync();
|
settings.sync();
|
||||||
delete ui;
|
delete ui;
|
||||||
@ -122,7 +126,7 @@ void MainWindow::ThreadRemoved(TextThread* thread)
|
|||||||
if (threadIndex == ui->ttCombo->currentIndex())
|
if (threadIndex == ui->ttCombo->currentIndex())
|
||||||
{
|
{
|
||||||
ui->ttCombo->setCurrentIndex(0);
|
ui->ttCombo->setCurrentIndex(0);
|
||||||
on_ttCombo_activated(0);
|
ViewThread(0);
|
||||||
}
|
}
|
||||||
ui->ttCombo->removeItem(threadIndex);
|
ui->ttCombo->removeItem(threadIndex);
|
||||||
});
|
});
|
||||||
@ -184,7 +188,7 @@ std::unordered_map<std::string, int64_t> MainWindow::GetMiscInfo(TextThread* thr
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_attachButton_clicked()
|
void MainWindow::AttachProcess()
|
||||||
{
|
{
|
||||||
QMultiHash<QString, DWORD> allProcesses;
|
QMultiHash<QString, DWORD> allProcesses;
|
||||||
DWORD allProcessIds[5000] = {}, spaceUsed = 0;
|
DWORD allProcessIds[5000] = {}, spaceUsed = 0;
|
||||||
@ -201,12 +205,12 @@ void MainWindow::on_attachButton_clicked()
|
|||||||
else for (auto processId : allProcesses.values(process)) Host::InjectProcess(processId);
|
else for (auto processId : allProcesses.values(process)) Host::InjectProcess(processId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_detachButton_clicked()
|
void MainWindow::DetachProcess()
|
||||||
{
|
{
|
||||||
Host::DetachProcess(GetSelectedProcessId());
|
Host::DetachProcess(GetSelectedProcessId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_hookButton_clicked()
|
void MainWindow::AddHook()
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
QString hookCode = QInputDialog::getText(this, ADD_HOOK, CODE_INFODUMP, QLineEdit::Normal, "", &ok, Qt::WindowCloseButtonHint);
|
QString hookCode = QInputDialog::getText(this, ADD_HOOK, CODE_INFODUMP, QLineEdit::Normal, "", &ok, Qt::WindowCloseButtonHint);
|
||||||
@ -215,7 +219,7 @@ void MainWindow::on_hookButton_clicked()
|
|||||||
else Host::AddConsoleOutput(INVALID_CODE);
|
else Host::AddConsoleOutput(INVALID_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_saveButton_clicked()
|
void MainWindow::SaveHooks()
|
||||||
{
|
{
|
||||||
if (auto processName = Util::GetModuleFileName(GetSelectedProcessId()))
|
if (auto processName = Util::GetModuleFileName(GetSelectedProcessId()))
|
||||||
{
|
{
|
||||||
@ -231,19 +235,19 @@ void MainWindow::on_saveButton_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_setButton_clicked()
|
void MainWindow::Settings()
|
||||||
{
|
{
|
||||||
SetDialog(this).exec();
|
SetDialog(this).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_extenButton_clicked()
|
void MainWindow::Extensions()
|
||||||
{
|
{
|
||||||
extenWindow->activateWindow();
|
extenWindow->activateWindow();
|
||||||
extenWindow->showNormal();
|
extenWindow->showNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_ttCombo_activated(int index)
|
void MainWindow::ViewThread(int index)
|
||||||
{
|
{
|
||||||
ui->textOutput->setPlainText(S(Host::GetThread(ParseTextThreadString(ui->ttCombo->itemText(index)))->GetStorage()));
|
ui->textOutput->setPlainText(S(Host::GetThread(ParseTextThreadString(ui->ttCombo->itemText(index)))->storage->c_str()));
|
||||||
ui->textOutput->moveCursor(QTextCursor::End);
|
ui->textOutput->moveCursor(QTextCursor::End);
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
#include "host/host.h"
|
#include "host/host.h"
|
||||||
#include "defs.h"
|
|
||||||
#include <QPlainTextEdit>
|
|
||||||
#include <QComboBox>
|
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
@ -14,23 +10,13 @@ namespace Ui
|
|||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_attachButton_clicked();
|
|
||||||
void on_detachButton_clicked();
|
|
||||||
void on_hookButton_clicked();
|
|
||||||
void on_saveButton_clicked();
|
|
||||||
void on_setButton_clicked();
|
|
||||||
void on_extenButton_clicked();
|
|
||||||
void on_ttCombo_activated(int index);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void closeEvent(QCloseEvent*);
|
void closeEvent(QCloseEvent*) override;
|
||||||
void InvokeOnMainThread(std::function<void()> f);
|
void InvokeOnMainThread(std::function<void()> f);
|
||||||
void ProcessConnected(DWORD processId);
|
void ProcessConnected(DWORD processId);
|
||||||
void ProcessDisconnected(DWORD processId);
|
void ProcessDisconnected(DWORD processId);
|
||||||
@ -41,8 +27,14 @@ private:
|
|||||||
ThreadParam ParseTextThreadString(QString ttString);
|
ThreadParam ParseTextThreadString(QString ttString);
|
||||||
DWORD GetSelectedProcessId();
|
DWORD GetSelectedProcessId();
|
||||||
std::unordered_map<std::string, int64_t> GetMiscInfo(TextThread* thread);
|
std::unordered_map<std::string, int64_t> GetMiscInfo(TextThread* thread);
|
||||||
|
void AttachProcess();
|
||||||
|
void DetachProcess();
|
||||||
|
void AddHook();
|
||||||
|
void SaveHooks();
|
||||||
|
void Settings();
|
||||||
|
void Extensions();
|
||||||
|
void ViewThread(int index);
|
||||||
|
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
QSettings settings = QSettings(CONFIG_FILE, QSettings::IniFormat);
|
|
||||||
QWidget* extenWindow;
|
QWidget* extenWindow;
|
||||||
};
|
};
|
||||||
|
@ -9,3 +9,4 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QSettings>
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "host/host.h"
|
#include "host/host.h"
|
||||||
#include <QSettings>
|
|
||||||
|
|
||||||
SetDialog::SetDialog(QWidget* parent) :
|
SetDialog::SetDialog(QWidget* parent) :
|
||||||
QDialog(parent, Qt::WindowCloseButtonHint),
|
QDialog(parent, Qt::WindowCloseButtonHint),
|
||||||
@ -21,18 +20,19 @@ SetDialog::SetDialog(QWidget* parent) :
|
|||||||
spinBox->setValue(value);
|
spinBox->setValue(value);
|
||||||
ui->layout->insertRow(0, label, spinBox);
|
ui->layout->insertRow(0, label, spinBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(ui->buttonBox, &QDialogButtonBox::accepted, [&] { edited = true; });
|
||||||
}
|
}
|
||||||
|
|
||||||
SetDialog::~SetDialog()
|
SetDialog::~SetDialog()
|
||||||
{
|
{
|
||||||
|
if (edited)
|
||||||
|
{
|
||||||
|
QSettings settings(CONFIG_FILE, QSettings::IniFormat);
|
||||||
|
settings.setValue(FLUSH_DELAY, TextThread::flushDelay = flushDelay->value());
|
||||||
|
settings.setValue(MAX_BUFFER_SIZE, TextThread::maxBufferSize = maxBufferSize->value());
|
||||||
|
settings.setValue(DEFAULT_CODEPAGE, TextThread::defaultCodepage = defaultCodepage->value());
|
||||||
|
settings.sync();
|
||||||
|
}
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDialog::on_buttonBox_accepted()
|
|
||||||
{
|
|
||||||
QSettings settings(CONFIG_FILE, QSettings::IniFormat);
|
|
||||||
settings.setValue(FLUSH_DELAY, TextThread::flushDelay = flushDelay->value());
|
|
||||||
settings.setValue(MAX_BUFFER_SIZE, TextThread::maxBufferSize = maxBufferSize->value());
|
|
||||||
settings.setValue(DEFAULT_CODEPAGE, TextThread::defaultCodepage = defaultCodepage->value());
|
|
||||||
settings.sync();
|
|
||||||
}
|
|
||||||
|
@ -10,18 +10,14 @@ namespace Ui
|
|||||||
|
|
||||||
class SetDialog : public QDialog
|
class SetDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SetDialog(QWidget* parent = nullptr);
|
explicit SetDialog(QWidget* parent = nullptr);
|
||||||
~SetDialog();
|
~SetDialog();
|
||||||
|
|
||||||
private slots:
|
|
||||||
void on_buttonBox_accepted();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::SetDialog* ui;
|
Ui::SetDialog* ui;
|
||||||
QSpinBox* flushDelay;
|
QSpinBox* flushDelay;
|
||||||
QSpinBox* maxBufferSize;
|
QSpinBox* maxBufferSize;
|
||||||
QSpinBox* defaultCodepage;
|
QSpinBox* defaultCodepage;
|
||||||
|
bool edited = false;
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,7 @@ class ThreadSafePtr
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template <typename ...Args> ThreadSafePtr(Args ...args) : ptr(new E(args...)), mtxPtr(new M) {}
|
template <typename ...Args> ThreadSafePtr(Args ...args) : ptr(new E(args...)), mtxPtr(new M) {}
|
||||||
auto operator->()
|
auto operator->() const
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user