From 7de41ab004c7a9df03988811768415c5c4d93428 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: Tue, 24 Sep 2024 23:25:45 +0800 Subject: [PATCH] Aisystem6 --- LunaHook/engine32/Silkys.cpp | 39 ++++++++++++++++++++++++++++++++- LunaHook/engine32/Silkys.h | 19 ++++++++++++++++ LunaHook/enginecollection32.cpp | 3 ++- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/LunaHook/engine32/Silkys.cpp b/LunaHook/engine32/Silkys.cpp index 7b7a5f6..7e9cff0 100644 --- a/LunaHook/engine32/Silkys.cpp +++ b/LunaHook/engine32/Silkys.cpp @@ -254,7 +254,7 @@ bool hookBefore(hook_stack *s, void *data1, size_t *len, uintptr_t *role) // FIXME: I am not able to distinguish choice out *role = s->stack[1] ? Engine::NameRole : // arg2 != 0 for name - // s->ebx > 0x0fffffff ? Engine::ChoiceRole : // edx is a pointer for choice + // s->ebx > 0x0fffffff ? Engine::ChoiceRole : // edx is a pointer for choice Engine::ScenarioRole; std::string oldData(arg->getText(), arg->size); @@ -734,4 +734,41 @@ bool Silkysveryveryold_attach_function() bool Silkysveryveryold::attach_function() { return Silkysveryveryold_attach_function() || fob2(); +} + +bool Aisystem6::attach_function() +{ + // 肢体を洗う + const BYTE bytes[] = { + // if ( *(_WORD *)lpString == 0x9381 && v9 == 2 ) + 0x66, 0x8B, 0x01, 0xF7, // mov ax, [ecx] + 0xDD, 0x1B, + 0xED, 0x83, 0xC5, 0x02, + 0xD1, 0xEB, + 0x0F, 0xAF, 0xDD, + 0x66, 0x3D, 0x81, 0x93, // cmp ax, 9381h + }; + ULONG addr = MemDbg::findBytes(bytes, sizeof(bytes), processStartAddress, processStopAddress); + if (!addr) + return false; + addr = MemDbg::findEnclosingAlignedFunction(addr); + if (!addr) + return false; + // 有三个这个同型的函数,分别显示不同的内容,各自只调用一次,在xref里面分发。 + auto addrs = findxref_reverse_checkcallop(addr, addr - 0x1000, addr + 0x1000, 0xe8); + if (addrs.size() != 1) + return false; + addr = MemDbg::findEnclosingAlignedFunction(addrs[0]); + if (!addr) + return false; + HookParam hp; + hp.address = addr; + hp.offset = get_stack(1); + hp.type = USING_STRING | NO_CONTEXT; // 男主自定义人名会被分开 + hp.filter_fun = [](void *data, size_t *len, HookParam *hp) + { + StringCharReplacer((char *)data, len, "\x81\x93", 2, '\n'); + return true; + }; + return NewHook(hp, "Aisystem6"); } \ No newline at end of file diff --git a/LunaHook/engine32/Silkys.h b/LunaHook/engine32/Silkys.h index f01f6ba..7a5a5ca 100644 --- a/LunaHook/engine32/Silkys.h +++ b/LunaHook/engine32/Silkys.h @@ -63,3 +63,22 @@ public: }; bool attach_function(); }; + +class Aisystem6 : public ENGINE +{ +public: + Aisystem6() + { + // 肢体を洗う + check_by = CHECK_BY::CUSTOM; + check_by_target = []() + { + auto check1 = Util::CheckFile(L"script.arc") && Util::CheckFile(L"sequence.arc") && Util::CheckFile(L"mask.arc") && Util::CheckFile(L"bitmap.arc") && Util::CheckFile(L"flag0000"); + if (!check1) + return false; + char AISYSTEM_6[] = "AISYSTEM_6"; + return 0 != MemDbg::findBytes(AISYSTEM_6, sizeof(AISYSTEM_6), processStartAddress, min(processStopAddress, processStartAddress + 0x100000)); + }; + }; + bool attach_function(); +}; \ No newline at end of file diff --git a/LunaHook/enginecollection32.cpp b/LunaHook/enginecollection32.cpp index b06b44f..368c6ea 100644 --- a/LunaHook/enginecollection32.cpp +++ b/LunaHook/enginecollection32.cpp @@ -404,6 +404,7 @@ std::vector check_engines() new RealliveX, new TextXtra_x32, new Stronger, - new RPGMaker + new RPGMaker, + new Aisystem6 }; } \ No newline at end of file