forked from Public-Mirror/Textractor
fix mono perf issues (hopefully)
This commit is contained in:
parent
17aa20109f
commit
8b345a4377
@ -57,6 +57,7 @@ void TextThread::Push(BYTE* data, int length)
|
|||||||
if (std::all_of(buffer.begin(), buffer.end(), [&](auto ch) { return repeatingChars.find(ch) != repeatingChars.end(); })) buffer.clear();
|
if (std::all_of(buffer.begin(), buffer.end(), [&](auto ch) { return repeatingChars.find(ch) != repeatingChars.end(); })) buffer.clear();
|
||||||
if (RemoveRepetition(buffer)) // sentence repetition detected, which means the entire sentence has already been received
|
if (RemoveRepetition(buffer)) // sentence repetition detected, which means the entire sentence has already been received
|
||||||
{
|
{
|
||||||
|
if (hp.type & BLOCK_FLOOD) Host::RemoveHook(tp.processId, tp.addr);
|
||||||
repeatingChars = std::unordered_set(buffer.begin(), buffer.end());
|
repeatingChars = std::unordered_set(buffer.begin(), buffer.end());
|
||||||
AddSentence(std::move(buffer));
|
AddSentence(std::move(buffer));
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
@ -79,11 +80,14 @@ void TextThread::Flush()
|
|||||||
|
|
||||||
std::deque<std::wstring> sentences;
|
std::deque<std::wstring> sentences;
|
||||||
queuedSentences->swap(sentences);
|
queuedSentences->swap(sentences);
|
||||||
|
int totalSize = 0;
|
||||||
for (auto& sentence : sentences)
|
for (auto& sentence : sentences)
|
||||||
{
|
{
|
||||||
|
totalSize += sentence.size();
|
||||||
sentence.erase(std::remove(sentence.begin(), sentence.end(), L'\0'));
|
sentence.erase(std::remove(sentence.begin(), sentence.end(), L'\0'));
|
||||||
if (Output(*this, sentence)) storage->append(sentence);
|
if (Output(*this, sentence)) storage->append(sentence);
|
||||||
}
|
}
|
||||||
|
if (hp.type & BLOCK_FLOOD && totalSize > PIPE_BUFFER_SIZE) Host::RemoveHook(tp.processId, tp.addr);
|
||||||
|
|
||||||
std::scoped_lock lock(bufferMutex);
|
std::scoped_lock lock(bufferMutex);
|
||||||
if (buffer.empty()) return;
|
if (buffer.empty()) return;
|
||||||
|
@ -27,6 +27,7 @@ enum HookParamType : unsigned
|
|||||||
FIXING_SPLIT = 0x800,
|
FIXING_SPLIT = 0x800,
|
||||||
DIRECT_READ = 0x1000, // /R read code instead of classic /H hook code
|
DIRECT_READ = 0x1000, // /R read code instead of classic /H hook code
|
||||||
FULL_STRING = 0x2000,
|
FULL_STRING = 0x2000,
|
||||||
HOOK_ENGINE = 0x4000,
|
BLOCK_FLOOD = 0x4000, // remove this hook if flooding text causing perf issues
|
||||||
HOOK_ADDITIONAL = 0x8000,
|
HOOK_ENGINE = 0x8000,
|
||||||
|
HOOK_ADDITIONAL = 0x10000,
|
||||||
};
|
};
|
||||||
|
@ -16681,7 +16681,7 @@ void InsertMonoHook(HMODULE h)
|
|||||||
{
|
{
|
||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
hp.address = addr;
|
hp.address = addr;
|
||||||
hp.type = USING_UNICODE | FULL_STRING;
|
hp.type = USING_UNICODE | FULL_STRING | BLOCK_FLOOD;
|
||||||
hp.offset = 4;
|
hp.offset = 4;
|
||||||
hp.text_fun = [](DWORD esp_base, HookParam*, BYTE, DWORD* data, DWORD* split, DWORD* len)
|
hp.text_fun = [](DWORD esp_base, HookParam*, BYTE, DWORD* data, DWORD* split, DWORD* len)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ namespace Engine
|
|||||||
{
|
{
|
||||||
HookParam hp = {};
|
HookParam hp = {};
|
||||||
hp.address = addr;
|
hp.address = addr;
|
||||||
hp.type = USING_STRING | USING_UNICODE | FULL_STRING;
|
hp.type = USING_STRING | USING_UNICODE | BLOCK_FLOOD | FULL_STRING;
|
||||||
hp.offset = -0x20; // rcx
|
hp.offset = -0x20; // rcx
|
||||||
hp.padding = 20;
|
hp.padding = 20;
|
||||||
hp.length_fun = [](uintptr_t, uintptr_t data)
|
hp.length_fun = [](uintptr_t, uintptr_t data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user