From ac7843ee40193bb3fa29f6a3515332d7eb121bbf 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: Sat, 9 Nov 2024 15:13:27 +0800 Subject: [PATCH] some --- cpp/LunaHook/LunaHook/engine64/yuzu.cpp | 44 +++++++++++++++++++++++-- cpp/LunaHook/LunaHook/util/util.h | 13 +++++--- cpp/LunaHook/include/stringutils.cpp | 10 +++--- cpp/version.cmake | 2 +- py/LunaTranslator/myutils/config.py | 9 ++++- 5 files changed, 63 insertions(+), 15 deletions(-) diff --git a/cpp/LunaHook/LunaHook/engine64/yuzu.cpp b/cpp/LunaHook/LunaHook/engine64/yuzu.cpp index 858b068f859..89a6488da46 100644 --- a/cpp/LunaHook/LunaHook/engine64/yuzu.cpp +++ b/cpp/LunaHook/LunaHook/engine64/yuzu.cpp @@ -912,7 +912,7 @@ namespace } void F0100B0601852A000(TextBuffer *buffer, HookParam *hp) { - auto s = buffer->strW(); + auto s = buffer->viewW(); static std::wstring last; if (last == s) return buffer->clear(); @@ -920,7 +920,7 @@ namespace } void F010027100C79A000(TextBuffer *buffer, HookParam *hp) { - auto s = buffer->strA(); + auto s = buffer->viewA(); static std::string last; if (last == s) return buffer->clear(); @@ -1775,6 +1775,18 @@ namespace s = std::regex_replace(s, std::regex("@[0-9]"), ""); buffer->from(s); } + void F01000EA00B23C000(TextBuffer *buffer, HookParam *hp) + { + auto s = buffer->strW(); + s = std::regex_replace(s, std::wregex(L"[`@](.*?)@"), L"$1"); + s = std::regex_replace(s, std::wregex(L"\\$\\[(.*?)\\$/(.*?)\\$\\]"), L"$1"); + s = std::regex_replace(s, std::wregex(L"\\$K\\d+(.*?)\\$K\\d+"), L"$1"); + s = std::regex_replace(s, std::wregex(L"\\$A\\d+"), L""); + strReplace(s, L"$2", L"花"); + strReplace(s, L"$1", L"山田"); + strReplace(s, L"$(3)", L"花"); + buffer->from(s); + } void F010060301588A000(TextBuffer *buffer, HookParam *hp) { auto s = buffer->strA(); @@ -2059,7 +2071,24 @@ namespace namespace { #pragma optimize("", off) - // 必须禁止优化这个函数,或者引用一下参数,否则参数被优化没了。 + void TT0100A4700BC98000(const char *_) {} +#pragma optimize("", on) + + void T0100A4700BC98000(TextBuffer *buffer, HookParam *) + { + auto s = buffer->strA(); + HookParam hp; + hp.address = (uintptr_t)TT0100A4700BC98000; + hp.offset = GETARG1; + hp.type = CODEC_UTF8 | USING_STRING; + static auto _ = NewHook(hp, "0100A4700BC98000"); + TT0100A4700BC98000(s.c_str()); + // buffer->clear(); + } + } + namespace + { +#pragma optimize("", off) void F01006530151F0000_collect(const wchar_t *_) {} #pragma optimize("", on) void F01006530151F0000(TextBuffer *buffer, HookParam *) @@ -3284,6 +3313,15 @@ namespace // Money Parasite ~Usotsuki na Onna~ {0x2169ac, {0, 0, 0, 0, F0100A250191E8000, "0100A250191E8000", "1.0.0"}}, {0x217030, {0, 0, 0, 0, F0100A250191E8000, "0100A250191E8000", "1.0.0"}}, + // 三国恋戦記~オトメの兵法!~ + {0x800644A0, {CODEC_UTF16, 1, 0, 0, F01000EA00B23C000, "01000EA00B23C000", "1.0.0"}}, + // 三国恋戦記~思いでがえし~+学園恋戦記 + {0x80153B20, {CODEC_UTF16, 8, 0, 0, F01000EA00B23C000, "01003B6014B38000", "1.0.0"}}, + // 殺人探偵ジャック・ザ・リッパー + {0x8000ED30, {CODEC_UTF8, 0, 0, 0, T0100A4700BC98000, "0100A4700BC98000", "1.0.0"}}, // 1.0.0有漏的 + {0x8000ED1C, {CODEC_UTF8, 0, 0, 0, T0100A4700BC98000, "0100A4700BC98000", "1.0.0"}}, + {0x8000ED3C, {CODEC_UTF8, 0, 0, 0, T0100A4700BC98000, "0100A4700BC98000", "1.0.0"}}, + {0x8003734C, {CODEC_UTF8, 2, 0, 0, F010027100C79A000, "0100A4700BC98000", "1.0.2"}}, // 完整 }; return 1; }(); diff --git a/cpp/LunaHook/LunaHook/util/util.h b/cpp/LunaHook/LunaHook/util/util.h index e0e50592bc5..4b2f6548b63 100644 --- a/cpp/LunaHook/LunaHook/util/util.h +++ b/cpp/LunaHook/LunaHook/util/util.h @@ -94,20 +94,23 @@ struct WindowInfo }; std::vector get_proc_windows(); +template +size_t strSize(const StringT &s) +{ + return s.size() * sizeof(StringT::value_type); +} + template auto allocateString(const StringT &s) -> typename StringT::value_type * { size_t t = s.size(); typename StringT::value_type *_data = new typename StringT::value_type[t + 1]; strcpyEx(_data, s.data()); + memcpy(_data, s.data(), strSize(s)); + _data[t] = 0; return _data; } -template -size_t strSize(const StringT &s) -{ - return s.size() * sizeof(StringT::value_type); -} bool IsShiftjisWord(WORD w); bool IsShiftjisLeadByte(BYTE b); diff --git a/cpp/LunaHook/include/stringutils.cpp b/cpp/LunaHook/include/stringutils.cpp index fbc6ca24b5d..79d9069c272 100644 --- a/cpp/LunaHook/include/stringutils.cpp +++ b/cpp/LunaHook/include/stringutils.cpp @@ -101,7 +101,7 @@ std::optional StringToWideString(const std::string &text, UINT enc std::optional StringToWideString(std::string_view text, UINT encoding) { - std::vector buffer(text.size() + 1); + std::vector buffer(text.size()); if (disable_mbwc) { int _s = text.size(); @@ -122,8 +122,8 @@ std::optional StringToWideString(std::string_view text, UINT encod } else { - if (int length = MultiByteToWideChar(encoding, 0, text.data(), text.size() + 1, buffer.data(), buffer.size())) - return std::wstring(buffer.data(), length - 1); + if (int length = MultiByteToWideChar(encoding, 0, text.data(), text.size(), buffer.data(), buffer.size())) + return std::wstring(buffer.data(), length); return {}; } } @@ -157,7 +157,7 @@ std::string WideStringToString(const wchar_t *text, UINT cp) } std::string WideStringToString(std::wstring_view text, UINT cp) { - std::vector buffer((text.size() + 1) * 4); + std::vector buffer((text.size()) * 4); if (disable_wcmb) { int _s = text.size(); @@ -178,7 +178,7 @@ std::string WideStringToString(std::wstring_view text, UINT cp) } else { - WideCharToMultiByte(cp, 0, text.data(), -1, buffer.data(), buffer.size(), nullptr, nullptr); + WideCharToMultiByte(cp, 0, text.data(), text.size(), buffer.data(), buffer.size(), nullptr, nullptr); return buffer.data(); } } diff --git a/cpp/version.cmake b/cpp/version.cmake index 81d8a0fdf03..c94eb2c0193 100644 --- a/cpp/version.cmake +++ b/cpp/version.cmake @@ -1,6 +1,6 @@ set(VERSION_MAJOR 5) set(VERSION_MINOR 56) -set(VERSION_PATCH 5) +set(VERSION_PATCH 6) include(${CMAKE_CURRENT_LIST_DIR}/version/generate_product_version.cmake) \ No newline at end of file diff --git a/py/LunaTranslator/myutils/config.py b/py/LunaTranslator/myutils/config.py index 32ee96c3e56..cd8ca1ac85b 100644 --- a/py/LunaTranslator/myutils/config.py +++ b/py/LunaTranslator/myutils/config.py @@ -378,9 +378,16 @@ def findgameuidofpath(gamepath, findall=False): use = savehook_new_list else: use = sub["games"] + minidx = len(use) + minuid = None for uid in uids: if uid in use: - return uid, use + idx = use.index(uid) + if minidx > idx: + minidx = idx + minuid = uid + if minuid: + return minuid, use if findall: return collect else: