mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 08:54:12 +08:00
(almost) finish implementing gui
This commit is contained in:
parent
5fbf92bc07
commit
4acd030e54
@ -1,32 +1,35 @@
|
||||
#include "extensions.h"
|
||||
#include <map>
|
||||
#include <QDir>
|
||||
|
||||
std::map<int, ExtensionFunction> extensions;
|
||||
|
||||
std::map<int, std::wstring> LoadExtensions()
|
||||
std::map<int, QString> LoadExtensions()
|
||||
{
|
||||
std::map<int, std::wstring> extensionNames;
|
||||
wchar_t path[MAX_PATH];
|
||||
wchar_t* end = path + GetModuleFileNameW(nullptr, path, MAX_PATH);
|
||||
while (*(--end) != L'\\');
|
||||
*(end + 1) = L'*';
|
||||
*(end + 2) = L'\0';
|
||||
extensions = std::map<int, ExtensionFunction>();
|
||||
std::map<int, QString> extensionNames;
|
||||
wchar_t path[MAX_PATH] = {};
|
||||
(QDir::currentPath() + "/*_nexthooker_extension.dll").toWCharArray(path);
|
||||
WIN32_FIND_DATAW fileData;
|
||||
HANDLE file = FindFirstFileW(path, &fileData);
|
||||
do
|
||||
if (!(fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
||||
if (wcsstr(fileData.cFileName, L"_nexthooker_extension.dll"))
|
||||
if (GetProcAddress(LoadLibraryW(fileData.cFileName), "OnNewSentence"))
|
||||
{
|
||||
extensions[std::wcstol(fileData.cFileName, nullptr, 10)] = (ExtensionFunction)GetProcAddress(LoadLibraryW(fileData.cFileName), "OnNewSentence");
|
||||
extensionNames[std::wcstol(fileData.cFileName, nullptr, 10)] = fileData.cFileName;
|
||||
}
|
||||
if (GetProcAddress(GetModuleHandleW(fileData.cFileName), "OnNewSentence") ||
|
||||
GetProcAddress(LoadLibraryW(fileData.cFileName), "OnNewSentence")
|
||||
)
|
||||
{
|
||||
extensions[std::wcstol(fileData.cFileName, nullptr, 10)] = (ExtensionFunction)GetProcAddress(GetModuleHandleW(fileData.cFileName), "OnNewSentence");
|
||||
QString name = QString::fromWCharArray(fileData.cFileName);
|
||||
name.chop(sizeof("_nexthooker_extension.dll") - 1);
|
||||
name.remove(0, name.split("_")[0].length() + 1);
|
||||
extensionNames[std::wcstol(fileData.cFileName, nullptr, 10)] = name;
|
||||
}
|
||||
while (FindNextFileW(file, &fileData) != 0);
|
||||
return extensionNames;
|
||||
}
|
||||
|
||||
std::wstring DispatchSentenceToExtensions(std::wstring sentence, std::unordered_map<std::string, int> miscInfo)
|
||||
{
|
||||
for (auto extension : extensions) sentence = extension.second(sentence, miscInfo);
|
||||
for (auto extension : extensions)
|
||||
extension.second(sentence, miscInfo);
|
||||
return sentence;
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include <vector>
|
||||
#include <QComboBox>
|
||||
|
||||
std::map<int, std::wstring> LoadExtensions();
|
||||
std::map<int, QString> LoadExtensions();
|
||||
std::wstring DispatchSentenceToExtensions(std::wstring sentence, std::unordered_map<std::string, int> miscInfo);
|
||||
|
||||
typedef std::wstring(*ExtensionFunction)(std::wstring, std::unordered_map<std::string, int>&);
|
||||
typedef void(*ExtensionFunction)(std::wstring&, std::unordered_map<std::string, int>&);
|
||||
extern QComboBox* ttCombo;
|
||||
|
||||
#endif // EXTENSIONS_H
|
||||
|
@ -62,8 +62,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(hostSignaller, &HostSignaller::AddThread, this, &MainWindow::AddThread);
|
||||
connect(hostSignaller, &HostSignaller::RemoveThread, this, &MainWindow::RemoveThread);
|
||||
connect(hostSignaller, &HostSignaller::ThreadOutput, this, &MainWindow::ThreadOutput);
|
||||
std::map<int, std::wstring> extensions = LoadExtensions();
|
||||
for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ":" + QString::fromWCharArray(i.second.c_str()));
|
||||
std::map<int, QString> extensions = LoadExtensions();
|
||||
for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ":" + i.second);
|
||||
Host::Open();
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ void MainWindow::on_hookButton_clicked()
|
||||
{
|
||||
bool ok;
|
||||
QString hookCode = QInputDialog::getText(this, "Add Hook",
|
||||
"Enter hook code\r\n/H{A|B|W|S|Q}[N][data_offset[*drdo]][:sub_offset[*drso]]@addr[:module]",
|
||||
"Enter hook code\r\n/H{A|B|W|S|Q}[N]data_offset[*drdo][:sub_offset[*drso]]@addr[:module]",
|
||||
QLineEdit::Normal, "/H", &ok
|
||||
);
|
||||
if (ok) Host::InsertHook(processCombo->currentText().split(":")[0].toInt(), ParseHCode(hookCode));
|
||||
@ -197,6 +197,27 @@ void MainWindow::on_ttCombo_activated(int index)
|
||||
|
||||
void MainWindow::on_addExtenButton_clicked()
|
||||
{
|
||||
QFileDialog extenSelector;
|
||||
|
||||
QString extenFileName = QFileDialog::getOpenFileName(this, "Select extension dll", "C:\\", "Extensions (*.dll)");
|
||||
if (!extenFileName.length()) return;
|
||||
QString extenName = extenFileName.split("/")[extenFileName.split("/").count() - 1];
|
||||
extenName.chop(4);
|
||||
QString copyTo = QString::number(extenCombo->itemText(extenCombo->count() - 1).split(":")[0].toInt() + 1) + "_" +
|
||||
extenName +
|
||||
"_nexthooker_extension.dll";
|
||||
QFile::copy(extenFileName, copyTo);
|
||||
extenCombo->clear();
|
||||
std::map<int, QString> extensions = LoadExtensions();
|
||||
for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ":" + i.second);
|
||||
}
|
||||
|
||||
void MainWindow::on_rmvExtenButton_clicked()
|
||||
{
|
||||
QString extenFileName = extenCombo->currentText().split(":")[0] + "_" + extenCombo->currentText().split(":")[1] + "_nexthooker_extension.dll";
|
||||
FreeLibrary(GetModuleHandleW(extenFileName.toStdWString().c_str()));
|
||||
QString disabledFileName = extenFileName;
|
||||
disabledFileName.replace("extension", "disabled_extension");
|
||||
QFile::rename(extenFileName, disabledFileName);
|
||||
extenCombo->clear();
|
||||
std::map<int, QString> extensions = LoadExtensions();
|
||||
for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ":" + i.second);
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ private slots:
|
||||
void on_saveButton_clicked();
|
||||
void on_addExtenButton_clicked();
|
||||
|
||||
void on_rmvExtenButton_clicked();
|
||||
|
||||
private:
|
||||
QVector<HookParam> GetAllHooks(DWORD processId);
|
||||
|
||||
|
@ -191,16 +191,9 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="enableExtenButton">
|
||||
<widget class="QPushButton" name="rmvExtenButton">
|
||||
<property name="text">
|
||||
<string>Enable extension</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="disableExtenButton">
|
||||
<property name="text">
|
||||
<string>Disable extension</string>
|
||||
<string>Remove extension</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -98,7 +98,7 @@ namespace Host
|
||||
CloseHandle(CreateMutexW(nullptr, FALSE, (ITH_HOOKMAN_MUTEX_ + std::to_wstring(processId)).c_str()));
|
||||
if (GetLastError() == ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
AddConsoleOutput(L"already locked");
|
||||
AddConsoleOutput(L"already injected");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user