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 (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());
|
||||
AddSentence(std::move(buffer));
|
||||
buffer.clear();
|
||||
@ -79,11 +80,14 @@ void TextThread::Flush()
|
||||
|
||||
std::deque<std::wstring> sentences;
|
||||
queuedSentences->swap(sentences);
|
||||
int totalSize = 0;
|
||||
for (auto& sentence : sentences)
|
||||
{
|
||||
totalSize += sentence.size();
|
||||
sentence.erase(std::remove(sentence.begin(), sentence.end(), L'\0'));
|
||||
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);
|
||||
if (buffer.empty()) return;
|
||||
|
@ -27,6 +27,7 @@ enum HookParamType : unsigned
|
||||
FIXING_SPLIT = 0x800,
|
||||
DIRECT_READ = 0x1000, // /R read code instead of classic /H hook code
|
||||
FULL_STRING = 0x2000,
|
||||
HOOK_ENGINE = 0x4000,
|
||||
HOOK_ADDITIONAL = 0x8000,
|
||||
BLOCK_FLOOD = 0x4000, // remove this hook if flooding text causing perf issues
|
||||
HOOK_ENGINE = 0x8000,
|
||||
HOOK_ADDITIONAL = 0x10000,
|
||||
};
|
||||
|
@ -16681,7 +16681,7 @@ void InsertMonoHook(HMODULE h)
|
||||
{
|
||||
HookParam hp = {};
|
||||
hp.address = addr;
|
||||
hp.type = USING_UNICODE | FULL_STRING;
|
||||
hp.type = USING_UNICODE | FULL_STRING | BLOCK_FLOOD;
|
||||
hp.offset = 4;
|
||||
hp.text_fun = [](DWORD esp_base, HookParam*, BYTE, DWORD* data, DWORD* split, DWORD* len)
|
||||
{
|
||||
|
@ -95,7 +95,7 @@ namespace Engine
|
||||
{
|
||||
HookParam hp = {};
|
||||
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.padding = 20;
|
||||
hp.length_fun = [](uintptr_t, uintptr_t data)
|
||||
|
Loading…
Reference in New Issue
Block a user