From 4bc0c834d7ca1fadc34d315968880d453cb5520e Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 20 Sep 2018 22:32:47 -0400 Subject: [PATCH] refactor and give extensions 64 bits --- GUI/extensions.cpp | 2 +- GUI/extensions.h | 4 ++-- GUI/host/textthread.cc | 3 ++- GUI/host/textthread.h | 5 +++-- GUI/mainwindow.cpp | 18 +++++++++--------- GUI/mainwindow.h | 2 +- extensions/extensions.h | 3 ++- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/GUI/extensions.cpp b/GUI/extensions.cpp index 3a08d11..0e8b32f 100644 --- a/GUI/extensions.cpp +++ b/GUI/extensions.cpp @@ -26,7 +26,7 @@ std::map LoadExtensions() return extensionNames; } -bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map miscInfo) +bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map miscInfo) { wchar_t* sentenceBuffer = (wchar_t*)malloc((sentence.size() + 1) * sizeof(wchar_t)); wcscpy(sentenceBuffer, sentence.c_str()); diff --git a/GUI/extensions.h b/GUI/extensions.h index 5cf12cd..c7fbc81 100644 --- a/GUI/extensions.h +++ b/GUI/extensions.h @@ -5,12 +5,12 @@ #include std::map LoadExtensions(); -bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map miscInfo); +bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map miscInfo); struct InfoForExtension { ~InfoForExtension() { if (nextProperty) delete nextProperty; }; const char* propertyName = ""; - int propertyValue = 0; + int64_t propertyValue = 0; InfoForExtension* nextProperty = nullptr; }; typedef wchar_t*(*ExtensionFunction)(const wchar_t*, const InfoForExtension*); diff --git a/GUI/host/textthread.cc b/GUI/host/textthread.cc index 0ef89f2..4136953 100644 --- a/GUI/host/textthread.cc +++ b/GUI/host/textthread.cc @@ -3,9 +3,10 @@ // Branch IHF/TextThread.cpp, rev 133 #include "textthread.h" +#include "host.h" #include "const.h" -TextThread::TextThread(ThreadParam tp, DWORD status) : tp(tp), status(status) {} +TextThread::TextThread(ThreadParam tp, DWORD status) : tp(tp), status(status), name(Host::GetHookName(tp.pid, tp.hook)) {} TextThread::~TextThread() { diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index 77cb4f4..5193bd1 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -15,13 +15,15 @@ public: ~TextThread(); std::wstring GetStore(); - ThreadParam GetThreadParam() { return tp; } void RegisterOutputCallBack(ThreadOutputCallback cb) { Output = cb; } void AddText(const BYTE* data, int len); void AddSentence(std::wstring sentence); + const std::wstring name; + const ThreadParam tp; + private: void Flush(); @@ -34,7 +36,6 @@ private: DWORD timestamp = GetTickCount(); ThreadOutputCallback Output; - ThreadParam tp; DWORD status; }; diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index 43f8128..fce32e2 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -77,9 +77,9 @@ void MainWindow::AddThread(TextThread* thread) { ttCombo->addItem( TextThreadString(thread) + - QString::fromStdWString(Host::GetHookName(thread->GetThreadParam().pid, thread->GetThreadParam().hook)) + + QString::fromStdWString(thread->name) + " (" + - GenerateCode(Host::GetHookParam(thread->GetThreadParam()), thread->GetThreadParam().pid) + + GenerateCode(Host::GetHookParam(thread->tp), thread->tp.pid) + ")" ); thread->RegisterOutputCallBack([&](TextThread* thread, std::wstring output) @@ -117,7 +117,7 @@ void MainWindow::ThreadOutput(TextThread* thread, QString output) QString MainWindow::TextThreadString(TextThread* thread) { - ThreadParam tp = thread->GetThreadParam(); + ThreadParam tp = thread->tp; return QString("%1:%2:%3:%4: ").arg( QString::number(tp.pid), QString::number(tp.hook, 16), @@ -144,16 +144,16 @@ void MainWindow::ReloadExtensions() for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ": " + i.second); } -std::unordered_map MainWindow::GetInfoForExtensions(TextThread* thread) +std::unordered_map MainWindow::GetInfoForExtensions(TextThread* thread) { return { - { "current select", (int)ttCombo->currentText().startsWith(TextThreadString(thread)) }, + { "current select", (int64_t)ttCombo->currentText().startsWith(TextThreadString(thread)) }, { "text number", 0 }, - { "process id", thread->GetThreadParam().pid }, - { "hook address", (int)thread->GetThreadParam().hook }, - { "hook address (upper 32 bits)", (int)(thread->GetThreadParam().hook >> 32) }, - { "text handle", (int)thread } + { "process id", thread->tp.pid }, + { "hook address", (int64_t)thread->tp.hook }, + { "text handle", (int64_t)thread }, + { "text name", (int64_t)thread->name.c_str() } }; } diff --git a/GUI/mainwindow.h b/GUI/mainwindow.h index 0e20e51..67bc12c 100644 --- a/GUI/mainwindow.h +++ b/GUI/mainwindow.h @@ -47,7 +47,7 @@ private: ThreadParam ParseTextThreadString(QString textThreadString); DWORD GetSelectedProcessId(); void ReloadExtensions(); - std::unordered_map GetInfoForExtensions(TextThread* thread); + std::unordered_map GetInfoForExtensions(TextThread* thread); QVector GetAllHooks(DWORD processId); Ui::MainWindow* ui; diff --git a/extensions/extensions.h b/extensions/extensions.h index 9f109a7..2951e57 100644 --- a/extensions/extensions.h +++ b/extensions/extensions.h @@ -2,12 +2,13 @@ #define WIN32_LEAN_AND_MEAN #include +#include #include struct InfoForExtension { const char* propertyName; - int propertyValue; + int64_t propertyValue; InfoForExtension* nextProperty; };