forked from Public-Mirror/Textractor
refactor
This commit is contained in:
parent
2be762b708
commit
3f35c5c230
@ -27,10 +27,10 @@ std::wstring TextThread::GetStore()
|
||||
return storage;
|
||||
}
|
||||
|
||||
bool TextThread::Flush()
|
||||
void TextThread::Flush()
|
||||
{
|
||||
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;
|
||||
if (status & USING_UNICODE)
|
||||
{
|
||||
@ -44,7 +44,6 @@ bool TextThread::Flush()
|
||||
}
|
||||
AddSentence(sentence);
|
||||
buffer.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextThread::AddSentence(std::wstring sentence)
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
void AddSentence(std::wstring sentence);
|
||||
|
||||
private:
|
||||
bool Flush();
|
||||
void Flush();
|
||||
|
||||
std::vector<char> buffer;
|
||||
std::wstring storage;
|
||||
|
45
GUI/misc.cpp
45
GUI/misc.cpp
@ -30,16 +30,18 @@ std::unordered_map<std::wstring, DWORD> GetAllProcesses()
|
||||
return ret;
|
||||
}
|
||||
|
||||
DWORD Hash(QString module)
|
||||
namespace
|
||||
{
|
||||
DWORD Hash(QString module)
|
||||
{
|
||||
module = module.toLower();
|
||||
DWORD hash = 0;
|
||||
for (auto i : module) hash = _rotr(hash, 7) + i.unicode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<HookParam> ParseRCode(QString RCode)
|
||||
{
|
||||
std::optional<HookParam> ParseRCode(QString RCode)
|
||||
{
|
||||
HookParam hp = {};
|
||||
hp.type |= DIRECT_READ;
|
||||
switch (RCode.at(0).unicode())
|
||||
@ -66,10 +68,10 @@ std::optional<HookParam> ParseRCode(QString RCode)
|
||||
if (address.indexIn(RCode) == -1) return {};
|
||||
hp.address = address.cap(0).toULongLong(nullptr, 16);
|
||||
return hp;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<HookParam> ParseHCode(QString HCode)
|
||||
{
|
||||
std::optional<HookParam> ParseHCode(QString HCode)
|
||||
{
|
||||
HookParam hp = {};
|
||||
switch (HCode.at(0).unicode())
|
||||
{
|
||||
@ -143,18 +145,10 @@ std::optional<HookParam> ParseHCode(QString HCode)
|
||||
if (hp.split < 0)
|
||||
hp.split -= 4;
|
||||
return hp;
|
||||
}
|
||||
}
|
||||
|
||||
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 GenerateHCode(HookParam hp, DWORD processId)
|
||||
{
|
||||
QString GenerateHCode(HookParam hp, DWORD processId)
|
||||
{
|
||||
QString code = "/H";
|
||||
if (hp.type & USING_UNICODE)
|
||||
{
|
||||
@ -215,10 +209,10 @@ QString GenerateHCode(HookParam hp, DWORD processId)
|
||||
code = code.toUpper();
|
||||
code += moduleName;
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
QString GenerateRCode(HookParam hp)
|
||||
{
|
||||
QString GenerateRCode(HookParam hp)
|
||||
{
|
||||
QString code = "/R";
|
||||
if (hp.type & USING_UNICODE)
|
||||
code += "Q";
|
||||
@ -230,6 +224,15 @@ QString GenerateRCode(HookParam hp)
|
||||
code += "@";
|
||||
code += QString::number(hp.address, 16);
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user