mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-23 08:54:12 +08:00
optimize dispatchsentence
This commit is contained in:
parent
f080656e60
commit
3dd7be65ff
@ -54,28 +54,27 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std::string, int64_t> miscInfo)
|
||||
bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<const char*, int64_t> miscInfo)
|
||||
{
|
||||
bool success = true;
|
||||
wchar_t* sentenceBuffer = (wchar_t*)HeapAlloc(GetProcessHeap(), 0, (sentence.size() + 1) * sizeof(wchar_t));
|
||||
wcscpy_s(sentenceBuffer, sentence.size() + 1, sentence.c_str());
|
||||
|
||||
InfoForExtension miscInfoLinkedList{ "", 0, nullptr };
|
||||
InfoForExtension* miscInfoTraverser = &miscInfoLinkedList;
|
||||
for (auto& i : miscInfo) miscInfoTraverser = miscInfoTraverser->next = new InfoForExtension{ i.first.c_str(), i.second, nullptr };
|
||||
for (auto[name, value] : miscInfo) miscInfoTraverser = miscInfoTraverser->next = new InfoForExtension{ name, value, nullptr };
|
||||
|
||||
std::shared_lock sharedLock(extenMutex);
|
||||
for (auto extenName : extenNames)
|
||||
{
|
||||
wchar_t* nextBuffer = extensions[extenName](sentenceBuffer, &miscInfoLinkedList);
|
||||
if (nextBuffer == nullptr) { success = false; break; }
|
||||
if (nextBuffer != sentenceBuffer) HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
||||
if (nextBuffer == nullptr) return false;
|
||||
sentenceBuffer = nextBuffer;
|
||||
}
|
||||
sentence = sentenceBuffer;
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
||||
return success;
|
||||
return true;
|
||||
}
|
||||
|
||||
ExtenWindow::ExtenWindow(QWidget* parent) :
|
||||
|
@ -7,7 +7,7 @@ namespace Ui
|
||||
class ExtenWindow;
|
||||
}
|
||||
|
||||
bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std::string, int64_t> miscInfo);
|
||||
bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<const char*, int64_t> miscInfo);
|
||||
|
||||
class ExtenWindow : public QMainWindow
|
||||
{
|
||||
|
@ -169,7 +169,7 @@ DWORD MainWindow::GetSelectedProcessId()
|
||||
return ui->processCombo->currentText().split(":")[0].toULong(nullptr, 16);
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, int64_t> MainWindow::GetMiscInfo(TextThread* thread)
|
||||
std::unordered_map<const char*, int64_t> MainWindow::GetMiscInfo(TextThread* thread)
|
||||
{
|
||||
return
|
||||
{
|
||||
|
@ -24,7 +24,7 @@ private:
|
||||
QString TextThreadString(TextThread* thread);
|
||||
ThreadParam ParseTextThreadString(QString ttString);
|
||||
DWORD GetSelectedProcessId();
|
||||
std::unordered_map<std::string, int64_t> GetMiscInfo(TextThread* thread);
|
||||
std::unordered_map<const char*, int64_t> GetMiscInfo(TextThread* thread);
|
||||
void AttachProcess();
|
||||
void DetachProcess();
|
||||
void AddHook();
|
||||
|
Loading…
x
Reference in New Issue
Block a user