From d15804a5b86c6527ad8042cd1a1718b71db5acb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Sun, 19 May 2024 16:32:44 +0800 Subject: [PATCH] livecaptions --- LunaHook/CMakeLists.txt | 2 +- LunaHook/engine64/livecaptions.cpp | 49 ++++++++++++++++++++++++++++++ LunaHook/engine64/livecaptions.h | 16 ++++++++++ LunaHook/enginecollection64.cpp | 4 ++- 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 LunaHook/engine64/livecaptions.cpp create mode 100644 LunaHook/engine64/livecaptions.h diff --git a/LunaHook/CMakeLists.txt b/LunaHook/CMakeLists.txt index e41037d..6d8befe 100644 --- a/LunaHook/CMakeLists.txt +++ b/LunaHook/CMakeLists.txt @@ -1,6 +1,6 @@ include_directories(. util engines) if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(enginessrc Kincaid vita3k rpcs3 yuzusuyu TYPEMOON ENTERGRAM AGES7 mono Godot Renpy 5pb lucasystem LightVN V8 pchooks Artemis KiriKiri YOX PPSSPP CMVS Suika2 ) + set(enginessrc livecaptions Kincaid vita3k rpcs3 yuzusuyu TYPEMOON ENTERGRAM AGES7 mono Godot Renpy 5pb lucasystem LightVN V8 pchooks Artemis KiriKiri YOX PPSSPP CMVS Suika2 ) set(enginepath "engine64") set(collector "enginecollection64.cpp") else() diff --git a/LunaHook/engine64/livecaptions.cpp b/LunaHook/engine64/livecaptions.cpp new file mode 100644 index 0000000..0c5c385 --- /dev/null +++ b/LunaHook/engine64/livecaptions.cpp @@ -0,0 +1,49 @@ +#include "livecaptions.h" + + +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::setonce; + 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)"); + } + }; + + return NewHook(hp,"vcruntime140_app:memmove"); +} \ No newline at end of file diff --git a/LunaHook/engine64/livecaptions.h b/LunaHook/engine64/livecaptions.h new file mode 100644 index 0000000..e0fbaba --- /dev/null +++ b/LunaHook/engine64/livecaptions.h @@ -0,0 +1,16 @@ + + +class livecaptions : public ENGINE +{ +public: + livecaptions() + { + + check_by = CHECK_BY::CUSTOM; + check_by_target = []() + { + return GetModuleHandle(L"vcruntime140_app.dll")&&GetModuleHandle(L"Microsoft.CognitiveServices.Speech.extension.embedded.sr.dll"); + }; + }; + bool attach_function(); +}; diff --git a/LunaHook/enginecollection64.cpp b/LunaHook/enginecollection64.cpp index a6abb51..b1a30ff 100644 --- a/LunaHook/enginecollection64.cpp +++ b/LunaHook/enginecollection64.cpp @@ -9,6 +9,7 @@ #include"engine64/KiriKiri.h" #include"engine64/YOX.h" #include"engine64/Suika2.h" +#include"engine64/livecaptions.h" #include"engine64/CMVS.h" #include"engine64/5pb.h" #include"engine64/lucasystem.h" @@ -44,7 +45,8 @@ std::vector check_engines(){ new PPSSPPengine, new vita3k, new rpcs3, - new Kincaid + new Kincaid, + new livecaptions }; }