diff --git a/cpp/LunaHook/LunaHook/CMakeLists.txt b/cpp/LunaHook/LunaHook/CMakeLists.txt index 5fc9dd77..845aad3c 100644 --- a/cpp/LunaHook/LunaHook/CMakeLists.txt +++ b/cpp/LunaHook/LunaHook/CMakeLists.txt @@ -4,7 +4,7 @@ if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) set(enginepath "engine64") set(collector "enginecollection64.cpp") else() - set(enginessrc Moonstone Aromarie Winters 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 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 T2U Moonstone Aromarie Winters 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 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/cpp/LunaHook/LunaHook/engine32/Artemis.cpp b/cpp/LunaHook/LunaHook/engine32/Artemis.cpp index 8e294ee8..dad614f7 100644 --- a/cpp/LunaHook/LunaHook/engine32/Artemis.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Artemis.cpp @@ -208,7 +208,7 @@ bool InsertArtemis3Hook() HookParam hp; hp.address = addr; hp.offset = get_stack(1); - hp.type = USING_STRING | EMBED_ABLE | CODEC_UTF8 | EMBED_AFTER_NEW; + hp.type = USING_STRING | EMBED_ABLE | CODEC_UTF8 | EMBED_AFTER_NEW; return NewHook(hp, "EmbedArtemis"); } @@ -263,8 +263,128 @@ namespace return false; } } +namespace +{ + bool artemis() + { + /* + char __cdecl sub_417EF0(char a1, _DWORD *a2, int a3) +{ + int i; // [esp+0h] [ebp-4h] + + if ( !a3 ) + { + if ( ((unsigned __int8)a1 ^ 0x20u) - 161 < 0x3C ) + { + if ( a2 ) + *a2 = 1; + return 1; + } + return 0; + } + if ( a3 == 1 ) + { + if ( ((unsigned __int8)a1 < 0xA1u || (unsigned __int8)a1 > 0xF4u) && (unsigned __int8)a1 != 142 ) + return 0; + if ( a2 ) + *a2 = 1; + + 这个和64位的那个是一样的,但是这个函数在64位下是内联的,32位不内联,所以必须xref一下 + */ + const BYTE BYTES[] = { + 0x0f, 0xb6, 0x45, 0x08, + 0x83, 0xf0, 0x20, + 0x2d, 0xa1, 0x00, 0x00, 0x00, + 0x83, 0xf8, 0x3c, + 0x73, XX4 + + }; + ULONG addr = MemDbg::findBytes(BYTES, sizeof(BYTES), processStartAddress, processStopAddress); + if (!addr) + return false; + addr = MemDbg::findEnclosingAlignedFunction(addr); + if (!addr) + return false; + for (auto addr_1 : findxref_reverse_checkcallop(addr, processStartAddress, processStopAddress, 0xe8)) + { + /* + char __cdecl sub_417EF0(char a1, _DWORD *a2, int a3) +{ + int i; // [esp+0h] [ebp-4h] + + if ( !a3 ) + { + if ( ((unsigned __int8)a1 ^ 0x20u) - 161 < 0x3C ) + { + if ( a2 ) + *a2 = 1; + return 1; + } + return 0; + } + if ( a3 == 1 ) + { + if ( ((unsigned __int8)a1 < 0xA1u || (unsigned __int8)a1 > 0xF4u) && (unsigned __int8)a1 != 142 ) + return 0; + if ( a2 ) + *a2 = 1; + return 1; + } + else + { + if ( a3 != 2 || (a1 & 0x80) == 0 ) + return 0; + if ( a2 ) + { + *a2 = -1; + for ( i = 128; (i & a1) != 0; i >>= 1 ) + ++*a2; + } + return 1; + } +} + */ + /* + .text:006032CC cmp [ebp+var_10], 3FFh + .text:006032D3 jge short loc_603315 + .text:006032D5 mov edx, [ebp+var_8] + .text:006032D8 movsx eax, byte ptr [edx] + .text:006032DB cmp eax, 41h ; 'A' + .text:006032DE jl short loc_6032EB + .text:006032E0 mov ecx, [ebp+var_8] + .text:006032E3 movsx edx, byte ptr [ecx] + .text:006032E6 cmp edx, 5Ah ; 'Z' + .text:006032E9 jle short loc_603301 + .text:006032EB + .text:006032EB loc_6032EB: ; CODE XREF: sub_603210+CE↑j + .text:006032EB mov eax, [ebp+var_8] + .text:006032EE movsx ecx, byte ptr [eax] + .text:006032F1 cmp ecx, 61h ; 'a' + .text:006032F4 jl short loc_603311 + .text:006032F6 mov edx, [ebp+var_8] + .text:006032F9 movsx eax, byte ptr [edx] + .text:006032FC cmp eax, 7Ah ; 'z' + .text:006032FF jg short loc_603311 + */ + BYTE sig[] = { + 0x81, 0x7d, 0xf0, 0xff, 0x03, 0x00, 0x00}; + if (MemDbg::findBytes(sig, sizeof(sig), addr_1, addr_1 + 0x100)) + { + addr = MemDbg::findEnclosingAlignedFunction(addr_1); + if (!addr) + return false; + HookParam hp; + hp.address = addr; + hp.type = USING_STRING | CODEC_UTF8; + hp.offset = get_stack(1); + return NewHook(hp, "Artemis"); + } + } + return false; + } +} bool Artemis::attach_function() { - return InsertArtemis1Hook() || InsertArtemis2Hook() || InsertArtemis3Hook() || a4(); + return artemis() | (InsertArtemis1Hook() || InsertArtemis2Hook() || InsertArtemis3Hook() || a4()); } \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/engine32/T2U.cpp b/cpp/LunaHook/LunaHook/engine32/T2U.cpp new file mode 100644 index 00000000..88cbafc7 --- /dev/null +++ b/cpp/LunaHook/LunaHook/engine32/T2U.cpp @@ -0,0 +1,20 @@ +#include "T2U.h" + +bool T2U::attach_function() +{ + //(18禁ゲーム)[000128][BLUE GALE] Treating2U (bin+cue) + HookParam hp; + hp.address = (DWORD)TextOutA; // 这个游戏设置embed_hook_font会卡死 + hp.type = USING_STRING; + hp.offset = get_stack(4); + hp.filter_fun = [](TextBuffer *buffer, HookParam *hp) + { + static lru_cache cache(5); + auto s = buffer->strA(); + if (cache.touch(s)) + { + return buffer->clear(); + } + }; + return NewHook(hp, "T2U"); +} \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/engine32/T2U.h b/cpp/LunaHook/LunaHook/engine32/T2U.h new file mode 100644 index 00000000..7b18089c --- /dev/null +++ b/cpp/LunaHook/LunaHook/engine32/T2U.h @@ -0,0 +1,17 @@ + + +class T2U : public ENGINE +{ +public: + T2U() + { + //(18禁ゲーム)[000128][BLUE GALE] Treating2U (bin+cue) + check_by = CHECK_BY::CUSTOM; + check_by_target = []() + { + auto _ = {L"*.zbm", L"scene00.bdt", L"*.dat", L"*.Snn"}; + return std::all_of(_.begin(), _.end(), Util::CheckFile); + }; + }; + bool attach_function(); +}; \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/engine32/Yuris.cpp b/cpp/LunaHook/LunaHook/engine32/Yuris.cpp index 641e3a0f..fc64d5b2 100644 --- a/cpp/LunaHook/LunaHook/engine32/Yuris.cpp +++ b/cpp/LunaHook/LunaHook/engine32/Yuris.cpp @@ -259,11 +259,10 @@ static void Yuris6Filter(TextBuffer *buffer, HookParam *) { auto text = reinterpret_cast(buffer->buff); - static std::string prevText; - - if (prevText.length() == buffer->size && prevText.find(text, 0, buffer->size) != std::string::npos) // Check if the string is present in the previous one + static std::string last; + if (last == buffer->viewA()) return buffer->clear(); - prevText.assign(text, buffer->size); + last = buffer->viewA(); // ruby <手水舎/ちょうずや> if (cpp_strnstr(text, "\x81\x83", buffer->size)) @@ -279,8 +278,11 @@ static void Yuris6Filter(TextBuffer *buffer, HookParam *) } CharReplacer(buffer, '=', '-'); - StringCharReplacer(buffer, "\xEF\xF0", 2, ' '); + StringFilter(buffer, "\xEF\xF0", 2); + StringFilter(buffer, "\xEF\xF1", 2); StringFilter(buffer, "\xEF\xF2", 2); + StringFilter(buffer, "\xEF\xF3", 2); + StringFilter(buffer, "\xEF\xF4", 2); StringFilter(buffer, "\xEF\xF5", 2); StringFilter(buffer, "\x81\x98", 2); } @@ -380,19 +382,35 @@ bool yuris8() 0x8b, 0x94, 0x24, XX, 0, 0, 0, 0x8b, 0x8c, 0x24, XX, 0, 0, 0, 0xe8, XX4}; + const BYTE bytes2[] = { + 0x8b, XX, + 0x8b, 0x94, 0x24, XX, 0, 0, 0, + 0x8b, 0x8c, 0x24, XX, 0, 0, 0, + 0xe8, XX4, + 0xeb, XX, + 0x8b, XX, + 0x8b, XX, + 0x8b, 0x8c, 0x24, XX, 0, 0, 0, + 0xe8, XX4}; + // 这两个E8调用的同一个函数,上面的那个更全一点,下面的这个有的会漏。不过无所谓了,其他钩子关于,就不改这个了。 + int offset = sizeof(bytes) - 5; ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress); + if (!addr) + { + addr = MemDbg::findBytes(bytes2, sizeof(bytes2), processStartAddress, processStopAddress); + offset = sizeof(bytes2) - 5; + } if (!addr) return false; - HookParam hp; - hp.address = addr + sizeof(bytes) - 5; + hp.address = addr + offset; hp.type = USING_STRING; hp.offset = get_reg(regs::ecx); hp.filter_fun = [](TextBuffer *buffer, HookParam *hp) { auto text = buffer->viewA(); if (std::all_of(text.begin(), text.end(), [](char c) - { return c == '1' || c == '2' || c == 'E'; })) + { return c == '1' || c == '2' || c == 'E' || c == 'C' || c == 'c' || c == 'R' || c == 'P' || c == 'Z'; })) return buffer->clear(); }; return NewHook(hp, "yuris8"); diff --git a/cpp/LunaHook/LunaHook/enginecollection32.cpp b/cpp/LunaHook/LunaHook/enginecollection32.cpp index ac92357a..2cca24a4 100644 --- a/cpp/LunaHook/LunaHook/enginecollection32.cpp +++ b/cpp/LunaHook/LunaHook/enginecollection32.cpp @@ -109,6 +109,7 @@ #include "engine32/XUSE.h" #include "engine32/RPGMaker.h" #include "engine32/EME.h" +#include "engine32/T2U.h" #include "engine32/RRE.h" #include "engine32/Sceplay.h" #include "engine32/Onscripter.h" @@ -416,5 +417,6 @@ std::vector check_engines() new Winters, new Aromarie, new Moonstone, + new T2U, }; } \ No newline at end of file diff --git a/cpp/version.cmake b/cpp/version.cmake index 28b9f419..ed4a6338 100644 --- a/cpp/version.cmake +++ b/cpp/version.cmake @@ -1,7 +1,7 @@ set(VERSION_MAJOR 6) set(VERSION_MINOR 9) -set(VERSION_PATCH 4) +set(VERSION_PATCH 5) set(VERSION_REVISION 0) set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}") add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp)