mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 17:04:12 +08:00
commit
c1198aeefd
@ -9,7 +9,7 @@ set(gui_SRCS
|
|||||||
main.cpp
|
main.cpp
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
misc.cpp
|
misc.cpp
|
||||||
extensions.cpp
|
extenwindow.cpp
|
||||||
tests.cpp
|
tests.cpp
|
||||||
host/host.cc
|
host/host.cc
|
||||||
host/textthread.cc
|
host/textthread.cc
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
#include "extensions.h"
|
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
static std::optional<Extension> LoadExtension(QString extenName)
|
|
||||||
{
|
|
||||||
// Extension is dll and exports "OnNewSentence"
|
|
||||||
HMODULE module = GetModuleHandleW(extenName.toStdWString().c_str());
|
|
||||||
if (!module) module = LoadLibraryW(extenName.toStdWString().c_str());
|
|
||||||
if (!module) return {};
|
|
||||||
FARPROC callback = GetProcAddress(module, "OnNewSentence");
|
|
||||||
if (!callback) return {};
|
|
||||||
return Extension{ extenName, (wchar_t*(*)(const wchar_t*, const InfoForExtension*))callback };
|
|
||||||
}
|
|
||||||
|
|
||||||
void Extension::Load(QString extenName)
|
|
||||||
{
|
|
||||||
LOCK(extenMutex);
|
|
||||||
if (auto extension = LoadExtension(extenName)) extensions.push_back(extension.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Extension::SendToBack(QString extenName)
|
|
||||||
{
|
|
||||||
LOCK(extenMutex);
|
|
||||||
Extension* extenIter = std::find_if(extensions.begin(), extensions.end(), [&](Extension extension) { return extension.name == extenName; });
|
|
||||||
Extension extension = *extenIter;
|
|
||||||
extensions.erase(extenIter);
|
|
||||||
extensions.push_back(extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Extension::Unload(QString extenName)
|
|
||||||
{
|
|
||||||
LOCK(extenMutex);
|
|
||||||
extensions.erase(std::find_if(extensions.begin(), extensions.end(), [&](Extension extension) { return extension.name == extenName; }));
|
|
||||||
FreeLibrary(GetModuleHandleW(extenName.toStdWString().c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QString> Extension::GetNames()
|
|
||||||
{
|
|
||||||
std::shared_lock sharedLock(extenMutex);
|
|
||||||
QVector<QString> ret;
|
|
||||||
for (auto extension : extensions) ret.push_back(extension.name);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Extension::DispatchSentence(std::wstring& sentence, std::unordered_map<std::string, int64_t> miscInfo)
|
|
||||||
{
|
|
||||||
bool success = true;
|
|
||||||
wchar_t* sentenceBuffer = (wchar_t*)HeapAlloc(GetProcessHeap(), 0, (sentence.size() + 1) * sizeof(wchar_t));
|
|
||||||
wcscpy_s(sentenceBuffer, sentence.size() + 1, sentence.c_str());
|
|
||||||
|
|
||||||
InfoForExtension miscInfoLinkedList{ "", 0, nullptr };
|
|
||||||
InfoForExtension* miscInfoTraverser = &miscInfoLinkedList;
|
|
||||||
for (auto& i : miscInfo) miscInfoTraverser = miscInfoTraverser->next = new InfoForExtension{ i.first.c_str(), i.second, nullptr };
|
|
||||||
|
|
||||||
std::shared_lock sharedLock(extenMutex);
|
|
||||||
for (auto extension : extensions)
|
|
||||||
{
|
|
||||||
wchar_t* nextBuffer = extension.callback(sentenceBuffer, &miscInfoLinkedList);
|
|
||||||
if (nextBuffer == nullptr) { success = false; break; }
|
|
||||||
if (nextBuffer != sentenceBuffer) HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
|
||||||
sentenceBuffer = nextBuffer;
|
|
||||||
}
|
|
||||||
sentence = std::wstring(sentenceBuffer);
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
|
||||||
return success;
|
|
||||||
}
|
|
@ -1,32 +0,0 @@
|
|||||||
#ifndef EXTENSIONS_H
|
|
||||||
#define EXTENSIONS_H
|
|
||||||
|
|
||||||
#include "qtcommon.h"
|
|
||||||
#include <shared_mutex>
|
|
||||||
|
|
||||||
struct InfoForExtension
|
|
||||||
{
|
|
||||||
const char* name;
|
|
||||||
int64_t value;
|
|
||||||
InfoForExtension* next;
|
|
||||||
~InfoForExtension() { if (next) delete next; };
|
|
||||||
};
|
|
||||||
|
|
||||||
class Extension
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
static bool DispatchSentence(std::wstring& sentence, std::unordered_map<std::string, int64_t> miscInfo);
|
|
||||||
static void Load(QString extenName);
|
|
||||||
static void SendToBack(QString extenName);
|
|
||||||
static void Unload(QString extenName);
|
|
||||||
static QVector<QString> GetNames();
|
|
||||||
|
|
||||||
QString name;
|
|
||||||
wchar_t* (*callback)(const wchar_t*, const InfoForExtension*);
|
|
||||||
|
|
||||||
private:
|
|
||||||
inline static std::shared_mutex extenMutex;
|
|
||||||
inline static QVector<Extension> extensions;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // EXTENSIONS_H
|
|
152
GUI/extenwindow.cpp
Normal file
152
GUI/extenwindow.cpp
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
#include "extenwindow.h"
|
||||||
|
#include "ui_extenwindow.h"
|
||||||
|
#include "defs.h"
|
||||||
|
#include "types.h"
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QMimeData>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
struct InfoForExtension
|
||||||
|
{
|
||||||
|
const char* name;
|
||||||
|
int64_t value;
|
||||||
|
InfoForExtension* next;
|
||||||
|
~InfoForExtension() { if (next) delete next; };
|
||||||
|
};
|
||||||
|
|
||||||
|
QHash<QString, wchar_t*(*)(const wchar_t*, const InfoForExtension*)> extensions;
|
||||||
|
QStringList extenNames;
|
||||||
|
std::shared_mutex extenMutex;
|
||||||
|
|
||||||
|
void Load(QString extenName)
|
||||||
|
{
|
||||||
|
if (extenName == ITH_DLL) return;
|
||||||
|
// Extension is dll and exports "OnNewSentence"
|
||||||
|
HMODULE module = GetModuleHandleW(extenName.toStdWString().c_str());
|
||||||
|
if (!module) module = LoadLibraryW(extenName.toStdWString().c_str());
|
||||||
|
if (!module) return;
|
||||||
|
FARPROC callback = GetProcAddress(module, "OnNewSentence");
|
||||||
|
if (!callback) return;
|
||||||
|
LOCK(extenMutex);
|
||||||
|
extensions[extenName] = (wchar_t*(*)(const wchar_t*, const InfoForExtension*))callback;
|
||||||
|
extenNames.push_back(extenName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Unload(QString extenName)
|
||||||
|
{
|
||||||
|
LOCK(extenMutex);
|
||||||
|
extenNames.erase(std::remove(extenNames.begin(), extenNames.end(), extenName), extenNames.end());
|
||||||
|
FreeLibrary(GetModuleHandleW(extenName.toStdWString().c_str()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reorder(QStringList extenNames)
|
||||||
|
{
|
||||||
|
LOCK(extenMutex);
|
||||||
|
::extenNames = extenNames;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std::string, int64_t> miscInfo)
|
||||||
|
{
|
||||||
|
bool success = true;
|
||||||
|
wchar_t* sentenceBuffer = (wchar_t*)HeapAlloc(GetProcessHeap(), 0, (sentence.size() + 1) * sizeof(wchar_t));
|
||||||
|
wcscpy_s(sentenceBuffer, sentence.size() + 1, sentence.c_str());
|
||||||
|
|
||||||
|
InfoForExtension miscInfoLinkedList{ "", 0, nullptr };
|
||||||
|
InfoForExtension* miscInfoTraverser = &miscInfoLinkedList;
|
||||||
|
for (auto& i : miscInfo) miscInfoTraverser = miscInfoTraverser->next = new InfoForExtension{ i.first.c_str(), i.second, nullptr };
|
||||||
|
|
||||||
|
std::shared_lock sharedLock(extenMutex);
|
||||||
|
for (auto extenName : extenNames)
|
||||||
|
{
|
||||||
|
wchar_t* nextBuffer = extensions[extenName](sentenceBuffer, &miscInfoLinkedList);
|
||||||
|
if (nextBuffer == nullptr) { success = false; break; }
|
||||||
|
if (nextBuffer != sentenceBuffer) HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
||||||
|
sentenceBuffer = nextBuffer;
|
||||||
|
}
|
||||||
|
sentence = std::wstring(sentenceBuffer);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtenWindow::ExtenWindow(QWidget* parent) :
|
||||||
|
QMainWindow(parent),
|
||||||
|
ui(new Ui::ExtenWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
extenList = findChild<QListWidget*>("extenList");
|
||||||
|
extenList->installEventFilter(this);
|
||||||
|
|
||||||
|
if (extensions.empty())
|
||||||
|
{
|
||||||
|
extenSaveFile.open(QIODevice::ReadOnly);
|
||||||
|
for (auto extenName : QString(extenSaveFile.readAll()).split(">")) Load(extenName);
|
||||||
|
extenSaveFile.close();
|
||||||
|
}
|
||||||
|
Sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
ExtenWindow::~ExtenWindow()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtenWindow::Sync()
|
||||||
|
{
|
||||||
|
extenList->clear();
|
||||||
|
extenSaveFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||||
|
std::shared_lock sharedLock(extenMutex);
|
||||||
|
for (auto extenName : extenNames)
|
||||||
|
{
|
||||||
|
extenList->addItem(extenName);
|
||||||
|
extenSaveFile.write((extenName + ">").toUtf8());
|
||||||
|
}
|
||||||
|
extenSaveFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtenWindow::Add(QString fileName)
|
||||||
|
{
|
||||||
|
if (!fileName.endsWith(".dll")) return;
|
||||||
|
QString extenName = fileName.mid(fileName.lastIndexOf("/") + 1);
|
||||||
|
QFile::copy(fileName, extenName);
|
||||||
|
Load(extenName.split(".dll")[0]);
|
||||||
|
Sync();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ExtenWindow::eventFilter(QObject* target, QEvent* event)
|
||||||
|
{
|
||||||
|
// See https://stackoverflow.com/questions/1224432/how-do-i-respond-to-an-internal-drag-and-drop-operation-using-a-qlistwidget/1528215
|
||||||
|
if (event->type() == QEvent::ChildRemoved)
|
||||||
|
{
|
||||||
|
QStringList extenNames;
|
||||||
|
for (int i = 0; i < extenList->count(); ++i) extenNames.push_back(extenList->item(i)->text());
|
||||||
|
Reorder(extenNames);
|
||||||
|
Sync();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtenWindow::dragEnterEvent(QDragEnterEvent* event)
|
||||||
|
{
|
||||||
|
event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtenWindow::dropEvent(QDropEvent* event)
|
||||||
|
{
|
||||||
|
for (auto file : event->mimeData()->urls()) Add(file.toLocalFile());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtenWindow::on_addButton_clicked()
|
||||||
|
{
|
||||||
|
Add(QFileDialog::getOpenFileName(this, "Select Extension", "C:\\", "Extensions (*.dll)"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtenWindow::on_rmvButton_clicked()
|
||||||
|
{
|
||||||
|
if (auto extenName = extenList->currentItem()) Unload(extenName->text());
|
||||||
|
Sync();
|
||||||
|
}
|
41
GUI/extenwindow.h
Normal file
41
GUI/extenwindow.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#ifndef EXTENSIONS_H
|
||||||
|
#define EXTENSIONS_H
|
||||||
|
|
||||||
|
#include "qtcommon.h"
|
||||||
|
#include <shared_mutex>
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QDragEnterEvent>
|
||||||
|
#include <QDropEvent>
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class ExtenWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std::string, int64_t> miscInfo);
|
||||||
|
|
||||||
|
class ExtenWindow : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit ExtenWindow(QWidget* parent = nullptr);
|
||||||
|
~ExtenWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_addButton_clicked();
|
||||||
|
void on_rmvButton_clicked();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Add(QString fileName);
|
||||||
|
void Sync();
|
||||||
|
bool eventFilter(QObject* target, QEvent* event);
|
||||||
|
void dragEnterEvent(QDragEnterEvent* event);
|
||||||
|
void dropEvent(QDropEvent* event);
|
||||||
|
|
||||||
|
Ui::ExtenWindow* ui;
|
||||||
|
QFile extenSaveFile = QFile("Extensions.txt");
|
||||||
|
QListWidget* extenList;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // EXTENSIONS_H
|
87
GUI/extenwindow.ui
Normal file
87
GUI/extenwindow.ui
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>ExtenWindow</class>
|
||||||
|
<widget class="QMainWindow" name="ExtenWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="acceptDrops">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Extensions</string>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">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;
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralWidget">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QListWidget" name="extenList">
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::InternalMove</enum>
|
||||||
|
</property>
|
||||||
|
<property name="defaultDropAction">
|
||||||
|
<enum>Qt::MoveAction</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="rmvButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="6"/>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -1,36 +1,21 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "extensions.h"
|
#include "extenwindow.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QFileDialog>
|
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow),
|
||||||
|
extenWindow(new ExtenWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
processCombo = findChild<QComboBox*>("processCombo");
|
processCombo = findChild<QComboBox*>("processCombo");
|
||||||
ttCombo = findChild<QComboBox*>("ttCombo");
|
ttCombo = findChild<QComboBox*>("ttCombo");
|
||||||
extenCombo = findChild<QComboBox*>("extenCombo");
|
|
||||||
textOutput = findChild<QPlainTextEdit*>("textOutput");
|
textOutput = findChild<QPlainTextEdit*>("textOutput");
|
||||||
|
|
||||||
QFile extenSaveFile("Extensions.txt");
|
|
||||||
if (extenSaveFile.exists())
|
|
||||||
{
|
|
||||||
extenSaveFile.open(QIODevice::ReadOnly);
|
|
||||||
for (auto extenName : QString(extenSaveFile.readAll()).split(">")) Extension::Load(extenName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (auto file : QDir().entryList())
|
|
||||||
if (file.endsWith(".dll") && file != ITH_DLL) Extension::Load(file.left(file.lastIndexOf(".dll")));
|
|
||||||
}
|
|
||||||
ReloadExtensions();
|
|
||||||
|
|
||||||
if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect());
|
if (settings.contains("Window")) this->setGeometry(settings.value("Window").toRect());
|
||||||
// TODO: add GUI for changing these
|
// TODO: add GUI for changing these
|
||||||
if (settings.contains("Flush_Delay")) TextThread::flushDelay = settings.value("Flush_Delay").toInt();
|
if (settings.contains("Flush_Delay")) TextThread::flushDelay = settings.value("Flush_Delay").toInt();
|
||||||
@ -65,6 +50,11 @@ MainWindow::~MainWindow()
|
|||||||
Host::Close();
|
Host::Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::closeEvent(QCloseEvent*)
|
||||||
|
{
|
||||||
|
QCoreApplication::quit(); // Need to do this to kill any windows that might've been made by extensions
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::AddProcess(unsigned processId)
|
void MainWindow::AddProcess(unsigned processId)
|
||||||
{
|
{
|
||||||
processCombo->addItem(QString::number(processId, 16).toUpper() + ": " + GetModuleName(processId));
|
processCombo->addItem(QString::number(processId, 16).toUpper() + ": " + GetModuleName(processId));
|
||||||
@ -120,7 +110,7 @@ void MainWindow::ThreadOutput(QString threadString, QString output)
|
|||||||
|
|
||||||
bool MainWindow::ProcessThreadOutput(TextThread* thread, std::wstring& output)
|
bool MainWindow::ProcessThreadOutput(TextThread* thread, std::wstring& output)
|
||||||
{
|
{
|
||||||
if (Extension::DispatchSentence(output, GetInfoForExtensions(thread)))
|
if (DispatchSentenceToExtensions(output, GetMiscInfo(thread)))
|
||||||
{
|
{
|
||||||
output += L"\r\n";
|
output += L"\r\n";
|
||||||
emit SigThreadOutput(TextThreadString(thread), QString::fromStdWString(output));
|
emit SigThreadOutput(TextThreadString(thread), QString::fromStdWString(output));
|
||||||
@ -152,19 +142,7 @@ DWORD MainWindow::GetSelectedProcessId()
|
|||||||
return processCombo->currentText().split(":")[0].toULong(nullptr, 16);
|
return processCombo->currentText().split(":")[0].toULong(nullptr, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ReloadExtensions()
|
std::unordered_map<std::string, int64_t> MainWindow::GetMiscInfo(TextThread* thread)
|
||||||
{
|
|
||||||
extenCombo->clear();
|
|
||||||
QFile extenSaveFile("Extensions.txt");
|
|
||||||
extenSaveFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
|
||||||
for (auto extenName : Extension::GetNames())
|
|
||||||
{
|
|
||||||
extenSaveFile.write((extenName + ">").toUtf8());
|
|
||||||
extenCombo->addItem(extenName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unordered_map<std::string, int64_t> MainWindow::GetInfoForExtensions(TextThread* thread)
|
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
{
|
{
|
||||||
@ -251,33 +229,14 @@ void MainWindow::on_saveButton_clicked()
|
|||||||
file.write((hookList + "\r\n").toUtf8());
|
file.write((hookList + "\r\n").toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_extenButton_clicked()
|
||||||
|
{
|
||||||
|
extenWindow->activateWindow();
|
||||||
|
extenWindow->showNormal();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_ttCombo_activated(int index)
|
void MainWindow::on_ttCombo_activated(int index)
|
||||||
{
|
{
|
||||||
textOutput->setPlainText(QString::fromStdWString(Host::GetThread(ParseTextThreadString(ttCombo->itemText(index)))->GetStorage()));
|
textOutput->setPlainText(QString::fromStdWString(Host::GetThread(ParseTextThreadString(ttCombo->itemText(index)))->GetStorage()));
|
||||||
textOutput->moveCursor(QTextCursor::End);
|
textOutput->moveCursor(QTextCursor::End);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_addExtenButton_clicked()
|
|
||||||
{
|
|
||||||
QString extenFileName = QFileDialog::getOpenFileName(this, "Select Extension", "C:\\", "Extensions (*.dll)");
|
|
||||||
if (!extenFileName.size()) return;
|
|
||||||
QString extenName = extenFileName.mid(extenFileName.lastIndexOf("/") + 1);
|
|
||||||
QFile::copy(extenFileName, extenName);
|
|
||||||
Extension::Load(extenName.left(extenName.lastIndexOf(".dll")));
|
|
||||||
ReloadExtensions();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_moveExtenButton_clicked()
|
|
||||||
{
|
|
||||||
if (extenCombo->currentText() == "") return;
|
|
||||||
Extension::SendToBack(extenCombo->currentText());
|
|
||||||
ReloadExtensions();
|
|
||||||
Host::AddConsoleOutput(L"extension sent to back");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::on_rmvExtenButton_clicked()
|
|
||||||
{
|
|
||||||
if (extenCombo->currentText() == "") return;
|
|
||||||
Extension::Unload(extenCombo->currentText());
|
|
||||||
ReloadExtensions();
|
|
||||||
}
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
#include "host/host.h"
|
#include "host/host.h"
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
@ -38,29 +37,27 @@ private slots:
|
|||||||
void ThreadOutput(QString threadString, QString output); // this function doesn't take TextThread* because it might be destroyed on pipe thread
|
void ThreadOutput(QString threadString, QString output); // this function doesn't take TextThread* because it might be destroyed on pipe thread
|
||||||
void on_attachButton_clicked();
|
void on_attachButton_clicked();
|
||||||
void on_detachButton_clicked();
|
void on_detachButton_clicked();
|
||||||
void on_ttCombo_activated(int index);
|
|
||||||
void on_unhookButton_clicked();
|
void on_unhookButton_clicked();
|
||||||
void on_hookButton_clicked();
|
void on_hookButton_clicked();
|
||||||
void on_saveButton_clicked();
|
void on_saveButton_clicked();
|
||||||
void on_addExtenButton_clicked();
|
void on_extenButton_clicked();
|
||||||
void on_moveExtenButton_clicked();
|
void on_ttCombo_activated(int index);
|
||||||
void on_rmvExtenButton_clicked();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool ProcessThreadOutput(TextThread* thread, std::wstring& output);
|
bool ProcessThreadOutput(TextThread* thread, std::wstring& output);
|
||||||
QString TextThreadString(TextThread* thread);
|
QString TextThreadString(TextThread* thread);
|
||||||
ThreadParam ParseTextThreadString(QString textThreadString);
|
ThreadParam ParseTextThreadString(QString textThreadString);
|
||||||
DWORD GetSelectedProcessId();
|
DWORD GetSelectedProcessId();
|
||||||
void ReloadExtensions();
|
std::unordered_map<std::string, int64_t> GetMiscInfo(TextThread* thread);
|
||||||
std::unordered_map<std::string, int64_t> GetInfoForExtensions(TextThread* thread);
|
|
||||||
QVector<HookParam> GetAllHooks(DWORD processId);
|
QVector<HookParam> GetAllHooks(DWORD processId);
|
||||||
|
void closeEvent(QCloseEvent*);
|
||||||
|
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
QSettings settings = QSettings("Textractor.ini", QSettings::IniFormat);
|
QSettings settings = QSettings("Textractor.ini", QSettings::IniFormat);
|
||||||
QComboBox* processCombo;
|
QComboBox* processCombo;
|
||||||
QComboBox* ttCombo;
|
QComboBox* ttCombo;
|
||||||
QComboBox* extenCombo;
|
|
||||||
QPlainTextEdit* textOutput;
|
QPlainTextEdit* textOutput;
|
||||||
|
QWidget* extenWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -6,16 +6,10 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>949</width>
|
<width>900</width>
|
||||||
<height>600</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>2</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Textractor</string>
|
<string>Textractor</string>
|
||||||
</property>
|
</property>
|
||||||
@ -38,271 +32,115 @@ QPushButton, QComboBox
|
|||||||
}</string>
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout">
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="options">
|
<widget class="QFrame" name="processManager">
|
||||||
<property name="sizePolicy">
|
<property name="enabled">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<bool>true</bool>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
<layout class="QVBoxLayout">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>4</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>4</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>4</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>4</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="processManager">
|
<widget class="QComboBox" name="processCombo">
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
|
||||||
<horstretch>2</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="processCombo">
|
|
||||||
<property name="editable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="insertPolicy">
|
|
||||||
<enum>QComboBox::InsertAtBottom</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeAdjustPolicy">
|
|
||||||
<enum>QComboBox::AdjustToContents</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="attachButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Attach to game</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="detachButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Detach from game</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="hookButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add hook</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="unhookButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove hook</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="saveButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save hook(s)</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QFrame" name="extenManager">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="extenCombo">
|
|
||||||
<property name="editable">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizeAdjustPolicy">
|
|
||||||
<enum>QComboBox::AdjustToContents</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="addExtenButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add extension</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="moveExtenButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Move extension</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="rmvExtenButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove extension</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QFrame" name="output">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>6</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::StyledPanel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="ttCombo">
|
|
||||||
<property name="editable">
|
<property name="editable">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="maxVisibleItems">
|
<property name="insertPolicy">
|
||||||
<number>50</number>
|
<enum>QComboBox::InsertAtBottom</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeAdjustPolicy">
|
||||||
|
<enum>QComboBox::AdjustToContents</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPlainTextEdit" name="textOutput">
|
<widget class="QPushButton" name="attachButton">
|
||||||
<property name="sizePolicy">
|
<property name="text">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<string>Attach to game</string>
|
||||||
<horstretch>5</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="readOnly">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="detachButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Detach from game</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="hookButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add hook</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="unhookButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove hook</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="saveButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save hook(s)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="extenButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Extensions</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="ttCombo">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="maxVisibleItems">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="textOutput">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menuBar">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>949</width>
|
|
||||||
<height>22</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="6"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "qtcommon.h"
|
#include "qtcommon.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <QHash>
|
|
||||||
|
|
||||||
QString GetFullModuleName(DWORD processId, HMODULE module = NULL);
|
QString GetFullModuleName(DWORD processId, HMODULE module = NULL);
|
||||||
QString GetModuleName(DWORD processId, HMODULE module = NULL);
|
QString GetModuleName(DWORD processId, HMODULE module = NULL);
|
||||||
|
@ -3,4 +3,7 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include <QFile>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include "extensions.h"
|
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
static int TESTS = []
|
static int TESTS = []
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// vnrhook/defs.h
|
// vnrhook/defs.h
|
||||||
// 8/23/2013 jichi
|
// 8/23/2013 jichi
|
||||||
|
|
||||||
#define ITH_DLL L"vnrhook.dll"
|
#define ITH_DLL L"vnrhook"
|
||||||
|
|
||||||
// Pipes
|
// Pipes
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user