From 68575aee1abaaad44f00a9a95d615801b9830a71 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: Thu, 9 Jan 2025 11:58:55 +0800 Subject: [PATCH] . --- .../LunaHook/engines/ppsspp/specialgames.hpp | 24 ++++++++++++++++++- cpp/LunaHook/LunaHook/hookfinder.cc | 10 ++++++-- cpp/LunaHook/LunaHook/texthook.cc | 6 ++++- cpp/LunaHook/LunaHook/veh_hook.cpp | 13 +++++----- cpp/version.cmake | 2 +- 5 files changed, 44 insertions(+), 11 deletions(-) diff --git a/cpp/LunaHook/LunaHook/engines/ppsspp/specialgames.hpp b/cpp/LunaHook/LunaHook/engines/ppsspp/specialgames.hpp index b3e56b0e..ff71ca2b 100644 --- a/cpp/LunaHook/LunaHook/engines/ppsspp/specialgames.hpp +++ b/cpp/LunaHook/LunaHook/engines/ppsspp/specialgames.hpp @@ -892,6 +892,21 @@ namespace ppsspp strReplace(s, "#n", ""); buffer->from(s); } + void ULJM05703(TextBuffer *buffer, HookParam *hp) + { + auto s = buffer->strA(); + s = std::regex_replace(s, std::regex(R"(#Kana\[(.*?),(.*?)\])"), "$1"); + strReplace(s, "\x81\x40", ""); + buffer->from(s); + ULJM05943F(buffer, hp); + } + void ULJM05915(TextBuffer *buffer, HookParam *hp) + { + auto s = buffer->strA(); + strReplace(s, "#n#", "\n#"); + buffer->from(s); + ULJM05943F(buffer, hp); + } void FULJM05889(TextBuffer *buffer, HookParam *) { auto text = reinterpret_cast(buffer->buff); @@ -929,7 +944,6 @@ namespace ppsspp s = std::regex_replace(s, std::regex("\\n+"), ""); buffer->from(s); } - void ULJM05441(hook_context *context, HookParam *hp, TextBuffer *buffer, uintptr_t *split) { auto data = PPSSPP::emu_arg(context)[1]; @@ -1718,6 +1732,8 @@ namespace ppsspp {0x88C0410, {0, 2, 0, 0, ULJM05019, "ULJM05019"}}, // 遙かなる時空の中で3 with 十六夜記 愛蔵版 {0x89024C8, {0, 0, 0, ULJM05441, 0, "ULJM05441"}}, + // 遙かなる時空の中で3 運命の迷宮 愛蔵版 + {0x89081f4, {0, 0, 0, ULJM05441, 0, "ULJM05547"}}, // 遙かなる時空の中で4 愛蔵版 {0x8955CE0, {0, 0, 0, ULJM05810, 0, "ULJM05810"}}, // 遙かなる時空の中で5 風花記 @@ -2060,5 +2076,11 @@ namespace ppsspp {0x88E08D0, {0, 3, 0, 0, 0, "ULJM0610[78]"}}, // 花帰葬 {0x88139f4, {CODEC_UTF16, 0, 0, 0, ULJM05701, "ULJM05701"}}, + // 死神所業~怪談ロマンス~ + {0x8857390, {0, 1, 0, 0, 0, "ULJM06334"}}, + // 二世の契り + {0x888D34C, {0, 3, 0, 0, ULJM05703, "ULJM05703"}}, + // 二世の契り 想い出の先へ + {0x88744A8, {0, 3, 0, 0, ULJM05915, "ULJM05915"}}, }; } \ No newline at end of file diff --git a/cpp/LunaHook/LunaHook/hookfinder.cc b/cpp/LunaHook/LunaHook/hookfinder.cc index b8d1d647..84b81125 100644 --- a/cpp/LunaHook/LunaHook/hookfinder.cc +++ b/cpp/LunaHook/LunaHook/hookfinder.cc @@ -256,9 +256,12 @@ void SafeSendJitVeh(hook_context *context, uintptr_t address, uint64_t em_addr, { } } +bool safeleave = false; std::unordered_map addresscalledtime; bool SendJitVeh(PCONTEXT pcontext, uintptr_t address, uint64_t em_addr, JITTYPE jittype, intptr_t padding) { + if (safeleave) + return false; if (addresscalledtime.find(address) == addresscalledtime.end()) addresscalledtime[address] = 0; auto tm = GetTickCount64(); @@ -555,10 +558,11 @@ void _SearchForHooks(SearchParam spUser) auto f = fopen("1.txt", "a"); for (auto addr : jitaddr2emuaddr) { - fprintf(f, "%llx => %llx\n", addr.second.second, addr.first); + fprintf(f, "%llx => %p\n", addr.second.second, addr.first); } fclose(f); #endif + safeleave = false; std::vector funcs; std::vector successaddr; for (auto addr : jitaddr2emuaddr) @@ -574,7 +578,9 @@ void _SearchForHooks(SearchParam spUser) ConsoleOutput(TR[HOOK_SEARCH_INITIALIZED], successaddr.size()); ConsoleOutput(TR[MAKE_GAME_PROCESS_TEXT], sp.searchTime / 1000); Sleep(sp.searchTime); - remove_veh_hook(successaddr); + // remove_veh_hook(successaddr); + // remove_veh_hook还是有问题,容易崩 + safeleave = true; } SearchForHooks_Return(); } diff --git a/cpp/LunaHook/LunaHook/texthook.cc b/cpp/LunaHook/LunaHook/texthook.cc index 5ed15ea8..482e8fb6 100644 --- a/cpp/LunaHook/LunaHook/texthook.cc +++ b/cpp/LunaHook/LunaHook/texthook.cc @@ -443,10 +443,14 @@ bool TextHook::breakpointcontext(PCONTEXT pcontext) context.toPCONTEXT(pcontext); return true; } +extern bool safeleave; bool TextHook::InsertBreakPoint() { // MH_CreateHook 64位unity/yuzu-emu经常 MH_ERROR_MEMORY_ALLOC - return add_veh_hook(location, std::bind(&TextHook::breakpointcontext, this, std::placeholders::_1)); + for (int i = 0; i < 1 + safeleave; i++) + if (add_veh_hook(location, std::bind(&TextHook::breakpointcontext, this, std::placeholders::_1))) + return true; + return false; } void TextHook::RemoveBreakPoint() { diff --git a/cpp/LunaHook/LunaHook/veh_hook.cpp b/cpp/LunaHook/LunaHook/veh_hook.cpp index 866176ea..f0c523d2 100644 --- a/cpp/LunaHook/LunaHook/veh_hook.cpp +++ b/cpp/LunaHook/LunaHook/veh_hook.cpp @@ -108,12 +108,13 @@ bool __remove_veh_hook(void *origFunc) void remove_veh_hook(void *origFunc) { // 仅会在手动移除时被调用 - while (true) - { - std::lock_guard _(vehlistlock); - if (__remove_veh_hook(origFunc)) - break; - } + // while (true) + // { + // std::lock_guard _(vehlistlock); + if (__remove_veh_hook(origFunc)) + ; + // break; + //} } void remove_veh_hook(std::vector origFuncs) { diff --git a/cpp/version.cmake b/cpp/version.cmake index 5057f0b8..39c2eb30 100644 --- a/cpp/version.cmake +++ b/cpp/version.cmake @@ -1,7 +1,7 @@ set(VERSION_MAJOR 6) set(VERSION_MINOR 19) -set(VERSION_PATCH 1) +set(VERSION_PATCH 2) 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)