From b46e0538ae0d01857381bd607e8f8f41c104f996 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, 27 Nov 2024 17:27:29 +0800 Subject: [PATCH] . --- cpp/LunaHook/LunaHook/engines/mages/mages.cpp | 42 +++++++++++++-- .../LunaHook/engines/ppsspp/specialgames.hpp | 54 +++++++++++++++++++ cpp/LunaHook/LunaHook/main.cc | 3 +- cpp/LunaHook/LunaHost/GUI/LunaHost.cpp | 3 +- cpp/LunaHook/LunaHost/host.cpp | 3 +- cpp/LunaHook/include/defs.h | 1 + cpp/version.cmake | 8 +-- cpp/version_def.cpp | 2 + 8 files changed, 101 insertions(+), 15 deletions(-) create mode 100644 cpp/version_def.cpp diff --git a/cpp/LunaHook/LunaHook/engines/mages/mages.cpp b/cpp/LunaHook/LunaHook/engines/mages/mages.cpp index b1e88ba7..17a6a038 100644 --- a/cpp/LunaHook/LunaHook/engines/mages/mages.cpp +++ b/cpp/LunaHook/LunaHook/engines/mages/mages.cpp @@ -129,7 +129,7 @@ namespace mages } else if (c == 2) { // line - // do nothing -> back to readChar + // do nothing -> back to readChar } else if (c == 4 || c == 0x15) { // SetColor, EvaluateExpression => SKIP @@ -273,7 +273,7 @@ namespace hookmages buffer->from(s); } - bool MAGES() + bool MAGES_text() { #ifndef _WIN64 auto dialogSigOffset = 2; @@ -371,10 +371,10 @@ namespace hookmages // hookaddr上是没有重复的,pos上是都能读到但有重复。 hp.text_fun = SpecialHookMAGES<0>; hp.type = CODEC_UTF16 | USING_STRING | NO_CONTEXT; - auto _ = NewHook(hp, "5pb_MAGES"); + auto _ = NewHook(hp, "MAGES_text"); hp.address = pos; hp.text_fun = SpecialHookMAGES<1>; - _ |= NewHook(hp, "5pb_MAGES"); + _ |= NewHook(hp, "MAGES_text"); ConsoleOutput("%p %p", hookaddr, pos); return _; @@ -417,9 +417,41 @@ namespace hookmages hp.address = hookaddr; hp.text_fun = SpecialHookMAGES<0>; hp.type = CODEC_UTF16 | USING_STRING | NO_CONTEXT; - return NewHook(hp, "5pb_MAGES"); + return NewHook(hp, "MAGES"); #endif } + void MAGES_mail() + { +#ifndef _WIN64 + BYTE sig1[] = { + 0xe8, XX, XX, XX, 0x00, 0x6a, 0x18, 0x50, 0x68, XX, 0x01, 0x00, 0x00, 0xe8, XX4, 0x8b}; + auto sigsize = sizeof(sig1); + auto addr = MemDbg::findBytes(sig1, sizeof(sig1), processStartAddress, processStopAddress); + if (!addr) + { + BYTE sig2[] = { + 0xe8, XX, XX, XX, 0x00, 0x6a, 0x18, XX, XX, 0xb9, XX, 0x01, 0x00, 0x00, 0xe8, XX4, 0x8b}; + sigsize = sizeof(sig2); + addr = MemDbg::findBytes(sig2, sizeof(sig2), processStartAddress, processStopAddress); + } + if (!addr) + return; + addr += sigsize - 6; + addr += *(int *)(addr + 1) + 5; + HookParam hp; + hp.address = addr; + hp.text_fun = SpecialHookMAGES<0>; + hp.type = CODEC_UTF16 | USING_STRING | NO_CONTEXT; + NewHook(hp, "MAGES_mail"); +#endif + } + bool MAGES() + { + auto succ = MAGES_text(); + if (succ) + MAGES_mail(); + return succ; + } } \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/engines/ppsspp/specialgames.hpp b/cpp/LunaHook/LunaHook/engines/ppsspp/specialgames.hpp index 6b3ce895..96df4d6c 100644 --- a/cpp/LunaHook/LunaHook/engines/ppsspp/specialgames.hpp +++ b/cpp/LunaHook/LunaHook/engines/ppsspp/specialgames.hpp @@ -368,6 +368,30 @@ namespace ppsspp last = s; buffer->from(s); } + void ULJM06289(TextBuffer *buffer, HookParam *hp) + { + StringFilter(buffer, "#n", 2); + StringFilter(buffer, "\x81\x40", 2); + auto s = buffer->strA(); + s = std::regex_replace(s, std::regex("(#[A-Za-z]+\\[(\\d*[.])?\\d+\\])+"), ""); + buffer->from(s); + } + namespace + { + void ULJM05823_1(TextBuffer *buffer, HookParam *hp) + { + StringFilter(buffer, "#n", 2); + auto s = buffer->strA(); + s = std::regex_replace(s, std::regex("(#[A-Za-z]+\\[(\\d*[.])?\\d+\\])+"), ""); + buffer->from(s); + } + void ULJM05823_2(TextBuffer *buffer, HookParam *hp) + { + auto s = buffer->viewA(); + if (s.find("#n") != s.npos) + return buffer->clear(); + } + } std::unordered_map emfunctionhooks = { // Shinigami to Shoujo {0x883bf34, {0, 1, 0, 0, ULJS00403_filter, "ULJS00403"}}, @@ -459,6 +483,36 @@ namespace ppsspp {0x880a744, {0, 0, 0, 0, ULJM05943F, "ULJM0630[23]"}}, // ULJM06302 & ULJM06303 // アーメン・ノワール ポータブル {0x883b6a8, {0, 0, 0, 0, ULJM05943F, "ULJM06064"}}, + // デス・コネクション ポータブル + {0x882AEF4, {0, 0, 0, 0, ULJM05823_1, "ULJM05823"}}, + {0x88B2464, {0, 0, 0, 0, ULJM05823_2, "ULJM05823"}}, // text+name->name + // しらつゆの怪 + {0x888A26C, {0, 0, 0, 0, ULJM06289, "ULJM06289"}}, + // 新装版クローバーの国のアリス~Wonderful Wonder World~ + {0x8875E50, {0, 1, 0, 0, 0, "NPJH50894"}}, + // ダイヤの国のアリス~Wonderful Wonder World~ + {0x8857E3C, {0, 0, 0, 0, 0, "ULJM06216"}}, + // ダイヤの国のアリス~ Wonderful Mirror World ~ + {0x8855AE4, {0, 1, 0, 0, 0, "ULJM06295"}}, + // ハートの国のアリス~Wonderful Twin World~ + {0x8881CAC, {0, 1, 0, 0, 0, "NPJH50872"}}, + // 新装版 ハートの国のアリス~Wonderful Wonder World~ + {0x886B610, {0, 1, 0, 0, 0, "ULJM06332"}}, + // S・Y・K ~新説西遊記~ ポータブル + {0x88DD918, {0, 0, 0, 0, ULJM05823_2, "ULJM05697"}}, // text+name->name + {0x88DA420, {0, 4, 0, 0, ULJM05823_1, "ULJM05697"}}, + // Glass Heart Princess + {0x885FA30, {0, 0, 0, 0, ULJM05823_1, "ULJM06196"}}, + // Glass Heart Princess:PLATINUM + {0x885D4F0, {0, 0, 0, 0, ULJM05823_1, "ULJM06309"}}, + // ウィル・オ・ウィスプ ポータブル + {0x885DD04, {0, 0, 0, 0, ULJM05823_1, "ULJM05447"}}, + // 華鬼 ~恋い初める刻 永久の印~ + {0x8829F14, {0, 4, 0, 0, ULJM05823_1, "ULJM05847"}}, + {0x886D270, {0, 0, 0, 0, ULJM05823_2, "ULJM05847"}}, + // 華鬼 ~夢のつづき~ + {0x88406CC, {0, 0, 0, 0, ULJM05823_1, "ULJM06048"}}, // text + {0x885B7BC, {0, 0, 0, 0, ULJM05823_1, "ULJM06048"}}, // name+text }; } \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/main.cc b/cpp/LunaHook/LunaHook/main.cc index 46dce192..f40192a1 100644 --- a/cpp/LunaHook/LunaHook/main.cc +++ b/cpp/LunaHook/LunaHook/main.cc @@ -37,8 +37,7 @@ DWORD WINAPI Pipe(LPVOID) *(DWORD *)buffer = GetCurrentProcessId(); WriteFile(hookPipe, buffer, sizeof(DWORD), &count, nullptr); - WORD hookversion[4] = LUNA_VERSION; - WriteFile(hookPipe, hookversion, sizeof(hookversion), &count, nullptr); + WriteFile(hookPipe, LUNA_VERSION, sizeof(LUNA_VERSION), &count, nullptr); ConsoleOutput(PIPE_CONNECTED); HIJACK(); diff --git a/cpp/LunaHook/LunaHost/GUI/LunaHost.cpp b/cpp/LunaHook/LunaHost/GUI/LunaHost.cpp index 348eaa11..d24836d5 100644 --- a/cpp/LunaHook/LunaHost/GUI/LunaHost.cpp +++ b/cpp/LunaHook/LunaHost/GUI/LunaHost.cpp @@ -310,10 +310,9 @@ LunaHost::LunaHost() } }) .detach(); - WORD version[4] = LUNA_VERSION; WCHAR vs[32]; - wsprintf(vs, L" | %s v%d.%d.%d", VersionCurrent, version[0], version[1], version[2]); + wsprintf(vs, L" | %s v%d.%d.%d", VersionCurrent, LUNA_VERSION[0], LUNA_VERSION[1], LUNA_VERSION[2]); title += vs; settext(title); std::thread([&]() diff --git a/cpp/LunaHook/LunaHost/host.cpp b/cpp/LunaHook/LunaHost/host.cpp index 817bd8fa..9a56aba4 100644 --- a/cpp/LunaHook/LunaHost/host.cpp +++ b/cpp/LunaHook/LunaHost/host.cpp @@ -102,9 +102,8 @@ namespace Host::AddConsoleOutput(FormatString(PROC_CONN,processId)); //CreatePipe(); WORD hookversion[4]; - WORD hostversion[4]=LUNA_VERSION; if( ReadFile(hookPipe, hookversion, sizeof(hookversion), &bytesRead, nullptr)){ - if(memcmp(hostversion,hookversion,sizeof(hookversion))!=0) + if(memcmp(hookversion,LUNA_VERSION,sizeof(hookversion))!=0) Host::Warning(UNMATCHABLEVERSION); } diff --git a/cpp/LunaHook/include/defs.h b/cpp/LunaHook/include/defs.h index 510fc81a..0cb47a82 100644 --- a/cpp/LunaHook/include/defs.h +++ b/cpp/LunaHook/include/defs.h @@ -32,4 +32,5 @@ constexpr auto LUNA_HOOK_DLL = LUNA_HOOK_DLL_64; // .dll but LoadLibrary automat constexpr auto LUNA_HOOK_DLL = LUNA_HOOK_DLL_32; // .dll but LoadLibrary automatically adds that #endif +extern WORD LUNA_VERSION[4]; // EOF diff --git a/cpp/version.cmake b/cpp/version.cmake index 36274c96..e0bee9c4 100644 --- a/cpp/version.cmake +++ b/cpp/version.cmake @@ -1,10 +1,10 @@ set(VERSION_MAJOR 6) set(VERSION_MINOR 6) -set(VERSION_PATCH 7) +set(VERSION_PATCH 8) set(VERSION_REVISION 0) set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}") -add_library(VERSION_DEF INTERFACE) -target_compile_definitions(VERSION_DEF INTERFACE - LUNA_VERSION=${LUNA_VERSION}) +add_library(VERSION_DEF ${CMAKE_CURRENT_LIST_DIR}/version_def.cpp) +target_compile_definitions(VERSION_DEF PRIVATE + LUNA_VERSION_=${LUNA_VERSION}) include(${CMAKE_CURRENT_LIST_DIR}/version/generate_product_version.cmake) \ No newline at end of file diff --git a/cpp/version_def.cpp b/cpp/version_def.cpp new file mode 100644 index 00000000..37a683d1 --- /dev/null +++ b/cpp/version_def.cpp @@ -0,0 +1,2 @@ +#include +WORD LUNA_VERSION[4] = LUNA_VERSION_; \ No newline at end of file