diff --git a/LunaHook/engine64/vita3k.cpp b/LunaHook/engine64/vita3k.cpp index cbc2627..c7c6086 100644 --- a/LunaHook/engine64/vita3k.cpp +++ b/LunaHook/engine64/vita3k.cpp @@ -87,6 +87,7 @@ bool vita3k::attach_function() } +namespace{ bool FPCSG01023(void* data, size_t* len, HookParam* hp){ auto s = std::string((char*)data,*len); s = std::regex_replace(s, std::regex("
"), ""); @@ -200,7 +201,68 @@ bool FPCSG00216(void* data, size_t* len, HookParam* hp){ s = std::regex_replace(s, std::regex("#Pos\\[[\\s\\S]*?\\]"), ""); return write_string_overwrite(data,len,s); } -namespace{ + + +void TPCSG00291(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* split, size_t* len){ + auto a2= VITA3K::emu_arg(stack)[0]; + + auto vm = *(DWORD*)(a2+(0x28)); + vm=*(DWORD*)VITA3K::emu_addr(stack,vm); + vm=*(DWORD*)VITA3K::emu_addr(stack,vm+8); + uintptr_t address=VITA3K::emu_addr(stack,vm); + auto len1=*(DWORD*)(address+4); + auto p=address+0x20; + if(len1>4 && *(WORD*)(p+2)==0){ + auto p1=*(DWORD*)(address+8); + vm=*(DWORD*)VITA3K::emu_addr(stack,vm); + vm=*(DWORD*)VITA3K::emu_addr(stack,vm+0xC); + p=VITA3K::emu_addr(stack,vm); + } + static int fm=0; + static std::string pre; + auto b=fm; + auto s=[](uintptr_t address){ + auto frist = *(WORD*)address; + auto lo = frist & 0xFF; // uppercase: 41->5A + auto hi = frist >> 8; + if (hi == 0 && (lo > 0x5a || lo < 0x41) /* T,W,? */) { + return std::string(); + } + std::string s ;int i = 0;WORD c; + char buf[3]={0}; + while ((c = *(WORD*)(address+i)) != 0) { + // reverse endian: ShiftJIS BE => LE + buf[0] = c >> 8; + buf[1] = c & 0xFF; + + if (c == 0x815e /* / */) { + s += ' '; // single line + } + else if (buf[0] == 0) { + //// UTF16 LE turned BE: 5700=>0057, 3100, 3500 + //// 4e00 6d00=>PLAYER + // do nothing + if (buf[1] == 0x4e) { + s += "PLAYER"; + fm++; + } + } + else { + s+=buf; + } + i += 2; + } + return s; + }(p); + if(b>0){ + fm--; + return; + } + if(s==pre)return ; + pre=s; + write_string_new(data,len,s); +} + auto _=[](){ emfunctionhooks={ //Tsuihou Senkyo @@ -246,7 +308,7 @@ auto _=[](){ {0x80058608,{0,1,0,0,FPCSG00389,"PCSG00389"}},//dialogue,sjis {0x80021292,{0,0,0,0,FPCSG00389,"PCSG00389"}},//name //Amagami - //to complex. + {0x80070658,{0,0,0,TPCSG00291,0,"PCSG00291"}}, //Rui wa Tomo o Yobu {0x81003db0,{CODEC_UTF8,1,0,0,FPCSG00839,"PCSG00216"}},//dialogue diff --git a/LunaHook/engine64/yuzusuyu.cpp b/LunaHook/engine64/yuzusuyu.cpp index c2ceb07..22b9f4a 100644 --- a/LunaHook/engine64/yuzusuyu.cpp +++ b/LunaHook/engine64/yuzusuyu.cpp @@ -171,6 +171,9 @@ bool yuzusuyu::attach_function() }; return NewHook(hp,"YuzuDoJit"); } + + +namespace{ int readu8(BYTE* addr){ int numBytes = 0; auto firstByte=*addr; @@ -1169,7 +1172,6 @@ bool F01000EA00D2EE000(void* data, size_t* len, HookParam* hp){ s = std::regex_replace(s, std::wregex(L"<.+?>"), L""); return write_string_overwrite(data,len,s); } -namespace{ auto _=[](){ emfunctionhooks={ //Memories Off diff --git a/LunaHook/engines/emujitarg.hpp b/LunaHook/engines/emujitarg.hpp index c933eb2..ffd8903 100644 --- a/LunaHook/engines/emujitarg.hpp +++ b/LunaHook/engines/emujitarg.hpp @@ -15,14 +15,26 @@ public: } namespace VITA3K { +class emu_addr{ + hook_stack* stack; + DWORD addr; +public: + emu_addr(hook_stack* stack_,DWORD addr_):stack(stack_),addr(addr_){}; + operator uintptr_t(){ + auto base=stack->r13; + return base+addr; + } + operator DWORD*(){ + return (DWORD*)(uintptr_t)*this; + } +}; class emu_arg{ hook_stack* stack; public: emu_arg(hook_stack* stack_):stack(stack_){}; uintptr_t operator [](int idx){ - auto base=stack->r13; auto args=(uint32_t*)stack->r15; - return base+args[idx]; + return emu_addr(stack,args[idx]); } }; } diff --git a/LunaHook/engines/ppsspp/specialgames.hpp b/LunaHook/engines/ppsspp/specialgames.hpp index 5f3a25a..50ec2c0 100644 --- a/LunaHook/engines/ppsspp/specialgames.hpp +++ b/LunaHook/engines/ppsspp/specialgames.hpp @@ -1,6 +1,7 @@ #include #include"emujitarg.hpp" +namespace ppsspp{ bool ULJS00403_filter(void* data, size_t* len, HookParam* hp){ std::string result = std::string((char*)data,*len); std::regex newlinePattern(R"((\\n)+)"); @@ -251,43 +252,42 @@ void QNPJH50909(hook_stack* stack, HookParam* hp, uintptr_t* data, uintptr_t* sp if(0x6e87==*(WORD*)*data)*len=0; if(0x000a==*(WORD*)*data)*len=0; } -namespace ppsspp{ - std::unordered_mapemfunctionhooks= { - //Shinigami to Shoujo - {0x883bf34,{0,1,0,0,ULJS00403_filter,"ULJS00403"}}, - //Amagami - {0x0886775c,{0,0,0,ULJS00339,0,"ULJS00339"}},// String.length() - //Sekai de Ichiban Dame na Koi - {0x8814adc,{0,0,0,0,NPJH50909_filter,"ULJM05878"}},// name + dialouge - {0x8850b2c,{0,0,0,0,NPJH50909_filter,"ULJM05878"}},// onscreen toast - //Dunamis15 - {0x0891D72C,{CODEC_UTF8,0,0,0,ULJM06119_filter,"ULJM06119"}}, - //Princess Evangile Portable - {0x88506d0,{CODEC_UTF16,2,0,0,ULJM06036_filter,"ULJM06036"}},// [0x88506d0(2)...0x088507C0(?)] // name text text (line doubled) - //Kin'iro no Corda 2f - {0x89b59dc,{0,0,0,ULJM05428,0,"ULJM05428"}}, - //Kin'iro no Corda - {0x886162c,{0,0,0,ULJM05054,0,"ULJM05054"}},// dialogue: 0x886162c (x1), 0x889d5fc-0x889d520(a2) fullLine - {0x8899e90,{0,0,0,ULJM05054,0,"ULJM05054"}},// name 0x88da57c, 0x8899ca4 (x0, oneTime), 0x8899e90 - //Sol Trigger - {0x8952cfc,{CODEC_UTF8,0,0,0,NPJH50619F,"NPJH50619"}},//dialog - {0x884aad4,{CODEC_UTF8,0,0,0,NPJH50619F,"NPJH50619"}},//description - {0x882e1b0,{CODEC_UTF8,0,0,0,NPJH50619F,"NPJH50619"}},//system - {0x88bb108,{CODEC_UTF8,2,0,0,NPJH50619F,"NPJH50619"}},//battle tutorial - {0x89526a0,{CODEC_UTF8,0,0,0,NPJH50619F,"NPJH50619"}},//battle info - {0x88bcef8,{CODEC_UTF8,1,0,0,NPJH50619F,"NPJH50619"}},//battle talk - //Fate/EXTRA CCC - {0x8958490,{0,0,0,0,NPJH50505F,"NPJH50505"}}, - //Kamigami no Asobi InFinite - {0x088630f8,{0,0,0,QNPJH50909,0,"NPJH50909"}}, // text, choice (debounce trailing 400ms), TODO: better hook - {0x0887813c,{0,3,4,0,0,"NPJH50909"}}, // Question YN - //Gekka Ryouran Romance - {0x88eeba4,{0,0,0,0,ULJM05943F,"ULJM05943"}},// a0 - monologue text - {0x8875e0c,{0,1,6,0,ULJM05943F,"ULJM05943"}},// a1 - dialogue text - //My Merry May with be - {0x886F014,{0,3,0,0,FULJM05603,"ULJM05603"}}, - //Corpse Party -The Anthology- Sachiko no Ren'ai Yuugi ♥ Hysteric Birthday 2U - Regular Edition - {0x88517C8,{0,1,0,0,FULJM05603,"ULJM06114"}}, - }; +std::unordered_mapemfunctionhooks= { + //Shinigami to Shoujo + {0x883bf34,{0,1,0,0,ULJS00403_filter,"ULJS00403"}}, + //Amagami + {0x0886775c,{0,0,0,ULJS00339,0,"ULJS00339"}},// String.length() + //Sekai de Ichiban Dame na Koi + {0x8814adc,{0,0,0,0,NPJH50909_filter,"ULJM05878"}},// name + dialouge + {0x8850b2c,{0,0,0,0,NPJH50909_filter,"ULJM05878"}},// onscreen toast + //Dunamis15 + {0x0891D72C,{CODEC_UTF8,0,0,0,ULJM06119_filter,"ULJM06119"}}, + //Princess Evangile Portable + {0x88506d0,{CODEC_UTF16,2,0,0,ULJM06036_filter,"ULJM06036"}},// [0x88506d0(2)...0x088507C0(?)] // name text text (line doubled) + //Kin'iro no Corda 2f + {0x89b59dc,{0,0,0,ULJM05428,0,"ULJM05428"}}, + //Kin'iro no Corda + {0x886162c,{0,0,0,ULJM05054,0,"ULJM05054"}},// dialogue: 0x886162c (x1), 0x889d5fc-0x889d520(a2) fullLine + {0x8899e90,{0,0,0,ULJM05054,0,"ULJM05054"}},// name 0x88da57c, 0x8899ca4 (x0, oneTime), 0x8899e90 + //Sol Trigger + {0x8952cfc,{CODEC_UTF8,0,0,0,NPJH50619F,"NPJH50619"}},//dialog + {0x884aad4,{CODEC_UTF8,0,0,0,NPJH50619F,"NPJH50619"}},//description + {0x882e1b0,{CODEC_UTF8,0,0,0,NPJH50619F,"NPJH50619"}},//system + {0x88bb108,{CODEC_UTF8,2,0,0,NPJH50619F,"NPJH50619"}},//battle tutorial + {0x89526a0,{CODEC_UTF8,0,0,0,NPJH50619F,"NPJH50619"}},//battle info + {0x88bcef8,{CODEC_UTF8,1,0,0,NPJH50619F,"NPJH50619"}},//battle talk + //Fate/EXTRA CCC + {0x8958490,{0,0,0,0,NPJH50505F,"NPJH50505"}}, + //Kamigami no Asobi InFinite + {0x088630f8,{0,0,0,QNPJH50909,0,"NPJH50909"}}, // text, choice (debounce trailing 400ms), TODO: better hook + {0x0887813c,{0,3,4,0,0,"NPJH50909"}}, // Question YN + //Gekka Ryouran Romance + {0x88eeba4,{0,0,0,0,ULJM05943F,"ULJM05943"}},// a0 - monologue text + {0x8875e0c,{0,1,6,0,ULJM05943F,"ULJM05943"}},// a1 - dialogue text + //My Merry May with be + {0x886F014,{0,3,0,0,FULJM05603,"ULJM05603"}}, + //Corpse Party -The Anthology- Sachiko no Ren'ai Yuugi ♥ Hysteric Birthday 2U - Regular Edition + {0x88517C8,{0,1,0,0,FULJM05603,"ULJM06114"}}, +}; } \ No newline at end of file