forked from Public-Mirror/Textractor
set up GUI skeleton, and small bugfixes
This commit is contained in:
parent
a85c398f47
commit
11d6a156dd
@ -1,8 +1,10 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "../texthook/host.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
if (!Host::Start()) return 1;
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
@ -55,7 +55,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
ttCombo = mainWindow->findChild<QComboBox*>("ttCombo");
|
ttCombo = mainWindow->findChild<QComboBox*>("ttCombo");
|
||||||
textOutput = mainWindow->findChild<QTextBrowser*>("textOutput");
|
textOutput = mainWindow->findChild<QTextBrowser*>("textOutput");
|
||||||
|
|
||||||
Host::Start();
|
|
||||||
hostSignaller->Initialize();
|
hostSignaller->Initialize();
|
||||||
connect(hostSignaller, &HostSignaller::AddProcess, this, &MainWindow::AddProcess);
|
connect(hostSignaller, &HostSignaller::AddProcess, this, &MainWindow::AddProcess);
|
||||||
connect(hostSignaller, &HostSignaller::RemoveProcess, this, &MainWindow::RemoveProcess);
|
connect(hostSignaller, &HostSignaller::RemoveProcess, this, &MainWindow::RemoveProcess);
|
||||||
@ -74,14 +73,12 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
void MainWindow::AddProcess(unsigned int processId)
|
void MainWindow::AddProcess(unsigned int processId)
|
||||||
{
|
{
|
||||||
processCombo->addItem(ProcessString(processId), Qt::AlignHCenter);
|
processCombo->addItem(ProcessString(processId));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::RemoveProcess(unsigned int processId)
|
void MainWindow::RemoveProcess(unsigned int processId)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < processCombo->count(); ++i)
|
processCombo->removeItem(processCombo->findText(QString::number(processId), Qt::MatchStartsWith));
|
||||||
if (processCombo->itemText(i).split(":")[0] == QString::number(processId))
|
|
||||||
processCombo->removeItem(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AddThread(TextThread* thread)
|
void MainWindow::AddThread(TextThread* thread)
|
||||||
@ -91,16 +88,13 @@ void MainWindow::AddThread(TextThread* thread)
|
|||||||
|
|
||||||
void MainWindow::RemoveThread(TextThread* thread)
|
void MainWindow::RemoveThread(TextThread* thread)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < ttCombo->count(); ++i)
|
int threadIndex = ttCombo->findText(QString::number(thread->Number()), Qt::MatchStartsWith);
|
||||||
if (ttCombo->itemText(i).split(":")[0] == QString::number(thread->Number()))
|
ttCombo->removeItem(threadIndex);
|
||||||
{
|
if (threadIndex == ttCombo->currentIndex())
|
||||||
ttCombo->removeItem(i);
|
{
|
||||||
if (i == ttCombo->currentIndex())
|
ttCombo->setCurrentIndex(0);
|
||||||
{
|
on_ttCombo_activated(0);
|
||||||
ttCombo->setCurrentIndex(0);
|
}
|
||||||
on_ttCombo_activated(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ThreadOutput(TextThread* thread, QString output)
|
void MainWindow::ThreadOutput(TextThread* thread, QString output)
|
||||||
|
@ -6,10 +6,16 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>949</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="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<pointsize>10</pointsize>
|
<pointsize>10</pointsize>
|
||||||
@ -20,10 +26,22 @@
|
|||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<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="processManager">
|
<widget class="QFrame" name="options">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
<horstretch>2</horstretch>
|
<horstretch>2</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -34,29 +52,159 @@
|
|||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<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>
|
<item>
|
||||||
<widget class="QLineEdit" name="lineEdit"/>
|
<widget class="QFrame" name="processManager">
|
||||||
</item>
|
<property name="enabled">
|
||||||
<item>
|
<bool>true</bool>
|
||||||
<widget class="QComboBox" name="processCombo">
|
|
||||||
<property name="insertPolicy">
|
|
||||||
<enum>QComboBox::InsertAtBottom</enum>
|
|
||||||
</property>
|
</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="insertPolicy">
|
||||||
|
<enum>QComboBox::InsertAtBottom</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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="attachButton">
|
<spacer name="verticalSpacer">
|
||||||
<property name="text">
|
<property name="orientation">
|
||||||
<string>Attach to game</string>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="detachButton">
|
<widget class="QFrame" name="extenManager">
|
||||||
<property name="text">
|
<property name="sizePolicy">
|
||||||
<string>Detach from game</string>
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</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"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="addExtenButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add extension</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="enableExtenButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Enable extension</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="disableExtenButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Disable extension</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -77,6 +225,18 @@
|
|||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<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>
|
<item>
|
||||||
<widget class="QComboBox" name="ttCombo"/>
|
<widget class="QComboBox" name="ttCombo"/>
|
||||||
</item>
|
</item>
|
||||||
@ -105,10 +265,22 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>949</width>
|
||||||
<height>23</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QMenu" name="menuOptions">
|
||||||
|
<property name="title">
|
||||||
|
<string>Options</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuAbout">
|
||||||
|
<property name="title">
|
||||||
|
<string>About</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<addaction name="menuOptions"/>
|
||||||
|
<addaction name="menuAbout"/>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
@ -23,7 +23,6 @@ ProcessEventCallback onAttach, onDetach;
|
|||||||
|
|
||||||
WORD nextThreadNumber;
|
WORD nextThreadNumber;
|
||||||
HWND dummyWindow;
|
HWND dummyWindow;
|
||||||
bool running;
|
|
||||||
|
|
||||||
#define HOST_LOCK CriticalSectionLocker hostLocker(hostCs) // Synchronized scope for accessing private data
|
#define HOST_LOCK CriticalSectionLocker hostLocker(hostCs) // Synchronized scope for accessing private data
|
||||||
|
|
||||||
@ -56,14 +55,13 @@ namespace Host
|
|||||||
DLLEXPORT bool Start()
|
DLLEXPORT bool Start()
|
||||||
{
|
{
|
||||||
preventDuplicationMutex = CreateMutexW(nullptr, TRUE, ITH_SERVER_MUTEX);
|
preventDuplicationMutex = CreateMutexW(nullptr, TRUE, ITH_SERVER_MUTEX);
|
||||||
if (GetLastError() == ERROR_ALREADY_EXISTS || running)
|
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||||
{
|
{
|
||||||
MessageBoxW(nullptr, L"I am sorry that this game is attached by some other VNR ><\nPlease restart the game and try again!", L"Error", MB_ICONERROR);
|
MessageBoxW(nullptr, L"I am sorry that this game is attached by some other VNR ><\nPlease restart the game and try again!", L"Error", MB_ICONERROR);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
running = true;
|
|
||||||
GetDebugPrivileges();
|
GetDebugPrivileges();
|
||||||
InitializeCriticalSection(&hostCs);
|
InitializeCriticalSection(&hostCs);
|
||||||
onAttach = onDetach = nullptr;
|
onAttach = onDetach = nullptr;
|
||||||
@ -83,17 +81,13 @@ namespace Host
|
|||||||
|
|
||||||
DLLEXPORT void Close()
|
DLLEXPORT void Close()
|
||||||
{
|
{
|
||||||
if (running)
|
EnterCriticalSection(&hostCs);
|
||||||
{
|
DestroyWindow(dummyWindow);
|
||||||
EnterCriticalSection(&hostCs);
|
RemoveThreads([](auto one, auto two) { return true; }, {});
|
||||||
running = false;
|
//for (auto i : processRecordsByIds) UnregisterProcess(i.first); // Artikash 7/24/2018 FIXME: This segfaults since UnregisterProcess invalidates the iterator
|
||||||
DestroyWindow(dummyWindow);
|
LeaveCriticalSection(&hostCs);
|
||||||
RemoveThreads([](auto one, auto two) { return true; }, {});
|
DeleteCriticalSection(&hostCs);
|
||||||
//for (auto i : processRecordsByIds) UnregisterProcess(i.first); // Artikash 7/24/2018 FIXME: This segfaults since UnregisterProcess invalidates the iterator
|
CloseHandle(preventDuplicationMutex);
|
||||||
LeaveCriticalSection(&hostCs);
|
|
||||||
DeleteCriticalSection(&hostCs);
|
|
||||||
CloseHandle(preventDuplicationMutex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DLLEXPORT bool InjectProcess(DWORD processId, DWORD timeout)
|
DLLEXPORT bool InjectProcess(DWORD processId, DWORD timeout)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user