From 1a7f27bd282f3581722f8a74ccb73f897f57dfcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Tue, 7 Jan 2025 17:34:40 +0800 Subject: [PATCH] . --- cpp/LunaHook/LunaHook/CMakeLists.txt | 2 +- cpp/LunaHook/LunaHook/engine32/BKEngine.cpp | 10 +-- cpp/LunaHook/LunaHook/engine32/FrontWing.h | 2 +- cpp/LunaHook/LunaHook/engine32/GSX.cpp | 10 +-- cpp/LunaHook/LunaHook/engine32/HXP.cpp | 4 +- cpp/LunaHook/LunaHook/engine32/Nijyuei.cpp | 2 +- cpp/LunaHook/LunaHook/engine32/RScript.cpp | 80 +++++++++++++++++++ cpp/LunaHook/LunaHook/engine32/RScript.h | 56 +++++++++++++ cpp/LunaHook/LunaHook/engine32/SRPGStudio.cpp | 2 +- cpp/LunaHook/LunaHook/engine32/Speed.cpp | 2 +- cpp/LunaHook/LunaHook/engine32/TSSystem.cpp | 2 +- cpp/LunaHook/LunaHook/engine32/ransel.cpp | 4 +- cpp/LunaHook/LunaHook/engine64/V8.cpp | 10 +-- cpp/LunaHook/LunaHook/enginecollection32.cpp | 2 + 14 files changed, 163 insertions(+), 25 deletions(-) create mode 100644 cpp/LunaHook/LunaHook/engine32/RScript.cpp create mode 100644 cpp/LunaHook/LunaHook/engine32/RScript.h diff --git a/cpp/LunaHook/LunaHook/CMakeLists.txt b/cpp/LunaHook/LunaHook/CMakeLists.txt index 9911cc0d..19d8382e 100644 --- a/cpp/LunaHook/LunaHook/CMakeLists.txt +++ b/cpp/LunaHook/LunaHook/CMakeLists.txt @@ -23,7 +23,7 @@ else() Syuntada Pensil Anim hibiki Nitroplus Reallive Siglus Taskforce2 RUGP IronGameSystem Anex86 ShinyDaysGame MarineHeart ShinaRio CaramelBox UnisonShift Escude Ryokucha Alice Footy2 utawarerumono System4x Abalone Abel 5pb HorkEye XUSE Leaf Nekopack AXL AGS AdobeFlash10 - FocasLens Tamamo Ages3ResT H_do_C) + FocasLens Tamamo Ages3ResT H_do_C RScript) set(enginepath "engine32") set(collector "enginecollection32.cpp") endif() diff --git a/cpp/LunaHook/LunaHook/engine32/BKEngine.cpp b/cpp/LunaHook/LunaHook/engine32/BKEngine.cpp index a40fa255..9b7000e5 100644 --- a/cpp/LunaHook/LunaHook/engine32/BKEngine.cpp +++ b/cpp/LunaHook/LunaHook/engine32/BKEngine.cpp @@ -4,9 +4,9 @@ namespace{ bool _1(){ BYTE sig[]={0x64,0xa3,0x00,0x00,0x00,0x00,0x8b,0xf1,0x8b,0x45,0x08,0x0f,0x57,0xc0,0xc7,0x06,0x02,0x00,0x00,0x00}; auto addr=MemDbg::findBytes(sig, sizeof(sig), processStartAddress, processStopAddress); - if(addr==0)return 0; + if(!addr)return 0; addr=MemDbg::findEnclosingAlignedFunction(addr); - if(addr==0)return 0; + if(!addr)return 0; HookParam hp; hp.address = addr; hp.type = CODEC_UTF16|DATA_INDIRECT; @@ -18,9 +18,9 @@ namespace{ bool _2(){ BYTE sig[]={0xb8,0xff,0x00,0x00,0x00,0x66,0x3b,0x06,0x1b,0xc0,0xf7,0xd8,0x40}; auto addr=MemDbg::findBytes(sig, sizeof(sig), processStartAddress, processStopAddress); - if(addr==0)return 0; + if(!addr)return 0; addr=MemDbg::findEnclosingAlignedFunction(addr); - if(addr==0)return 0; + if(!addr)return 0; HookParam hp; hp.address = addr; hp.type = CODEC_UTF16|DATA_INDIRECT|NO_CONTEXT; @@ -35,7 +35,7 @@ namespace{ DWORD maxaddr=0;int maxi=0; for(auto addr:Util::SearchMemory(sig, sizeof(sig),PAGE_EXECUTE, processStartAddress, processStopAddress)){ addr=MemDbg::findEnclosingAlignedFunction(addr); - if(addr==0)continue; + if(!addr)continue; if(mp.find(addr)==mp.end())mp[addr]=0; mp[addr]+=1; if(mp[addr]>maxi){maxi=mp[addr];maxaddr=addr;} diff --git a/cpp/LunaHook/LunaHook/engine32/FrontWing.h b/cpp/LunaHook/LunaHook/engine32/FrontWing.h index 64552ad5..c9619179 100644 --- a/cpp/LunaHook/LunaHook/engine32/FrontWing.h +++ b/cpp/LunaHook/LunaHook/engine32/FrontWing.h @@ -39,7 +39,7 @@ public: { //[071227][フロントウイング] タイムリープ check_by = CHECK_BY::FILE_ALL; - check_by_target = check_by_list{L"MDT/*.dat", L"BGM.dat", L"CHIP.dat", L"ef.dat", L"Init.dat", L"SE.dat"}; + check_by_target = check_by_list{L"MDT\\*.dat", L"BGM.dat", L"CHIP.dat", L"ef.dat", L"Init.dat", L"SE.dat"}; }; bool attach_function(); }; \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/engine32/GSX.cpp b/cpp/LunaHook/LunaHook/engine32/GSX.cpp index a85dbee0..dd61d963 100644 --- a/cpp/LunaHook/LunaHook/engine32/GSX.cpp +++ b/cpp/LunaHook/LunaHook/engine32/GSX.cpp @@ -9,7 +9,7 @@ bool GSX1() { //http://www.mirai-soft.com/products/persona/download.html //https://dlsoft.dmm.co.jp/detail/stone_0015/ ULONG addr = MemDbg::findCallerAddress((ULONG)::GetCharWidth32W, 0xec8b55, processStartAddress, processStopAddress); - if(addr==0)return false; + if(!addr)return false; HookParam hp; hp.address=addr; hp.type=USING_CHAR|CODEC_UTF16|DATA_INDIRECT; @@ -36,14 +36,14 @@ bool GSX2() { //仁義なき乙女 体验版 //https://dlsoft.dmm.co.jp/detail/stone_0031/ ULONG addr = findiatcallormov((DWORD)GetGlyphOutlineA,processStartAddress, processStartAddress, processStopAddress,false,XX); - if(addr==0) + if(!addr) addr = findiatcallormov((DWORD)GetGlyphOutlineA,processStartAddress, processStartAddress, processStopAddress); - if(addr==0)return false; + if(!addr)return false; auto addr1=findfuncstart(addr); auto addr2=MemDbg::findEnclosingAlignedFunction(addr); if(addr1) addr=addr1; else addr=addr2; - if(addr==0)return false; + if(!addr)return false; auto xrefs=findxref_reverse_checkcallop(addr,processStartAddress,processStopAddress,0xe8); if(xrefs.size()!=2)return false; addr=xrefs[1]; @@ -51,7 +51,7 @@ bool GSX2() { addr2=MemDbg::findEnclosingAlignedFunction(addr); if(addr1)addr=addr1; else addr=addr2; - if(addr==0)return false; + if(!addr)return false; ConsoleOutput("%p",addr); HookParam hp; hp.address=addr; diff --git a/cpp/LunaHook/LunaHook/engine32/HXP.cpp b/cpp/LunaHook/LunaHook/engine32/HXP.cpp index 1cc2dd9e..5fecf900 100644 --- a/cpp/LunaHook/LunaHook/engine32/HXP.cpp +++ b/cpp/LunaHook/LunaHook/engine32/HXP.cpp @@ -5,9 +5,9 @@ bool HXP::attach_function() { //https://vndb.org/v172 //エクソダスギルティー・オルタナティブ auto addr=MemDbg::findCallerAddress((DWORD)TextOutA, 0x01003d66,processStartAddress, processStopAddress); - if(addr==0)return false; + if(!addr)return false; addr=MemDbg::findEnclosingAlignedFunction(addr); - if(addr==0)return false; + if(!addr)return false; HookParam hp; hp.address = (DWORD)addr; hp.offset=stackoffset(2); diff --git a/cpp/LunaHook/LunaHook/engine32/Nijyuei.cpp b/cpp/LunaHook/LunaHook/engine32/Nijyuei.cpp index 3a48e3df..f2cdda13 100644 --- a/cpp/LunaHook/LunaHook/engine32/Nijyuei.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Nijyuei.cpp @@ -13,7 +13,7 @@ bool Nijyuei::attach_function() { }; auto addr=MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress); - if(addr==0)return false; + if(!addr)return false; HookParam hp; hp.address = addr+5; diff --git a/cpp/LunaHook/LunaHook/engine32/RScript.cpp b/cpp/LunaHook/LunaHook/engine32/RScript.cpp new file mode 100644 index 00000000..424c3e36 --- /dev/null +++ b/cpp/LunaHook/LunaHook/engine32/RScript.cpp @@ -0,0 +1,80 @@ +#include "RScript.h" + +bool RScript::attach_function() +{ + /* + void __thiscall CSelTxtEx::SetSels(CSelTxtEx *this, char *a2) + + while ( *a2 ) + { + if ( _ismbblead(*a2) && (v8 = _ismbbtrail(a2[1])) != 0 ) + { + if ( *((_WORD *)this + 42) >= *((_WORD *)this + 43) ) + return; + LOWORD(v8) = (unsigned __int8)*a2; + LOWORD(v9) = (unsigned __int8)a2[1]; + *(_WORD *)(*((_DWORD *)this + 96) + 2 * *((unsigned __int16 *)this + 42)) = v3; + CSelTxtEx::SetSel(this, v9 + (v8 << 8), v23, v4, v22, v21); + a2 += 2; + } + else if ( *a2 == 94 ) + { + v10 = *++a2; + if ( !v10 ) + return; + switch ( v10 ) + { + case 'A': + case 'a': + */ + BYTE bytes[] = { + 0x80, 0x3f, 0x5e, + 0x0f, 0x85, XX4, + 0x8a, 0x47, 0x01, + 0x47, 0x84, 0xc0, + 0x0f, 0x84, XX4, + 0x0f, 0xbe, 0xc0, + 0x83, 0xc0, 0xbf, + 0x83, 0xf8, 0x32}; + auto addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress); + if (!addr) + return false; + auto faddr = MemDbg::findEnclosingAlignedFunction(addr); + if (!faddr) + return false; + BYTE bytes2[] = { + 0x8a, 0x07, + 0x84, 0xc0, + 0x0f, 0x84, XX4, + 0x0f, 0xbe, 0xd0, + 0x52, + 0xe8, XX4, // call __ismbblead + 0x83, 0xc4, 0x04, + 0x85, 0xc0, + 0x74, XX, + 0x0f, 0xbe, 0x47, 0x01, + 0x50, + 0xe8, XX4, // call __ismbbtrail + }; + auto addrX = MemDbg::findBytes(bytes2, sizeof(bytes2), faddr, addr); + if (!addrX) + return false; + static auto __ismbblead = *(int *)(addrX + 2 + 2 + 6 + 3 + 1 + 1) + addrX + 2 + 2 + 6 + 3 + 1 + 5; + static auto __ismbbtrail = *(int *)(addrX + sizeof(bytes2) - 4) + addrX + sizeof(bytes2); + ConsoleOutput("%p", __ismbblead); + ConsoleOutput("%p", __ismbbtrail); + HookParam hp; + hp.address = faddr; + hp.offset = stackoffset(1); + hp.type = USING_STRING | EMBED_ABLE | EMBED_AFTER_NEW | EMBED_DYNA_SJIS; + hp.embed_hook_font = F_GetGlyphOutlineA | F_GetTextExtentPoint32A; + hp.lineSeparator = L"^n"; + patch_fun = []() + { + ReplaceFunction((void *)__ismbblead, +[](BYTE b) + { return b != '^'; }); + ReplaceFunction((void *)__ismbbtrail, +[](BYTE b) + { return b != '^'; }); + }; + return NewHook(hp, "RScript"); +} \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/engine32/RScript.h b/cpp/LunaHook/LunaHook/engine32/RScript.h new file mode 100644 index 00000000..69f8396d --- /dev/null +++ b/cpp/LunaHook/LunaHook/engine32/RScript.h @@ -0,0 +1,56 @@ + +/* +FILEVERSION 1,0,0,0 +PRODUCTVERSION 3,0,0,0 +FILEFLAGSMASK 0x3F +FILEFLAGS 0x0 +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +FILESUBTYPE 0x0 +{ + BLOCK "StringFileInfo" + { + BLOCK "041104b0" + { + VALUE "Comments" + VALUE "CompanyName", "LiarSoft" + VALUE "FileDescription", "RScript" + VALUE "FileVersion", "1, 0, 0, 0" + VALUE "InternalName", "RScript" + VALUE "LegalCopyright", "Copyright (C)LiarSoft 2001" + VALUE "LegalTrademarks" + VALUE "OriginalFilename", "RScript.exe" + VALUE "PrivateBuild" + VALUE "ProductName", "WindWing RScript" + VALUE "ProductVersion", "3, 0, 0, 0" + VALUE "SpecialBuild" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x411, 1200 + } +} + +*/ +class RScript : public ENGINE +{ +public: + RScript() + { + check_by = CHECK_BY::CUSTOM; + check_by_target = []() + { + auto _ = { + L"grpe\\*.lim", + L"grps\\*.lim", + L"grpo\\*.lim", + L"scr\\*.gsc", + }; + auto checkfile = std::all_of(_.begin(), _.end(), Util::CheckFile); + return checkfile && Util::SearchResourceString(L"RScript"); + }; + is_engine_certain = false; + }; + bool attach_function(); +}; \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/engine32/SRPGStudio.cpp b/cpp/LunaHook/LunaHook/engine32/SRPGStudio.cpp index e5ba9d71..90767b77 100644 --- a/cpp/LunaHook/LunaHook/engine32/SRPGStudio.cpp +++ b/cpp/LunaHook/LunaHook/engine32/SRPGStudio.cpp @@ -7,7 +7,7 @@ bool SRPGStudio::attach_function() { auto dll=GetModuleHandleW(L"OLEAUT32.dll"); if(dll==0)return 0; auto addr=GetProcAddress(dll,"SysAllocString"); - if(addr==0)return 0; + if(!addr)return 0; HookParam hp; hp.address = (DWORD)addr; hp.offset=stackoffset(1); diff --git a/cpp/LunaHook/LunaHook/engine32/Speed.cpp b/cpp/LunaHook/LunaHook/engine32/Speed.cpp index fdb44b62..8cc8ebd8 100644 --- a/cpp/LunaHook/LunaHook/engine32/Speed.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Speed.cpp @@ -11,7 +11,7 @@ bool Speed::attach_function() { BYTE sig4[]={ 0xFF,0xD6 }; for(auto p:std::vector>{{sig1,sizeof(sig1)},{sig2,sizeof(sig2)},{sig3,sizeof(sig3)},{sig4,sizeof(sig4)}}){ addr=MemDbg::findBytes(p.first, p.second, addr, addr+0x40); - if(addr==0)return false; + if(!addr)return false; } addr = MemDbg::findEnclosingAlignedFunction(addr); if (addr == 0)return false; diff --git a/cpp/LunaHook/LunaHook/engine32/TSSystem.cpp b/cpp/LunaHook/LunaHook/engine32/TSSystem.cpp index e2670142..2273e1bf 100644 --- a/cpp/LunaHook/LunaHook/engine32/TSSystem.cpp +++ b/cpp/LunaHook/LunaHook/engine32/TSSystem.cpp @@ -10,7 +10,7 @@ bool TSSystem::attach_function() { auto addrs = Util::SearchMemory(bytes, sizeof(bytes), PAGE_EXECUTE, processStartAddress, processStopAddress); for (auto addr : addrs) { addr=MemDbg::findEnclosingAlignedFunction(addr); - if(addr==0)continue; + if(!addr)continue; HookParam hp; hp.address = addr; hp.offset=stackoffset(1); diff --git a/cpp/LunaHook/LunaHook/engine32/ransel.cpp b/cpp/LunaHook/LunaHook/engine32/ransel.cpp index b1f87027..e0b76a4f 100644 --- a/cpp/LunaHook/LunaHook/engine32/ransel.cpp +++ b/cpp/LunaHook/LunaHook/engine32/ransel.cpp @@ -43,9 +43,9 @@ bool ransel::attach_function() { 0xe8,XX4 //SendMessageA->__imp_SendMessageA }; auto addr=MemDbg::findBytes(sig,sizeof(sig),processStartAddress,processStopAddress); - if(addr==0)return false; + if(!addr)return false; addr=findfuncstart(addr,0x20); - if(addr==0)return false; + if(!addr)return false; HookParam hp; hp.address=addr; hp.type=USING_STRING; diff --git a/cpp/LunaHook/LunaHook/engine64/V8.cpp b/cpp/LunaHook/LunaHook/engine64/V8.cpp index f5e4fff8..5da17f89 100644 --- a/cpp/LunaHook/LunaHook/engine64/V8.cpp +++ b/cpp/LunaHook/LunaHook/engine64/V8.cpp @@ -92,16 +92,16 @@ namespace{ BYTE sig4[]={XX,0x00,0x24,0xA0,0xFC}; addr=forwardsearch(sig1,sizeof(sig1),addr,0x20); - if(addr==0)continue; + if(!addr)continue; addr=forwardsearch(sig2,sizeof(sig2),addr,0x100); - if(addr==0)continue; + if(!addr)continue; addr=forwardsearch(sig3,sizeof(sig3),addr,0x20); - if(addr==0)continue; + if(!addr)continue; addr=forwardsearch(sig4,sizeof(sig4),addr,0x20); - if(addr==0)continue; + if(!addr)continue; auto off=andregimm((BYTE*)addrsave); if(off==regs::invalid)continue; HookParam hp; @@ -164,7 +164,7 @@ namespace{ char innerHTML[]="innerHTML"; auto addr = MemDbg::findBytes(innerHTML, sizeof(innerHTML), processStartAddress, processStopAddress); ConsoleOutput("%x",addr); - if(addr==0)return false; + if(!addr)return false; bool ok=false; for(auto _addr=processStartAddress+4;_addr check_engines() new H_do_C, new Mink3, new FrontWing2, + new RScript, }; } \ No newline at end of file