Merge remote-tracking branch 'Blu3train/texthook_x64_improvements'

This commit is contained in:
Chenx221 2024-09-05 12:27:31 +08:00
commit f86a674c4a

View File

@ -169,6 +169,10 @@ void TextHook::Send(uintptr_t dwDataBase)
ThreadParam tp = { GetCurrentProcessId(), address, *(uintptr_t*)dwDataBase, 0 }; // first value on stack (if hooked start of function, this is return address) ThreadParam tp = { GetCurrentProcessId(), address, *(uintptr_t*)dwDataBase, 0 }; // first value on stack (if hooked start of function, this is return address)
uintptr_t data = *(uintptr_t*)(dwDataBase + hp.offset); // default value uintptr_t data = *(uintptr_t*)(dwDataBase + hp.offset); // default value
if (hp.text_fun) {
hp.text_fun(dwDataBase, &hp, 0, &static_cast<DWORD>(data), &static_cast<DWORD>(tp.ctx2), &static_cast<DWORD>(count));
}
else {
if (hp.type & USING_SPLIT) if (hp.type & USING_SPLIT)
{ {
tp.ctx2 = *(uintptr_t*)(dwDataBase + hp.split); tp.ctx2 = *(uintptr_t*)(dwDataBase + hp.split);
@ -178,6 +182,8 @@ void TextHook::Send(uintptr_t dwDataBase)
data += hp.padding; data += hp.padding;
count = GetLength(dwDataBase, data); count = GetLength(dwDataBase, data);
}
if (count <= 0) goto done; if (count <= 0) goto done;
if (count > TEXT_BUFFER_SIZE) count = TEXT_BUFFER_SIZE; if (count > TEXT_BUFFER_SIZE) count = TEXT_BUFFER_SIZE;
if (hp.length_offset == 1) if (hp.length_offset == 1)
@ -189,6 +195,8 @@ void TextHook::Send(uintptr_t dwDataBase)
} }
else ::memcpy(pbData, (void*)data, count); else ::memcpy(pbData, (void*)data, count);
if (hp.filter_fun && !hp.filter_fun(pbData, &static_cast<DWORD>(count), &hp, 0) || count <= 0) goto done;
if (hp.type & (NO_CONTEXT | FIXING_SPLIT)) tp.ctx = 0; if (hp.type & (NO_CONTEXT | FIXING_SPLIT)) tp.ctx = 0;
TextOutput(tp, buffer, count); TextOutput(tp, buffer, count);