This commit is contained in:
Akash Mozumdar 2018-08-25 16:02:16 -04:00
parent 2be762b708
commit 3f35c5c230
3 changed files with 190 additions and 188 deletions

View File

@ -27,10 +27,10 @@ std::wstring TextThread::GetStore()
return storage; return storage;
} }
bool TextThread::Flush() void TextThread::Flush()
{ {
LOCK ttLock(ttMutex); LOCK ttLock(ttMutex);
if (timestamp - GetTickCount() < 250 || buffer.size() == 0) return true; // TODO: let user change delay before sentence is flushed if (timestamp - GetTickCount() < 250 || buffer.size() == 0) return; // TODO: let user change delay before sentence is flushed
std::wstring sentence; std::wstring sentence;
if (status & USING_UNICODE) if (status & USING_UNICODE)
{ {
@ -44,7 +44,6 @@ bool TextThread::Flush()
} }
AddSentence(sentence); AddSentence(sentence);
buffer.clear(); buffer.clear();
return true;
} }
void TextThread::AddSentence(std::wstring sentence) void TextThread::AddSentence(std::wstring sentence)

View File

@ -24,7 +24,7 @@ public:
void AddSentence(std::wstring sentence); void AddSentence(std::wstring sentence);
private: private:
bool Flush(); void Flush();
std::vector<char> buffer; std::vector<char> buffer;
std::wstring storage; std::wstring storage;

View File

@ -30,16 +30,18 @@ std::unordered_map<std::wstring, DWORD> GetAllProcesses()
return ret; return ret;
} }
DWORD Hash(QString module) namespace
{ {
DWORD Hash(QString module)
{
module = module.toLower(); module = module.toLower();
DWORD hash = 0; DWORD hash = 0;
for (auto i : module) hash = _rotr(hash, 7) + i.unicode(); for (auto i : module) hash = _rotr(hash, 7) + i.unicode();
return hash; return hash;
} }
std::optional<HookParam> ParseRCode(QString RCode) std::optional<HookParam> ParseRCode(QString RCode)
{ {
HookParam hp = {}; HookParam hp = {};
hp.type |= DIRECT_READ; hp.type |= DIRECT_READ;
switch (RCode.at(0).unicode()) switch (RCode.at(0).unicode())
@ -66,10 +68,10 @@ std::optional<HookParam> ParseRCode(QString RCode)
if (address.indexIn(RCode) == -1) return {}; if (address.indexIn(RCode) == -1) return {};
hp.address = address.cap(0).toULongLong(nullptr, 16); hp.address = address.cap(0).toULongLong(nullptr, 16);
return hp; return hp;
} }
std::optional<HookParam> ParseHCode(QString HCode) std::optional<HookParam> ParseHCode(QString HCode)
{ {
HookParam hp = {}; HookParam hp = {};
switch (HCode.at(0).unicode()) switch (HCode.at(0).unicode())
{ {
@ -143,18 +145,10 @@ std::optional<HookParam> ParseHCode(QString HCode)
if (hp.split < 0) if (hp.split < 0)
hp.split -= 4; hp.split -= 4;
return hp; return hp;
} }
std::optional<HookParam> ParseCode(QString code) QString GenerateHCode(HookParam hp, DWORD processId)
{ {
code = code.toUpper();
if (code.startsWith("/H")) return ParseHCode(code.remove(0, 2));
else if (code.startsWith("/R")) return ParseRCode(code.remove(0, 2));
else return {};
}
QString GenerateHCode(HookParam hp, DWORD processId)
{
QString code = "/H"; QString code = "/H";
if (hp.type & USING_UNICODE) if (hp.type & USING_UNICODE)
{ {
@ -215,10 +209,10 @@ QString GenerateHCode(HookParam hp, DWORD processId)
code = code.toUpper(); code = code.toUpper();
code += moduleName; code += moduleName;
return code; return code;
} }
QString GenerateRCode(HookParam hp) QString GenerateRCode(HookParam hp)
{ {
QString code = "/R"; QString code = "/R";
if (hp.type & USING_UNICODE) if (hp.type & USING_UNICODE)
code += "Q"; code += "Q";
@ -230,6 +224,15 @@ QString GenerateRCode(HookParam hp)
code += "@"; code += "@";
code += QString::number(hp.address, 16); code += QString::number(hp.address, 16);
return code.toUpper(); return code.toUpper();
}
}
std::optional<HookParam> ParseCode(QString code)
{
code = code.toUpper();
if (code.startsWith("/H")) return ParseHCode(code.remove(0, 2));
else if (code.startsWith("/R")) return ParseRCode(code.remove(0, 2));
else return {};
} }
QString GenerateCode(HookParam hp, DWORD processId) QString GenerateCode(HookParam hp, DWORD processId)