mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-24 01:14: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));
|
wchar_t* sentenceBuffer = (wchar_t*)HeapAlloc(GetProcessHeap(), 0, (sentence.size() + 1) * sizeof(wchar_t));
|
||||||
wcscpy_s(sentenceBuffer, sentence.size() + 1, sentence.c_str());
|
wcscpy_s(sentenceBuffer, sentence.size() + 1, sentence.c_str());
|
||||||
|
|
||||||
InfoForExtension miscInfoLinkedList{ "", 0, nullptr };
|
InfoForExtension miscInfoLinkedList{ "", 0, nullptr };
|
||||||
InfoForExtension* miscInfoTraverser = &miscInfoLinkedList;
|
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);
|
std::shared_lock sharedLock(extenMutex);
|
||||||
for (auto extenName : extenNames)
|
for (auto extenName : extenNames)
|
||||||
{
|
{
|
||||||
wchar_t* nextBuffer = extensions[extenName](sentenceBuffer, &miscInfoLinkedList);
|
wchar_t* nextBuffer = extensions[extenName](sentenceBuffer, &miscInfoLinkedList);
|
||||||
if (nextBuffer == nullptr) { success = false; break; }
|
|
||||||
if (nextBuffer != sentenceBuffer) HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
if (nextBuffer != sentenceBuffer) HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
||||||
|
if (nextBuffer == nullptr) return false;
|
||||||
sentenceBuffer = nextBuffer;
|
sentenceBuffer = nextBuffer;
|
||||||
}
|
}
|
||||||
sentence = sentenceBuffer;
|
sentence = sentenceBuffer;
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
HeapFree(GetProcessHeap(), 0, sentenceBuffer);
|
||||||
return success;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtenWindow::ExtenWindow(QWidget* parent) :
|
ExtenWindow::ExtenWindow(QWidget* parent) :
|
||||||
|
@ -7,7 +7,7 @@ namespace Ui
|
|||||||
class ExtenWindow;
|
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
|
class ExtenWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ DWORD MainWindow::GetSelectedProcessId()
|
|||||||
return ui->processCombo->currentText().split(":")[0].toULong(nullptr, 16);
|
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
|
return
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@ private:
|
|||||||
QString TextThreadString(TextThread* thread);
|
QString TextThreadString(TextThread* thread);
|
||||||
ThreadParam ParseTextThreadString(QString ttString);
|
ThreadParam ParseTextThreadString(QString ttString);
|
||||||
DWORD GetSelectedProcessId();
|
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 AttachProcess();
|
||||||
void DetachProcess();
|
void DetachProcess();
|
||||||
void AddHook();
|
void AddHook();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user