refactor and give extensions 64 bits

This commit is contained in:
Akash Mozumdar 2018-09-20 22:32:47 -04:00
parent e2f83d47b9
commit 4bc0c834d7
7 changed files with 20 additions and 17 deletions

View File

@ -26,7 +26,7 @@ std::map<int, QString> LoadExtensions()
return extensionNames; return extensionNames;
} }
bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std::string, int> miscInfo) bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std::string, int64_t> miscInfo)
{ {
wchar_t* sentenceBuffer = (wchar_t*)malloc((sentence.size() + 1) * sizeof(wchar_t)); wchar_t* sentenceBuffer = (wchar_t*)malloc((sentence.size() + 1) * sizeof(wchar_t));
wcscpy(sentenceBuffer, sentence.c_str()); wcscpy(sentenceBuffer, sentence.c_str());

View File

@ -5,12 +5,12 @@
#include <map> #include <map>
std::map<int, QString> LoadExtensions(); std::map<int, QString> LoadExtensions();
bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std::string, int> miscInfo); bool DispatchSentenceToExtensions(std::wstring& sentence, std::unordered_map<std::string, int64_t> miscInfo);
struct InfoForExtension struct InfoForExtension
{ {
~InfoForExtension() { if (nextProperty) delete nextProperty; }; ~InfoForExtension() { if (nextProperty) delete nextProperty; };
const char* propertyName = ""; const char* propertyName = "";
int propertyValue = 0; int64_t propertyValue = 0;
InfoForExtension* nextProperty = nullptr; InfoForExtension* nextProperty = nullptr;
}; };
typedef wchar_t*(*ExtensionFunction)(const wchar_t*, const InfoForExtension*); typedef wchar_t*(*ExtensionFunction)(const wchar_t*, const InfoForExtension*);

View File

@ -3,9 +3,10 @@
// Branch IHF/TextThread.cpp, rev 133 // Branch IHF/TextThread.cpp, rev 133
#include "textthread.h" #include "textthread.h"
#include "host.h"
#include "const.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() TextThread::~TextThread()
{ {

View File

@ -15,13 +15,15 @@ public:
~TextThread(); ~TextThread();
std::wstring GetStore(); std::wstring GetStore();
ThreadParam GetThreadParam() { return tp; }
void RegisterOutputCallBack(ThreadOutputCallback cb) { Output = cb; } void RegisterOutputCallBack(ThreadOutputCallback cb) { Output = cb; }
void AddText(const BYTE* data, int len); void AddText(const BYTE* data, int len);
void AddSentence(std::wstring sentence); void AddSentence(std::wstring sentence);
const std::wstring name;
const ThreadParam tp;
private: private:
void Flush(); void Flush();
@ -34,7 +36,6 @@ private:
DWORD timestamp = GetTickCount(); DWORD timestamp = GetTickCount();
ThreadOutputCallback Output; ThreadOutputCallback Output;
ThreadParam tp;
DWORD status; DWORD status;
}; };

View File

@ -77,9 +77,9 @@ void MainWindow::AddThread(TextThread* thread)
{ {
ttCombo->addItem( ttCombo->addItem(
TextThreadString(thread) + 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) thread->RegisterOutputCallBack([&](TextThread* thread, std::wstring output)
@ -117,7 +117,7 @@ void MainWindow::ThreadOutput(TextThread* thread, QString output)
QString MainWindow::TextThreadString(TextThread* thread) QString MainWindow::TextThreadString(TextThread* thread)
{ {
ThreadParam tp = thread->GetThreadParam(); ThreadParam tp = thread->tp;
return QString("%1:%2:%3:%4: ").arg( return QString("%1:%2:%3:%4: ").arg(
QString::number(tp.pid), QString::number(tp.pid),
QString::number(tp.hook, 16), QString::number(tp.hook, 16),
@ -144,16 +144,16 @@ void MainWindow::ReloadExtensions()
for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ": " + i.second); for (auto i : extensions) extenCombo->addItem(QString::number(i.first) + ": " + i.second);
} }
std::unordered_map<std::string, int> MainWindow::GetInfoForExtensions(TextThread* thread) std::unordered_map<std::string, int64_t> MainWindow::GetInfoForExtensions(TextThread* thread)
{ {
return return
{ {
{ "current select", (int)ttCombo->currentText().startsWith(TextThreadString(thread)) }, { "current select", (int64_t)ttCombo->currentText().startsWith(TextThreadString(thread)) },
{ "text number", 0 }, { "text number", 0 },
{ "process id", thread->GetThreadParam().pid }, { "process id", thread->tp.pid },
{ "hook address", (int)thread->GetThreadParam().hook }, { "hook address", (int64_t)thread->tp.hook },
{ "hook address (upper 32 bits)", (int)(thread->GetThreadParam().hook >> 32) }, { "text handle", (int64_t)thread },
{ "text handle", (int)thread } { "text name", (int64_t)thread->name.c_str() }
}; };
} }

View File

@ -47,7 +47,7 @@ private:
ThreadParam ParseTextThreadString(QString textThreadString); ThreadParam ParseTextThreadString(QString textThreadString);
DWORD GetSelectedProcessId(); DWORD GetSelectedProcessId();
void ReloadExtensions(); void ReloadExtensions();
std::unordered_map<std::string, int> GetInfoForExtensions(TextThread* thread); std::unordered_map<std::string, int64_t> GetInfoForExtensions(TextThread* thread);
QVector<HookParam> GetAllHooks(DWORD processId); QVector<HookParam> GetAllHooks(DWORD processId);
Ui::MainWindow* ui; Ui::MainWindow* ui;

View File

@ -2,12 +2,13 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
#include <cstdint>
#include <string> #include <string>
struct InfoForExtension struct InfoForExtension
{ {
const char* propertyName; const char* propertyName;
int propertyValue; int64_t propertyValue;
InfoForExtension* nextProperty; InfoForExtension* nextProperty;
}; };