From d3a6a81defae2a73255d7bbb995be1c83e5b9522 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: Wed, 30 Oct 2024 11:13:55 +0800 Subject: [PATCH] Cage --- LunaHook/CMakeLists.txt | 2 +- LunaHook/engine32/Cage.cpp | 78 +++++++++++++++++++++++++++++++++ LunaHook/engine32/Cage.h | 14 ++++++ LunaHook/enginecollection32.cpp | 2 + 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 LunaHook/engine32/Cage.cpp create mode 100644 LunaHook/engine32/Cage.h diff --git a/LunaHook/CMakeLists.txt b/LunaHook/CMakeLists.txt index d839396..1a8ac97 100644 --- a/LunaHook/CMakeLists.txt +++ b/LunaHook/CMakeLists.txt @@ -4,7 +4,7 @@ if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) set(enginepath "engine64") set(collector "enginecollection64.cpp") else() - set(enginessrc AGE_System AksysGames RPGMaker Stronger TACTICS Onscripter Sceplay DISCOVERY Erogos godot A98SYS GuruGuruSMF4 TeethingRing Fizz CoffeeMaker VALKYRIA mirage CisLugI tamasoft FrontWing solfasys Diskdream splushwave ransel akatombo GASTRO GSX Aksys ScrPlayer SYSD KISS IGScript Jellyfish BKEngine Overflow SRPGStudio Suika2 FVP LCScript Ohgetsu RPGMakerRGSS3 ONScripterru OVERDRIVE HXP Palette Purple Ruf RUNE Tarte Tomato Sakuradog Troy VitaminSoft UnknownEngine TSSystem Xbangbang Anisetta Nijyuei Interheart LovaGame Giga Jisatu101 EntisGLS Ciel ACTGS TerraLunar PPSSPP jukujojidai PCSX2 VanillawareGC cef V8 mono pchooks PONScripter Bishop sakanagl Lightvn KiriKiri SideB BGI Bootup morning shyakunage Regista NNNConfig Eushully Majiro littlecheese Elf Silkys CMVS Wolf Circus1 Circus2 Cotopha Artemis CatSystem Atelier Tenco QLIE Pal AIL2 NeXAS LunaSoft Unicorn Rejet Interlude AdobeAir Retouch Malie Live Nexton Lucifen Waffle TinkerBell SystemAoi Yuris Nitroplus2 Bruns EME RRE Candy Speed ApricoT Triangle AB2Try MBLMED GameMaker DxLib CodeX Minori Sprite RpgmXP Eagls Debonosu C4 WillPlus Tanuki GXP AOS Mink YukaSystem2 sakusesu Exp 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) + set(enginessrc Cage AGE_System AksysGames RPGMaker Stronger TACTICS Onscripter Sceplay DISCOVERY Erogos godot A98SYS GuruGuruSMF4 TeethingRing Fizz CoffeeMaker VALKYRIA mirage CisLugI tamasoft FrontWing solfasys Diskdream splushwave ransel akatombo GASTRO GSX Aksys ScrPlayer SYSD KISS IGScript Jellyfish BKEngine Overflow SRPGStudio Suika2 FVP LCScript Ohgetsu RPGMakerRGSS3 ONScripterru OVERDRIVE HXP Palette Purple Ruf RUNE Tarte Tomato Sakuradog Troy VitaminSoft UnknownEngine TSSystem Xbangbang Anisetta Nijyuei Interheart LovaGame Giga Jisatu101 EntisGLS Ciel ACTGS TerraLunar PPSSPP jukujojidai PCSX2 VanillawareGC cef V8 mono pchooks PONScripter Bishop sakanagl Lightvn KiriKiri SideB BGI Bootup morning shyakunage Regista NNNConfig Eushully Majiro littlecheese Elf Silkys CMVS Wolf Circus1 Circus2 Cotopha Artemis CatSystem Atelier Tenco QLIE Pal AIL2 NeXAS LunaSoft Unicorn Rejet Interlude AdobeAir Retouch Malie Live Nexton Lucifen Waffle TinkerBell SystemAoi Yuris Nitroplus2 Bruns EME RRE Candy Speed ApricoT Triangle AB2Try MBLMED GameMaker DxLib CodeX Minori Sprite RpgmXP Eagls Debonosu C4 WillPlus Tanuki GXP AOS Mink YukaSystem2 sakusesu Exp 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) set(enginepath "engine32") set(collector "enginecollection32.cpp") endif() diff --git a/LunaHook/engine32/Cage.cpp b/LunaHook/engine32/Cage.cpp new file mode 100644 index 0000000..6df0506 --- /dev/null +++ b/LunaHook/engine32/Cage.cpp @@ -0,0 +1,78 @@ +#include "Cage.h" + +bool Cage::attach_function() +{ + // https://vndb.org/v8381 + // 夢姿 ~ゆめのすがた~ + /* + size_t __cdecl _mbslen(const unsigned __int8 *String) +{ +const unsigned __int8 *v2; // eax +size_t i; // esi + +if ( !dword_476AFC ) +return strlen((const char *)String); +_lock(25); +v2 = String; +for ( i = 0; *v2; ++i ) +{ +if ( (byte_476C01[*v2] & 4) != 0 && !*++v2 ) +break; +++v2; +} +_unlock(25); +return i; +} + */ + /* + .text:00451B0C mov eax, [esp+8+String] +.text:00451B10 pop ecx +.text:00451B11 xor esi, esi +.text:00451B13 +.text:00451B13 loc_451B13: ; CODE XREF: __mbslen+3D↓j +.text:00451B13 mov cl, [eax] +.text:00451B15 test cl, cl +.text:00451B17 jz short loc_451B2F +.text:00451B19 movzx ecx, cl +.text:00451B1C test byte_476C01[ecx], 4 +.text:00451B23 jz short loc_451B2B +.text:00451B25 inc eax +.text:00451B26 cmp byte ptr [eax], 0 +.text:00451B29 jz short loc_451B2F +.text:00451B2B +.text:00451B2B loc_451B2B: ; CODE XREF: __mbslen+33↑j +.text:00451B2B inc esi +.text:00451B2C inc eax +.text:00451B2D jmp short loc_451B13 + */ + BYTE check[] = { + //clang-format off + 0x8B, 0x44, 0x24, 0x0C, + 0x59, + 0x33, 0xF6, + 0x8A, 0x08, + 0x84, 0xC9, + 0x74, 0x16, + 0x0F, 0xB6, 0xC9, + 0xF6, 0x81, XX4, 0x04, + 0x74, 0x06, + 0x40, + 0x80, 0x38, 0x00, + 0x74, 0x04, + 0x46, + 0x40, + 0xEB, 0xE4 + //clang-format on + }; + auto addrx = MemDbg::findBytes(check, sizeof(check), processStartAddress, processStopAddress); + if (!addrx) + return false; + addrx = MemDbg::findEnclosingAlignedFunction(addrx); + if (!addrx) + return 0; + HookParam hp; + hp.address = addrx; + hp.type = USING_STRING; + hp.offset = get_stack(1); + return NewHook(hp, "Cage"); +} \ No newline at end of file diff --git a/LunaHook/engine32/Cage.h b/LunaHook/engine32/Cage.h new file mode 100644 index 0000000..bc7e36f --- /dev/null +++ b/LunaHook/engine32/Cage.h @@ -0,0 +1,14 @@ + + +class Cage : public ENGINE +{ +public: + Cage() + { + // https://vndb.org/v8381 + // 夢姿 ~ゆめのすがた~ + check_by = CHECK_BY::FILE_ALL; + check_by_target = check_by_list{L"script.msb", L"data*.ym"}; + }; + bool attach_function(); +}; \ No newline at end of file diff --git a/LunaHook/enginecollection32.cpp b/LunaHook/enginecollection32.cpp index cf67908..797b979 100644 --- a/LunaHook/enginecollection32.cpp +++ b/LunaHook/enginecollection32.cpp @@ -9,6 +9,7 @@ #include "engine32/Tarte.h" #include "engine32/sakanagl.h" #include "engine32/LCScript.h" +#include "engine32/Cage.h" #include "engine32/ONScripterru.h" #include "engine32/CoffeeMaker.h" #include "engine32/TACTICS.h" @@ -410,5 +411,6 @@ std::vector check_engines() new Aisystem6, new AksysGames, new AGE_System, + new Cage, }; } \ No newline at end of file