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;
|
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)
|
||||||
|
@ -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;
|
||||||
|
19
GUI/misc.cpp
19
GUI/misc.cpp
@ -30,6 +30,8 @@ std::unordered_map<std::wstring, DWORD> GetAllProcesses()
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
DWORD Hash(QString module)
|
DWORD Hash(QString module)
|
||||||
{
|
{
|
||||||
module = module.toLower();
|
module = module.toLower();
|
||||||
@ -145,14 +147,6 @@ std::optional<HookParam> ParseHCode(QString HCode)
|
|||||||
return hp;
|
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";
|
QString code = "/H";
|
||||||
@ -231,6 +225,15 @@ QString GenerateRCode(HookParam hp)
|
|||||||
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)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user