diff --git a/LunaHook/engine64/livecaptions.cpp b/LunaHook/engine64/livecaptions.cpp index 66c73e0..96d3c05 100644 --- a/LunaHook/engine64/livecaptions.cpp +++ b/LunaHook/engine64/livecaptions.cpp @@ -2,49 +2,39 @@ bool livecaptions::attach_function() { - - // .text:0000000180001C98 push rbx - // .text:0000000180001C9A sub rsp, 20h - // .text:0000000180001C9E mov rbx, rcx - // .text:0000000180001CA1 call memmove_0 - // .text:0000000180001CA6 mov rax, rbx - // .text:0000000180001CA9 add rsp, 20h - // .text:0000000180001CAD pop rbx - // .text:0000000180001CAE retn - HookParam hp; - hp.address = (uintptr_t)GetProcAddress(GetModuleHandle(L"vcruntime140_app.dll"), "memmove"); - hp.text_fun = [](hook_stack *stack, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t *len) - { - BYTE sig[] = { - 0x40, 0x53, 0x48, 0x83, 0xEC, 0x20, 0x48, 0x8B, 0xD9, - 0xE8, XX4}; - auto a1 = stack->retaddr - sizeof(sig); - if ((stack->retaddr > (uintptr_t)GetModuleHandle(L"Microsoft.CognitiveServices.Speech.extension.embedded.sr.dll"))) - if (memcmp((void *)a1, &sig, sizeof(sig) - 4) == 0) - { - static std::set once; - if (once.find(stack->retaddr) != once.end()) - return; - once.insert(stack->retaddr); - // hp->text_fun=nullptr; - // hp->type=HOOK_EMPTY; - - HookParam hpinternal; - hpinternal.address = a1; // 0xE551+(uintptr_t)GetModuleHandle(L"Microsoft.CognitiveServices.Speech.extension.embedded.sr.dll"); - hpinternal.type = USING_STRING | CODEC_UTF8 | FULL_STRING; - hpinternal.text_fun = [](hook_stack *stack, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t *len) - { - auto ptr = stack->rdx; - auto size = stack->r8; - if (size == strnlen((char *)ptr, TEXT_BUFFER_SIZE)) // 否则有短acsii - { - *data = ptr; - *len = size; - } - }; - NewHook(hpinternal, "std::_Char_traits::copy(void *, const void *, size_t)"); - } + auto srdll = GetModuleHandle(L"Microsoft.CognitiveServices.Speech.extension.embedded.sr.dll"); + if (!srdll) + return false; + auto [s, e] = Util::QueryModuleLimits(srdll); + bool succ = false; + // std::_Char_traits::copy(void *, const void *, size_t) + // std::_Char_traits::move(void *, const void *, size_t) + BYTE sig[] = { + 0x40, 0x53, // push rbx + 0x48, 0x83, 0xec, 0x20, // sub rsp,0x20 + 0x48, 0x8b, 0xd9, // mov rbx,rcx + 0xe8, XX4, // call memmove_0 ,新版本改成call memcpy_0了 + 0x48, 0x8b, 0xc3, // mov rax,rbx + 0x48, 0x83, 0xc4, 0x20, // add rsp,0x20 + 0x5b, // pop rbx + 0xc3 // ret }; - - return NewHook(hp, "vcruntime140_app:memmove"); + for (auto addr : Util::SearchMemory(sig, sizeof(sig), PAGE_EXECUTE, s, e)) + { + auto target = addr + 2 + 4 + 3 + 5 + *(int *)(addr + 2 + 4 + 3 + 1); + if (*(WORD *)target != 0x25ff) + continue; + HookParam hp; + hp.address = addr; + hp.type = USING_STRING | CODEC_UTF8 | FULL_STRING; + hp.text_fun = [](hook_stack *stack, HookParam *hp, uintptr_t *data, uintptr_t *split, size_t *len) + { + auto ptr = stack->rdx; + auto size = stack->r8; + *data = ptr; + *len = size; + }; + succ |= NewHook(hp, "LiveCaptions"); + } + return succ; } \ No newline at end of file