diff --git a/GUI/extensions.cpp b/GUI/extensions.cpp index 87f1233..12b3547 100644 --- a/GUI/extensions.cpp +++ b/GUI/extensions.cpp @@ -29,7 +29,32 @@ std::map LoadExtensions() std::wstring DispatchSentenceToExtensions(std::wstring sentence, std::unordered_map miscInfo) { - for (auto extension : extensions) - extension.second(sentence, miscInfo); - return sentence; + wchar_t* sentenceBuffer = new wchar_t[sentence.size() + 1]; + wcscpy(sentenceBuffer, sentence.c_str()); + InfoForExtension* miscInfoLinkedList = new InfoForExtension; + InfoForExtension* miscInfoTraverser = miscInfoLinkedList; + for (auto i : miscInfo) + { + miscInfoTraverser->propertyName = new char[i.first.size() + 1]; + strcpy(miscInfoTraverser->propertyName, i.first.c_str()); + miscInfoTraverser->propertyValue = i.second; + miscInfoTraverser->nextProperty = new InfoForExtension; + miscInfoTraverser = miscInfoTraverser->nextProperty; + } + miscInfoTraverser->propertyName = new char[sizeof("END")]; + strcpy(miscInfoTraverser->propertyName, "END"); + miscInfoTraverser->nextProperty = nullptr; + for (auto i : extensions) + sentenceBuffer = i.second(sentenceBuffer, miscInfoLinkedList); + miscInfoTraverser = miscInfoLinkedList; + while (miscInfoTraverser != nullptr) + { + InfoForExtension* nextNode = miscInfoTraverser->nextProperty; + delete[] miscInfoTraverser->propertyName; + delete miscInfoTraverser; + miscInfoTraverser = nextNode; + } + std::wstring newSentence = std::wstring(sentenceBuffer); + delete[] sentenceBuffer; + return newSentence; } diff --git a/GUI/extensions.h b/GUI/extensions.h index 560ff4a..12f8a8f 100644 --- a/GUI/extensions.h +++ b/GUI/extensions.h @@ -10,8 +10,13 @@ std::map LoadExtensions(); std::wstring DispatchSentenceToExtensions(std::wstring sentence, std::unordered_map miscInfo); - -typedef void(*ExtensionFunction)(std::wstring&, std::unordered_map&); +struct InfoForExtension +{ + char* propertyName; + int propertyValue; + InfoForExtension* nextProperty; +}; +typedef wchar_t*(*ExtensionFunction)(wchar_t*, InfoForExtension*); extern QComboBox* ttCombo; #endif // EXTENSIONS_H diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index d88fc81..2fa7bd1 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -214,9 +214,7 @@ 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); + DeleteFileW(extenFileName.toStdWString().c_str()); extenCombo->clear(); std::map extensions = LoadExtensions(); for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ":" + i.second);