diff --git a/Lang/en.h b/Lang/en.h index f7fa148..682a98e 100644 --- a/Lang/en.h +++ b/Lang/en.h @@ -25,7 +25,7 @@ #define HIJACK_ERROR u8"Hijack ERROR" #define COULD_NOT_FIND u8"could not find text" #define CONSOLE L"Console" -#define InvalidLength u8"something went very wrong (invalid length %d at hook address %I64d)" +#define InvalidLength u8"something went very wrong (invalid length %d in %s)" #define InsertHookFailed u8"failed to insert hook %s" #define Match_Error u8"ERROR happened when matching engine %s " #define Attach_Error u8"ERROR happened when attaching engine %s ERROR" diff --git a/Lang/zh.h b/Lang/zh.h index 97bd3a4..74a977b 100644 --- a/Lang/zh.h +++ b/Lang/zh.h @@ -25,7 +25,7 @@ #define HIJACK_ERROR u8"Hijack 错误" #define COULD_NOT_FIND u8"无法找到文本" #define CONSOLE L"控制台" -#define InvalidLength u8"可能存在错误 (无效的文本长度 %d 出现在Hook地址 %I64d)" +#define InvalidLength u8"可能存在错误 (无效的文本长度 %d 出现 %s)" #define InsertHookFailed u8"钩子注入失败 %s" #define Match_Error u8"匹配 %s 引擎时发生错误" #define Attach_Error u8"连接到 %s 引擎时发送错误" diff --git a/LunaHook/engine32/KiriKiri.cpp b/LunaHook/engine32/KiriKiri.cpp index a8c0f31..dacf83c 100644 --- a/LunaHook/engine32/KiriKiri.cpp +++ b/LunaHook/engine32/KiriKiri.cpp @@ -1278,6 +1278,7 @@ namespace Private { auto text = (LPCSTR)s->ecx; if ( !text || !*text) return false; + if(strlen(text)>2000)return false; if (all_ascii(text,strlen(text)))return false; //"。」』?―!、" auto chatflags={"\xe3\x80\x82", "\xe3\x80\x8d","\xe3\x80\x8f","\xef\xbc\x9f","\xe2\x80\x95","\xef\xbc\x81","\xe3\x80\x81"}; diff --git a/LunaHook/main.cc b/LunaHook/main.cc index 60a0cae..8b394c7 100644 --- a/LunaHook/main.cc +++ b/LunaHook/main.cc @@ -95,7 +95,6 @@ DWORD WINAPI Pipe(LPVOID) void TextOutput(ThreadParam tp, TextOutput_T*buffer, int len) { - if (len < 0 || len > PIPE_BUFFER_SIZE - sizeof(tp)) ConsoleOutput(InvalidLength, len, tp.addr); buffer->tp=tp; WriteFile(hookPipe, buffer, sizeof(TextOutput_T) + len, DUMMY, nullptr); } diff --git a/LunaHook/texthook.cc b/LunaHook/texthook.cc index 709ec80..8cf1d28 100644 --- a/LunaHook/texthook.cc +++ b/LunaHook/texthook.cc @@ -128,14 +128,12 @@ void TextHook::Send(uintptr_t lpDataBase) buffer->type=hp.type; bool isstring=false; - if((hp.type&EMBED_ABLE)&&!(hp.type&EMBED_BEFORE_SIMPLE) ) + auto use_custom_embed_fun=(hp.type&EMBED_ABLE)&&!(hp.type&EMBED_BEFORE_SIMPLE); + if(use_custom_embed_fun) { isstring=true; - lpRetn=0; lpSplit=Engine::ScenarioRole; if(hp.hook_before(stack,pbData,&lpCount,&lpSplit)==false)__leave; - if (hp.filter_fun && !hp.filter_fun(pbData, &lpCount, &hp) || lpCount <= 0) __leave; - } else { @@ -164,9 +162,16 @@ void TextHook::Send(uintptr_t lpDataBase) //hook_fun&&text_fun change hookparam.type buffer->type=hp.type; - - if (lpCount <= 0) __leave; - if (lpCount > TEXT_BUFFER_SIZE) lpCount = TEXT_BUFFER_SIZE; + } + if (lpCount <= 0) __leave; + if (lpCount > TEXT_BUFFER_SIZE) + { + ConsoleOutput(InvalidLength, lpCount, hp.name); + lpCount = TEXT_BUFFER_SIZE; + } + + if(!use_custom_embed_fun) + { if ((!(hp.type&USING_CHAR))&&(isstring||(hp.type&USING_STRING))) { if(lpDataIn == 0)__leave; @@ -185,11 +190,11 @@ void TextHook::Send(uintptr_t lpDataBase) *(WORD*)pbData = lpDataIn & 0xffff; } } - - if (hp.filter_fun && !hp.filter_fun(pbData, &lpCount, &hp) || lpCount <= 0) __leave; - - if (hp.type & (NO_CONTEXT | FIXING_SPLIT)) lpRetn = 0; } + if (hp.filter_fun && !hp.filter_fun(pbData, &lpCount, &hp) || lpCount <= 0) __leave; + + if (hp.type & (NO_CONTEXT | FIXING_SPLIT)) lpRetn = 0; + ThreadParam tp{ GetCurrentProcessId(), address, lpRetn, lpSplit }; if((hp.type&EMBED_ABLE)&&(check_embed_able(tp)))