misc refactors
This commit is contained in:
parent
3f7a0fdd52
commit
91ac0825f8
@ -9,22 +9,18 @@ std::map<int, QString> LoadExtensions()
|
|||||||
{
|
{
|
||||||
std::map<int, ExtensionFunction> newExtensions;
|
std::map<int, ExtensionFunction> newExtensions;
|
||||||
std::map<int, QString> extensionNames;
|
std::map<int, QString> extensionNames;
|
||||||
wchar_t path[MAX_PATH] = {};
|
QStringList files = QDir().entryList();
|
||||||
(QDir::currentPath() + "/*_nexthooker_extension.dll").toWCharArray(path);
|
for (auto file : files)
|
||||||
WIN32_FIND_DATAW fileData;
|
if (file.endsWith("_nexthooker_extension.dll"))
|
||||||
HANDLE file = FindFirstFileW(path, &fileData);
|
if (GetProcAddress(GetModuleHandleW(file.toStdWString().c_str()), "OnNewSentence") ||
|
||||||
do
|
GetProcAddress(LoadLibraryW(file.toStdWString().c_str()), "OnNewSentence"))
|
||||||
if (GetProcAddress(GetModuleHandleW(fileData.cFileName), "OnNewSentence") ||
|
{
|
||||||
GetProcAddress(LoadLibraryW(fileData.cFileName), "OnNewSentence")
|
QString extensionNumber = file.split("_")[0];
|
||||||
)
|
newExtensions[extensionNumber.toInt()] = (ExtensionFunction)GetProcAddress(GetModuleHandleW(file.toStdWString().c_str()), "OnNewSentence");
|
||||||
{
|
file.chop(sizeof("_nexthooker_extension.dll") - 1);
|
||||||
newExtensions[std::wcstol(fileData.cFileName, nullptr, 10)] = (ExtensionFunction)GetProcAddress(GetModuleHandleW(fileData.cFileName), "OnNewSentence");
|
file.remove(0, extensionNumber.length() + 1);
|
||||||
QString name = QString::fromWCharArray(fileData.cFileName);
|
extensionNames[extensionNumber.toInt()] = file;
|
||||||
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);
|
|
||||||
while (processing) Sleep(10);
|
while (processing) Sleep(10);
|
||||||
processing = -1;
|
processing = -1;
|
||||||
extensions = newExtensions;
|
extensions = newExtensions;
|
||||||
|
@ -103,7 +103,7 @@ void MainWindow::AddThread(TextThread* thread)
|
|||||||
{
|
{
|
||||||
ttCombo->addItem(
|
ttCombo->addItem(
|
||||||
TextThreadString(thread) +
|
TextThreadString(thread) +
|
||||||
QString::fromWCharArray(Host::GetHookName(thread->GetThreadParameter().pid, thread->GetThreadParameter().hook).c_str()) +
|
QString::fromStdWString(Host::GetHookName(thread->GetThreadParameter().pid, thread->GetThreadParameter().hook)) +
|
||||||
" (" +
|
" (" +
|
||||||
GenerateCode(Host::GetHookParam(thread->GetThreadParameter().pid, thread->GetThreadParameter().hook), thread->GetThreadParameter().pid) +
|
GenerateCode(Host::GetHookParam(thread->GetThreadParameter().pid, thread->GetThreadParameter().hook), thread->GetThreadParameter().pid) +
|
||||||
")"
|
")"
|
||||||
@ -112,7 +112,7 @@ void MainWindow::AddThread(TextThread* thread)
|
|||||||
{
|
{
|
||||||
output = DispatchSentenceToExtensions(output, GetInfoForExtensions(thread));
|
output = DispatchSentenceToExtensions(output, GetInfoForExtensions(thread));
|
||||||
output += L"\r\n";
|
output += L"\r\n";
|
||||||
emit ThreadOutputReceived(thread, QString::fromWCharArray(output.c_str()));
|
emit ThreadOutputReceived(thread, QString::fromStdWString(output));
|
||||||
return output;
|
return output;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ void MainWindow::on_unhookButton_clicked()
|
|||||||
QVector<HookParam> hooks = GetAllHooks(processCombo->currentText().split(":")[0].toInt());
|
QVector<HookParam> hooks = GetAllHooks(processCombo->currentText().split(":")[0].toInt());
|
||||||
QStringList hookList;
|
QStringList hookList;
|
||||||
for (auto i : hooks) hookList.push_back(
|
for (auto i : hooks) hookList.push_back(
|
||||||
QString::fromWCharArray(Host::GetHookName(processCombo->currentText().split(":")[0].toInt(), i.address).c_str()) +
|
QString::fromStdWString(Host::GetHookName(processCombo->currentText().split(":")[0].toInt(), i.address)) +
|
||||||
": " +
|
": " +
|
||||||
GenerateCode(i, processCombo->currentText().split(":")[0].toInt())
|
GenerateCode(i, processCombo->currentText().split(":")[0].toInt())
|
||||||
);
|
);
|
||||||
@ -250,6 +250,6 @@ void MainWindow::on_rmvExtenButton_clicked()
|
|||||||
if (extenCombo->currentText().size() == 0) return;
|
if (extenCombo->currentText().size() == 0) return;
|
||||||
QString extenFileName = extenCombo->currentText().split(":")[0] + "_" + extenCombo->currentText().split(": ")[1] + "_nexthooker_extension.dll";
|
QString extenFileName = extenCombo->currentText().split(":")[0] + "_" + extenCombo->currentText().split(": ")[1] + "_nexthooker_extension.dll";
|
||||||
FreeLibrary(GetModuleHandleW(extenFileName.toStdWString().c_str()));
|
FreeLibrary(GetModuleHandleW(extenFileName.toStdWString().c_str()));
|
||||||
DeleteFileW(extenFileName.toStdWString().c_str());
|
QFile::remove(extenFileName);
|
||||||
ReloadExtensions();
|
ReloadExtensions();
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ extern "C"
|
|||||||
if (WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, NULL))
|
if (WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, NULL))
|
||||||
{
|
{
|
||||||
DWORD bytesRead;
|
DWORD bytesRead;
|
||||||
char buffer[100000]; // Google Translate page is ~64kb
|
char buffer[100000] = {}; // Google Translate page is ~64kb
|
||||||
WinHttpReceiveResponse(request, NULL);
|
WinHttpReceiveResponse(request, NULL);
|
||||||
WinHttpReadData(request, buffer, 100000, &bytesRead);
|
WinHttpReadData(request, buffer, 100000, &bytesRead);
|
||||||
TKK = strtoll(strstr(buffer, "a\\x3d") + 5, nullptr, 10) + strtoll(strstr(buffer, "b\\x3d") + 5, nullptr, 10);
|
TKK = strtoll(strstr(buffer, "a\\x3d") + 5, nullptr, 10) + strtoll(strstr(buffer, "b\\x3d") + 5, nullptr, 10);
|
||||||
@ -76,9 +76,9 @@ extern "C"
|
|||||||
if (WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, NULL))
|
if (WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, NULL))
|
||||||
{
|
{
|
||||||
DWORD bytesRead;
|
DWORD bytesRead;
|
||||||
char buffer[0x10000] = {};
|
char buffer[10000] = {};
|
||||||
WinHttpReceiveResponse(request, NULL);
|
WinHttpReceiveResponse(request, NULL);
|
||||||
WinHttpReadData(request, buffer, 0x10000, &bytesRead);
|
WinHttpReadData(request, buffer, 10000, &bytesRead);
|
||||||
// Response formatted as JSON: starts with '[[["'
|
// Response formatted as JSON: starts with '[[["'
|
||||||
MultiByteToWideChar(CP_UTF8, 0, buffer + 4, (int)((strstr(buffer, "\",\"")) - (buffer + 4)), translation, 10000);
|
MultiByteToWideChar(CP_UTF8, 0, buffer + 4, (int)((strstr(buffer, "\",\"")) - (buffer + 4)), translation, 10000);
|
||||||
message = translation;
|
message = translation;
|
||||||
|
Loading…
Reference in New Issue
Block a user