From cd3cb280d5b465b1a8f619acd115a1666dde418b Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 22 Sep 2018 17:13:06 -0400 Subject: [PATCH] move to hex for processId display and display text handles --- GUI/host/textthread.cc | 2 +- GUI/host/textthread.h | 9 +++++---- GUI/mainwindow.cpp | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/GUI/host/textthread.cc b/GUI/host/textthread.cc index 6d17de3..bd129f3 100644 --- a/GUI/host/textthread.cc +++ b/GUI/host/textthread.cc @@ -6,7 +6,7 @@ #include "host.h" #include "const.h" -TextThread::TextThread(ThreadParam tp, DWORD status) : tp(tp), status(status), name(Host::GetHookName(tp.pid, tp.hook)) {} +TextThread::TextThread(ThreadParam tp, DWORD status) : handle(ThreadCounter++), name(Host::GetHookName(tp.pid, tp.hook)), tp(tp), status(status) {} TextThread::~TextThread() { diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index f217de1..491d781 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -15,16 +15,17 @@ public: ~TextThread(); std::wstring GetStore(); + void AddText(const BYTE* data, int len); + void AddSentence(std::wstring sentence); void RegisterOutputCallBack(ThreadOutputCallback cb) { Output = cb; } - void AddText(const BYTE* data, int len); - void AddSentence(std::wstring sentence); - + const int64_t handle; const std::wstring name; const ThreadParam tp; - inline static unsigned FlushDelay = 250; // flush every 250ms by default + inline static int FlushDelay = 250; // flush every 250ms by default + inline static int ThreadCounter = 0; private: void Flush(); diff --git a/GUI/mainwindow.cpp b/GUI/mainwindow.cpp index d753b48..979eb87 100644 --- a/GUI/mainwindow.cpp +++ b/GUI/mainwindow.cpp @@ -51,7 +51,7 @@ MainWindow::~MainWindow() void MainWindow::AddProcess(unsigned int processId) { - processCombo->addItem(QString::number(processId) + ": " + GetModuleName(processId)); + processCombo->addItem(QString::number(processId, 16).toUpper() + ": " + GetModuleName(processId)); QFile file("SavedHooks.txt"); if (!file.open(QIODevice::ReadOnly)) return; QString processName = GetFullModuleName(processId); @@ -69,7 +69,7 @@ void MainWindow::AddProcess(unsigned int processId) void MainWindow::RemoveProcess(unsigned int processId) { - processCombo->removeItem(processCombo->findText(QString::number(processId) + ":", Qt::MatchStartsWith)); + processCombo->removeItem(processCombo->findText(QString::number(processId, 16).toUpper() + ":", Qt::MatchStartsWith)); } void MainWindow::AddThread(TextThread* thread) @@ -118,23 +118,23 @@ QString MainWindow::TextThreadString(TextThread* thread) { ThreadParam tp = thread->tp; return QString("%1:%2:%3:%4:%5: ").arg( - QString::number(tp.pid), + QString::number(thread->handle, 16).toUpper(), + QString::number(tp.pid, 16), QString::number(tp.hook, 16), QString::number(tp.retn, 16), - QString::number(tp.spl, 16), - QString::number((int64_t)thread, 16) + QString::number(tp.spl, 16) ).toUpper(); } ThreadParam MainWindow::ParseTextThreadString(QString textThreadString) { QStringList threadParam = textThreadString.split(":"); - return { threadParam[0].toUInt(), threadParam[1].toULongLong(nullptr, 16), threadParam[2].toULongLong(nullptr, 16), threadParam[3].toULongLong(nullptr, 16) }; + return { threadParam[1].toUInt(nullptr, 16), threadParam[2].toULongLong(nullptr, 16), threadParam[3].toULongLong(nullptr, 16), threadParam[4].toULongLong(nullptr, 16) }; } DWORD MainWindow::GetSelectedProcessId() { - return processCombo->currentText().split(":")[0].toULong(); + return processCombo->currentText().split(":")[0].toULong(nullptr, 16); } void MainWindow::ReloadExtensions() @@ -148,11 +148,11 @@ std::unordered_map MainWindow::GetInfoForExtensions(TextTh { return { - { "current select", (int64_t)ttCombo->currentText().startsWith(TextThreadString(thread)) }, - { "text number", 0 }, + { "current select", ttCombo->currentText().startsWith(TextThreadString(thread)) }, + { "text number", thread->handle }, { "process id", thread->tp.pid }, - { "hook address", (int64_t)thread->tp.hook }, - { "text handle", (int64_t)thread }, + { "hook address", thread->tp.hook }, + { "text handle", thread->handle }, { "text name", (int64_t)thread->name.c_str() } }; }