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, 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 (GetProcAddress(GetModuleHandleW(fileData.cFileName), "OnNewSentence") ||
|
||||
GetProcAddress(LoadLibraryW(fileData.cFileName), "OnNewSentence")
|
||||
)
|
||||
{
|
||||
newExtensions[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);
|
||||
QStringList files = QDir().entryList();
|
||||
for (auto file : files)
|
||||
if (file.endsWith("_nexthooker_extension.dll"))
|
||||
if (GetProcAddress(GetModuleHandleW(file.toStdWString().c_str()), "OnNewSentence") ||
|
||||
GetProcAddress(LoadLibraryW(file.toStdWString().c_str()), "OnNewSentence"))
|
||||
{
|
||||
QString extensionNumber = file.split("_")[0];
|
||||
newExtensions[extensionNumber.toInt()] = (ExtensionFunction)GetProcAddress(GetModuleHandleW(file.toStdWString().c_str()), "OnNewSentence");
|
||||
file.chop(sizeof("_nexthooker_extension.dll") - 1);
|
||||
file.remove(0, extensionNumber.length() + 1);
|
||||
extensionNames[extensionNumber.toInt()] = file;
|
||||
}
|
||||
while (processing) Sleep(10);
|
||||
processing = -1;
|
||||
extensions = newExtensions;
|
||||
|
@ -103,7 +103,7 @@ void MainWindow::AddThread(TextThread* thread)
|
||||
{
|
||||
ttCombo->addItem(
|
||||
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) +
|
||||
")"
|
||||
@ -112,7 +112,7 @@ void MainWindow::AddThread(TextThread* thread)
|
||||
{
|
||||
output = DispatchSentenceToExtensions(output, GetInfoForExtensions(thread));
|
||||
output += L"\r\n";
|
||||
emit ThreadOutputReceived(thread, QString::fromWCharArray(output.c_str()));
|
||||
emit ThreadOutputReceived(thread, QString::fromStdWString(output));
|
||||
return output;
|
||||
});
|
||||
}
|
||||
@ -205,7 +205,7 @@ void MainWindow::on_unhookButton_clicked()
|
||||
QVector<HookParam> hooks = GetAllHooks(processCombo->currentText().split(":")[0].toInt());
|
||||
QStringList hookList;
|
||||
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())
|
||||
);
|
||||
@ -250,6 +250,6 @@ void MainWindow::on_rmvExtenButton_clicked()
|
||||
if (extenCombo->currentText().size() == 0) return;
|
||||
QString extenFileName = extenCombo->currentText().split(":")[0] + "_" + extenCombo->currentText().split(": ")[1] + "_nexthooker_extension.dll";
|
||||
FreeLibrary(GetModuleHandleW(extenFileName.toStdWString().c_str()));
|
||||
DeleteFileW(extenFileName.toStdWString().c_str());
|
||||
QFile::remove(extenFileName);
|
||||
ReloadExtensions();
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ extern "C"
|
||||
if (WinHttpSendRequest(request, NULL, 0, NULL, 0, 0, NULL))
|
||||
{
|
||||
DWORD bytesRead;
|
||||
char buffer[100000]; // Google Translate page is ~64kb
|
||||
char buffer[100000] = {}; // Google Translate page is ~64kb
|
||||
WinHttpReceiveResponse(request, NULL);
|
||||
WinHttpReadData(request, buffer, 100000, &bytesRead);
|
||||
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))
|
||||
{
|
||||
DWORD bytesRead;
|
||||
char buffer[0x10000] = {};
|
||||
char buffer[10000] = {};
|
||||
WinHttpReceiveResponse(request, NULL);
|
||||
WinHttpReadData(request, buffer, 0x10000, &bytesRead);
|
||||
WinHttpReadData(request, buffer, 10000, &bytesRead);
|
||||
// Response formatted as JSON: starts with '[[["'
|
||||
MultiByteToWideChar(CP_UTF8, 0, buffer + 4, (int)((strstr(buffer, "\",\"")) - (buffer + 4)), translation, 10000);
|
||||
message = translation;
|
||||
|
Loading…
Reference in New Issue
Block a user