diff --git a/GUI/extenwindow.cpp b/GUI/extenwindow.cpp index e1f9f22..1f3c4a3 100644 --- a/GUI/extenwindow.cpp +++ b/GUI/extenwindow.cpp @@ -65,13 +65,13 @@ namespace } } -bool DispatchSentenceToExtensions(std::wstring& sentence, const InfoForExtension* miscInfo) +bool DispatchSentenceToExtensions(std::wstring& sentence, const InfoForExtension* sentenceInfo) { wchar_t* sentenceBuffer = (wchar_t*)HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, (sentence.size() + 1) * sizeof(wchar_t)); wcscpy_s(sentenceBuffer, sentence.size() + 1, sentence.c_str()); concurrency::reader_writer_lock::scoped_lock_read readLock(extenMutex); for (const auto& extension : extensions) - if (*(sentenceBuffer = extension.callback(sentenceBuffer, miscInfo)) == L'\0') break; + if (*(sentenceBuffer = extension.callback(sentenceBuffer, sentenceInfo)) == L'\0') break; sentence = sentenceBuffer; HeapFree(GetProcessHeap(), 0, sentenceBuffer); return !sentence.empty(); diff --git a/GUI/extenwindow.h b/GUI/extenwindow.h index f5cf143..a5a3f5f 100644 --- a/GUI/extenwindow.h +++ b/GUI/extenwindow.h @@ -13,7 +13,7 @@ struct InfoForExtension int64_t value; }; -bool DispatchSentenceToExtensions(std::wstring& sentence, const InfoForExtension* miscInfo); +bool DispatchSentenceToExtensions(std::wstring& sentence, const InfoForExtension* sentenceInfo); void CleanupExtensions(); // must call this before exiting the program, only way to uphold guarantee that DllMain and OnNewSentence won't be called concurrently class ExtenWindow : public QMainWindow diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index f4c4980..8a7cc62 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -208,7 +208,7 @@ void MainWindow::ThreadRemoved(TextThread& thread) bool MainWindow::SentenceReceived(TextThread& thread, std::wstring& sentence) { - if (!DispatchSentenceToExtensions(sentence, GetMiscInfo(thread).data())) return false; + if (!DispatchSentenceToExtensions(sentence, GetSentenceInfo(thread).data())) return false; sentence += L'\n'; if (current == &thread) QMetaObject::invokeMethod(this, [this, sentence] { @@ -248,7 +248,7 @@ DWORD MainWindow::GetSelectedProcessId() return ui->processCombo->currentText().split(":")[0].toULong(nullptr, 16); } -std::array MainWindow::GetMiscInfo(TextThread& thread) +std::array MainWindow::GetSentenceInfo(TextThread& thread) { void(*AddSentence)(MainWindow*, int64_t, const wchar_t*) = [](MainWindow* This, int64_t number, const wchar_t* sentence) { diff --git a/GUI/mainwindow.h b/GUI/mainwindow.h index 89de329..ce998a0 100644 --- a/GUI/mainwindow.h +++ b/GUI/mainwindow.h @@ -31,7 +31,7 @@ private: QString TextThreadString(TextThread& thread); ThreadParam ParseTextThreadString(QString ttString); DWORD GetSelectedProcessId(); - std::array GetMiscInfo(TextThread& thread); + std::array GetSentenceInfo(TextThread& thread); std::optional UserSelectedProcess(); void AttachProcess(); void LaunchProcess(); diff --git a/extensions/extensionimpl.cpp b/extensions/extensionimpl.cpp index 8decc99..366045f 100644 --- a/extensions/extensionimpl.cpp +++ b/extensions/extensionimpl.cpp @@ -8,18 +8,18 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo); This can be modified. Textractor uses the modified sentence for future processing and display. If empty (starts with null terminator), Textractor will destroy it. Textractor will display the sentence after all extensions have had a chance to process and/or modify it. The buffer is allocated using HeapAlloc(). If you want to make it larger, please use HeapReAlloc(). - Param miscInfo: pointer to array containing misc info about the sentence. End of array is marked with name being nullptr. + Param sentenceInfo: pointer to array containing misc info about the sentence. End of array is marked with name being nullptr. Return value: the buffer used for the sentence. Remember to return a new pointer if HeapReAlloc() gave you one. This function may be run concurrently with itself: please make sure it's thread safe. It will not be run concurrently with DllMain. */ -extern "C" __declspec(dllexport) wchar_t* OnNewSentence(wchar_t* sentence, const InfoForExtension* miscInfo) +extern "C" __declspec(dllexport) wchar_t* OnNewSentence(wchar_t* sentence, const InfoForExtension* sentenceInfo) { try { std::wstring sentenceStr(sentence); int origLength = sentenceStr.size(); - if (ProcessSentence(sentenceStr, SentenceInfo{ miscInfo })) + if (ProcessSentence(sentenceStr, SentenceInfo{ sentenceInfo })) { if (sentenceStr.size() > origLength) sentence = (wchar_t*)HeapReAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sentence, (sentenceStr.size() + 1) * sizeof(wchar_t)); wcscpy_s(sentence, sentenceStr.size() + 1, sentenceStr.c_str());