From 505de799dd339825cec4f55b9e53bd02c89e0637 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: Mon, 1 Apr 2024 16:42:31 +0800 Subject: [PATCH] yuzu --- LunaHook/engine64/yuzusuyu.cpp | 19 ++++++++++- include/hookcode.cpp | 62 ++++++++++++++++------------------ 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/LunaHook/engine64/yuzusuyu.cpp b/LunaHook/engine64/yuzusuyu.cpp index e1f1766..7c8a04b 100644 --- a/LunaHook/engine64/yuzusuyu.cpp +++ b/LunaHook/engine64/yuzusuyu.cpp @@ -101,7 +101,7 @@ struct GameInfo { bool checkiscurrentgame(const emfuncinfo& em){ auto wininfos=get_proc_windows(); for(auto&& info:wininfos){ - if(info.title.find(acastw(game_info.version))!=info.title.npos){ + if((game_info.version.size())&&(info.title.find(acastw(game_info.version))!=info.title.npos)&&(game_info.id!=0)){ //判断是有效的info auto checkversion=(std::wstring(em._version)==acastw(game_info.version)); auto checkid=(std::stoll(em._id,0,16)==game_info.id); @@ -454,6 +454,20 @@ bool F0100982015606000(void* data, size_t* len, HookParam* hp){ return write_string_overwrite(data,len,s); } +bool F010001D015260000(void* data, size_t* len, HookParam* hp){ + auto s=std::string((char*)data,*len); + if(startWith(s,"#Key"))return false; + strReplace(s,"#n","\n"); + return write_string_overwrite(data,len,s); +} +bool F0100AEC013DDA000(void* data, size_t* len, HookParam* hp){ + auto s=std::string((char*)data,*len); + static std::string ss; + if(ss==s)return false; + ss=s; + return true; +} + bool F0100925014864000(void* data, size_t* len, HookParam* hp){ auto s=std::string((char*)data,*len); @@ -538,6 +552,9 @@ auto _=[](){ {0x81c9ae60 - 0x80004000,{"Hamefura Pirates",CODEC_UTF16,0,0,T0100982015606000,F0100982015606000,L"0100982015606000",L"1.0.0"}},// Hamekai.ChoicesText$$SetText {0x81eb7dc0 - 0x80004000,{"Hamefura Pirates",CODEC_UTF16,0,0,T0100982015606000,F0100982015606000,L"0100982015606000",L"1.0.0"}},// Hamekai.ShortStoryTextView$$AddText + {0x80225C3C - 0x80004000,{"Death end re;Quest 2",CODEC_UTF8,8,0,0,F010001D015260000,L"010001D015260000",L"1.0.0"}}, + {0x80241088 - 0x80004000,{"Death end re;Quest",CODEC_UTF8,8,0,0,F0100AEC013DDA000,L"0100AEC013DDA000",L"1.0.0"}},//english ver + }; return 1; }(); diff --git a/include/hookcode.cpp b/include/hookcode.cpp index fbaeff9..e44e4e9 100644 --- a/include/hookcode.cpp +++ b/include/hookcode.cpp @@ -4,6 +4,7 @@ namespace { std::optional ParseRCode(std::wstring RCode) { + RCode.erase(0,1); std::wsmatch match; HookParam hp; hp.type |= DIRECT_READ; @@ -40,16 +41,28 @@ namespace return hp; } - std::optional ParseHCode(std::wstring HCode) + std::optional ParseHCode(std::wstring HCode,std::optional hpo={}) { - std::wsmatch match; - HookParam hp; - if(endWith(HCode,L":JIT:YUZU")){ + auto hp=hpo?hpo.value():HookParam{}; + + switch (HCode[0]) + { + case L'B': + hp.type|=BREAK_POINT; + case L'H': + break; + default: + return {}; + } + + HCode.erase(0,1); + + if(endWith(HCode,L":JIT:YUZU")) hp.jittype=JITTYPE::YUZU; - } - else if(endWith(HCode,L":JIT:PPSSPP")){ + else if(endWith(HCode,L":JIT:PPSSPP")) hp.jittype=JITTYPE::PPSSPP; - } + + // {A|B|W|H|S|Q|V|M} switch (HCode[0]) { @@ -98,7 +111,8 @@ namespace hp.type |= NO_CONTEXT; HCode.erase(0, 1); } - + + std::wsmatch match; // [codepage#] if (std::regex_search(HCode, match, std::wregex(L"^([0-9]+)#"))) { @@ -183,18 +197,8 @@ namespace std::optional ParseECode(std::wstring code) { - auto idx=code.find(L'H'); - if(idx==code.npos) - { - idx=code.find(L'B'); - - if(idx==code.npos) - return {}; - } - auto hpo=ParseHCode(code.substr(idx+1)); - code=code.substr(0,idx); - if(hpo.has_value()==false)return {}; - auto hp=hpo.value(); + code.erase(0,1); + HookParam hp; hp.type|=EMBED_ABLE; if(code[0]==L'D') @@ -215,8 +219,8 @@ namespace return {}; code.erase(0,1); } - if(code.size())return {}; - return hp; + + return ParseHCode(code,hp); } std::wstring HexString(int64_t num) @@ -363,17 +367,9 @@ namespace HookCode if (code[0] == L'/') code.erase(0, 1); code.erase(std::find(code.begin(), code.end(), L'/'), code.end()); // legacy/AGTH compatibility Trim(code); - if (code[0] == L'R') return ParseRCode(code.erase(0, 1)); - else if (code[0] == L'B'||code[0] == L'H'){ - auto isbreakpoint=code[0] == L'B'; - auto hpo=ParseHCode(code.erase(0, 1)); - if(isbreakpoint && hpo.has_value()){ - hpo.value().type|=BREAK_POINT; - } - return hpo; - } - else if (code[0] == L'E') return ParseECode(code.erase(0, 1)); - return {}; + if (code[0] == L'R') return ParseRCode(code); + else if (code[0] == L'E') return ParseECode(code); + else return ParseHCode(code); } std::wstring Generate(HookParam hp, DWORD processId)