From ff2fc74c5ac76bd4720419c6003d56888b1bb4b7 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sun, 29 Jul 2018 14:36:45 -0700 Subject: [PATCH] change abi to be C compatible --- GUI/extensions.cpp | 31 ++++++++++++++++++++++++++++--- GUI/extensions.h | 9 +++++++-- GUI/mainwindow.cpp | 4 +--- 3 files changed, 36 insertions(+), 8 deletions(-) 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);