From db6df724cb4435b09b2ecbaec8fd9077ff399037 Mon Sep 17 00:00:00 2001 From: RyuMiya Date: Tue, 15 Oct 2024 11:20:57 +0800 Subject: [PATCH 1/4] Add chs_patch for 3906 --- README.md | 4 ++++ dist/config.toml | 3 +++ src/patches/versions/CHN00.cpp | 2 +- src/patches/versions/JPN39.cpp | 31 +++++++++++++++++++++++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d9c2a81..04fb78d 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ unlock_songs = true # enable ai soshina mode mode_collabo026 = false + [patches.jpn39] + # use cn font and chineseS wordlist value + chs_patch = false + [audio] # wasapi shared mode # allows you to have multiple audio sources at once at a cost of having higher latency diff --git a/dist/config.toml b/dist/config.toml index 8677ce1..ce0da8f 100644 --- a/dist/config.toml +++ b/dist/config.toml @@ -16,6 +16,9 @@ unlock_songs = true mode_collabo025 = false mode_collabo026 = false + [patches.jpn39] + chs_patch = false + [graphics] res = { x = 1920, y = 1080 } windowed = false diff --git a/src/patches/versions/CHN00.cpp b/src/patches/versions/CHN00.cpp index 5479e8a..c16bf6d 100644 --- a/src/patches/versions/CHN00.cpp +++ b/src/patches/versions/CHN00.cpp @@ -130,7 +130,7 @@ Init () { unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs); auto chn00 = openConfigSection (patches, "chn00"); if (chn00) { - fixLanguage = readConfigBool (chn00, "fix_language", fixLanguage); + fixLanguage = readConfigBool (chn00, "fix_language", fixLanguage); demoMovie = readConfigBool (chn00, "demo_movie", demoMovie); modeCollabo025 = readConfigBool (chn00, "mode_collabo025", modeCollabo025); modeCollabo026 = readConfigBool (chn00, "mode_collabo026", modeCollabo026); diff --git a/src/patches/versions/JPN39.cpp b/src/patches/versions/JPN39.cpp index c414f9e..b3ea742 100644 --- a/src/patches/versions/JPN39.cpp +++ b/src/patches/versions/JPN39.cpp @@ -1,6 +1,7 @@ #include "../patches.h" #include "helpers.h" #include +#include namespace patches::JPN39 { @@ -40,17 +41,33 @@ ReplaceLeaBufferAddress (const std::vector &bufferAddresses, void *ne } } +SafetyHookMid changeLanguageTypeHook{}; + +void +ChangeLanguageType(SafetyHookContext& ctx) { + int* pFontType = (int *) ctx.rax; + printf("---- saftyhook 2 fontType = %d\n", *pFontType); + if (*pFontType == 4) *pFontType = 2; +} + void Init () { i32 xRes = 1920; i32 yRes = 1080; bool unlockSongs = true; + bool chsPatch = false; auto configPath = std::filesystem::current_path () / "config.toml"; std::unique_ptr config_ptr (openConfig (configPath), toml_free); if (config_ptr) { auto patches = openConfigSection (config_ptr.get (), "patches"); - if (patches) unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs); + if (patches) { + unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs); + auto jpn39 = openConfigSection (patches, "jpn39"); + if (jpn39) { + chsPatch = readConfigBool (jpn39, "chs_patch", chsPatch); + } + } auto graphics = openConfigSection (config_ptr.get (), "graphics"); if (graphics) { @@ -115,6 +132,16 @@ Init () { ReplaceLeaBufferAddress (datatableBuffer3Addresses, datatableBuffer3.data ()); } + if (chsPatch) { + WRITE_MEMORY (ASLR (0x140CD1AE0), char, "cn_64"); + WRITE_MEMORY (ASLR (0x140CD1AF0), char, "cn_32"); + WRITE_MEMORY (ASLR (0x140CD1AF8), char, "cn_30"); + WRITE_MEMORY (ASLR (0x140C946A0), char, "chineseSText"); + WRITE_MEMORY (ASLR (0x140C946B0), char, "chineseSFontType"); + + changeLanguageTypeHook = safetyhook::create_mid (ASLR (0x1400B2016), ChangeLanguageType); + } + // Disable live check auto amHandle = (u64)GetModuleHandle ("AMFrameWork.dll"); INSTALL_HOOK_DYNAMIC (AMFWTerminate, (void *)(amHandle + 0x42DE0)); @@ -137,4 +164,4 @@ Init () { patches::Qr::Init (); patches::AmAuth::Init (); } -} // namespace patches::JPN39 \ No newline at end of file +} // namespace patches::JPN39 From 036f68b06dea65c546e93e03584e42041bfc17bd Mon Sep 17 00:00:00 2001 From: RyuMiya Date: Thu, 17 Oct 2024 11:58:58 +0800 Subject: [PATCH 2/4] Add FixLanguage --- README.md | 2 ++ dist/config.toml | 1 + src/patches/versions/JPN39.cpp | 51 ++++++++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 04fb78d..129c5d9 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ unlock_songs = true mode_collabo026 = false [patches.jpn39] + # sync test mode language to attract etc + fix_language = false # use cn font and chineseS wordlist value chs_patch = false diff --git a/dist/config.toml b/dist/config.toml index ce0da8f..bea44c7 100644 --- a/dist/config.toml +++ b/dist/config.toml @@ -17,6 +17,7 @@ unlock_songs = true mode_collabo026 = false [patches.jpn39] + fix_language = false chs_patch = false [graphics] diff --git a/src/patches/versions/JPN39.cpp b/src/patches/versions/JPN39.cpp index b3ea742..9735bfa 100644 --- a/src/patches/versions/JPN39.cpp +++ b/src/patches/versions/JPN39.cpp @@ -14,6 +14,17 @@ HOOK_DYNAMIC (i64, __fastcall, curl_easy_setopt, i64 a1, i64 a2, i64 a3, i64 a4, return originalcurl_easy_setopt (a1, a2, a3, a4, a5); } +i64 (__fastcall *lua_settop) (u64, u64) = (i64 (__fastcall *) (u64, u64))PROC_ADDRESS ("lua51.dll", "lua_settop"); +i64 (__fastcall *lua_pushboolean) (u64, u64) = (i64 (__fastcall *) (u64, u64))PROC_ADDRESS ("lua51.dll", "lua_pushboolean"); +i64 (__fastcall *lua_pushstring) (u64, u64) = (i64 (__fastcall *) (u64, u64))PROC_ADDRESS ("lua51.dll", "lua_pushstring"); + +i64 +lua_pushtrue (i64 a1) { + lua_settop (a1, 0); + lua_pushboolean (a1, 1); + return 1; +} + const i32 datatableBufferSize = 1024 * 1024 * 12; safetyhook::Allocation datatableBuffer1; safetyhook::Allocation datatableBuffer2; @@ -46,15 +57,42 @@ SafetyHookMid changeLanguageTypeHook{}; void ChangeLanguageType(SafetyHookContext& ctx) { int* pFontType = (int *) ctx.rax; - printf("---- saftyhook 2 fontType = %d\n", *pFontType); if (*pFontType == 4) *pFontType = 2; } +int language = 0; +const char * +languageStr () { + switch (language) { + case 1: return "en_us"; + case 2: return "cn_tw"; + case 3: return "kor"; + case 4: return "cn_cn"; + default: return "jpn"; + } +} +HOOK (i64, GetLanguage, ASLR (0x140024AC0), i64 a1) { + auto result = originalGetLanguage (a1); + language = *((u32 *)result); + return result; +} +HOOK (i64, GetRegionLanguage, ASLR (0x1401CE9B0), i64 a1) { + lua_settop (a1, 0); + lua_pushstring (a1, (u64)languageStr ()); + return 1; +} +HOOK (i64, GetCabinetLanguage, ASLR (0x1401D1A60), i64, i64 a2) { + lua_settop (a2, 0); + lua_pushstring (a2, (u64)languageStr ()); + return 1; +} + void Init () { i32 xRes = 1920; i32 yRes = 1080; bool unlockSongs = true; + bool fixLanguage = false; bool chsPatch = false; auto configPath = std::filesystem::current_path () / "config.toml"; @@ -65,7 +103,8 @@ Init () { unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs); auto jpn39 = openConfigSection (patches, "jpn39"); if (jpn39) { - chsPatch = readConfigBool (jpn39, "chs_patch", chsPatch); + fixLanguage = readConfigBool (jpn39, "fix_language", fixLanguage); + chsPatch = readConfigBool (jpn39, "chs_patch", chsPatch); } } @@ -132,6 +171,7 @@ Init () { ReplaceLeaBufferAddress (datatableBuffer3Addresses, datatableBuffer3.data ()); } + // patch to use chs font/wordlist instead of cht if (chsPatch) { WRITE_MEMORY (ASLR (0x140CD1AE0), char, "cn_64"); WRITE_MEMORY (ASLR (0x140CD1AF0), char, "cn_32"); @@ -142,6 +182,13 @@ Init () { changeLanguageTypeHook = safetyhook::create_mid (ASLR (0x1400B2016), ChangeLanguageType); } + // Fix language + if (fixLanguage) { + INSTALL_HOOK (GetLanguage); + INSTALL_HOOK (GetRegionLanguage); + INSTALL_HOOK (GetCabinetLanguage); + } + // Disable live check auto amHandle = (u64)GetModuleHandle ("AMFrameWork.dll"); INSTALL_HOOK_DYNAMIC (AMFWTerminate, (void *)(amHandle + 0x42DE0)); From e2f2bda0146b834333829f3c442724379095b34d Mon Sep 17 00:00:00 2001 From: RyuMiya Date: Thu, 17 Oct 2024 14:33:30 +0800 Subject: [PATCH 3/4] Add Mode Unlock --- README.md | 6 ++++++ dist/config.toml | 3 +++ src/patches/versions/CHN00.cpp | 2 +- src/patches/versions/JPN39.cpp | 29 ++++++++++++++++++++++------- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 129c5d9..ef42082 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,12 @@ unlock_songs = true fix_language = false # use cn font and chineseS wordlist value chs_patch = false + # enable one piece collab mode + mode_collabo025 = false + # enable ai soshina mode + mode_collabo026 = false + # enable aoharu no tatsujinn mode + mode_aprilfool001 = false [audio] # wasapi shared mode diff --git a/dist/config.toml b/dist/config.toml index bea44c7..195d9c6 100644 --- a/dist/config.toml +++ b/dist/config.toml @@ -19,6 +19,9 @@ unlock_songs = true [patches.jpn39] fix_language = false chs_patch = false + mode_collabo025 = false + mode_collabo026 = false + mode_aprilfool001 = false [graphics] res = { x = 1920, y = 1080 } diff --git a/src/patches/versions/CHN00.cpp b/src/patches/versions/CHN00.cpp index c16bf6d..46fa093 100644 --- a/src/patches/versions/CHN00.cpp +++ b/src/patches/versions/CHN00.cpp @@ -100,7 +100,7 @@ Init () { i32 xRes = 1920; i32 yRes = 1080; bool unlockSongs = true; - bool fixLanguage = false; + bool fixLanguage = false; bool demoMovie = true; bool modeCollabo025 = false; bool modeCollabo026 = false; diff --git a/src/patches/versions/JPN39.cpp b/src/patches/versions/JPN39.cpp index 9735bfa..0c64344 100644 --- a/src/patches/versions/JPN39.cpp +++ b/src/patches/versions/JPN39.cpp @@ -25,6 +25,11 @@ lua_pushtrue (i64 a1) { return 1; } +HOOK (i64, AvailableMode_Collabo024, ASLR (0x1402DE710), i64 a1) { return lua_pushtrue (a1); } +HOOK (i64, AvailableMode_Collabo025, ASLR (0x1402DE6B0), i64 a1) { return lua_pushtrue (a1); } +HOOK (i64, AvailableMode_Collabo026, ASLR (0x1402DE670), i64 a1) { return lua_pushtrue (a1); } +HOOK (i64, AvailableMode_AprilFool001, ASLR (0x1402DE5B0), i64 a1) { return lua_pushtrue (a1); } + const i32 datatableBufferSize = 1024 * 1024 * 12; safetyhook::Allocation datatableBuffer1; safetyhook::Allocation datatableBuffer2; @@ -89,11 +94,14 @@ HOOK (i64, GetCabinetLanguage, ASLR (0x1401D1A60), i64, i64 a2) { void Init () { - i32 xRes = 1920; - i32 yRes = 1080; - bool unlockSongs = true; - bool fixLanguage = false; - bool chsPatch = false; + i32 xRes = 1920; + i32 yRes = 1080; + bool unlockSongs = true; + bool fixLanguage = false; + bool chsPatch = false; + bool modeCollabo025 = false; + bool modeCollabo026 = false; + bool modeAprilFool001 = false; auto configPath = std::filesystem::current_path () / "config.toml"; std::unique_ptr config_ptr (openConfig (configPath), toml_free); @@ -103,8 +111,11 @@ Init () { unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs); auto jpn39 = openConfigSection (patches, "jpn39"); if (jpn39) { - fixLanguage = readConfigBool (jpn39, "fix_language", fixLanguage); - chsPatch = readConfigBool (jpn39, "chs_patch", chsPatch); + fixLanguage = readConfigBool (jpn39, "fix_language", fixLanguage); + chsPatch = readConfigBool (jpn39, "chs_patch", chsPatch); + modeCollabo025 = readConfigBool (jpn39, "mode_collabo025", modeCollabo025); + modeCollabo026 = readConfigBool (jpn39, "mode_collabo026", modeCollabo026); + modeAprilFool001 = readConfigBool (jpn39, "mode_aprilfool001", modeAprilFool001); } } @@ -189,6 +200,10 @@ Init () { INSTALL_HOOK (GetCabinetLanguage); } + if (modeCollabo025) INSTALL_HOOK (AvailableMode_Collabo025); + if (modeCollabo026) INSTALL_HOOK (AvailableMode_Collabo026); + if (modeAprilFool001) INSTALL_HOOK (AvailableMode_AprilFool001); + // Disable live check auto amHandle = (u64)GetModuleHandle ("AMFrameWork.dll"); INSTALL_HOOK_DYNAMIC (AMFWTerminate, (void *)(amHandle + 0x42DE0)); From db0fe9acce41006cd7bed91965f8e4e06a1ad3f7 Mon Sep 17 00:00:00 2001 From: esuo1198 <54134.es@gmail.com> Date: Thu, 17 Oct 2024 19:07:21 +0900 Subject: [PATCH 4/4] Clean up code --- src/patches/versions/CHN00.cpp | 10 +++++----- src/patches/versions/JPN39.cpp | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/patches/versions/CHN00.cpp b/src/patches/versions/CHN00.cpp index 680723a..7f99fe7 100644 --- a/src/patches/versions/CHN00.cpp +++ b/src/patches/versions/CHN00.cpp @@ -24,9 +24,9 @@ HOOK (i32, HaspRead, PROC_ADDRESS ("hasp_windows_x64.dll", "hasp_read"), i32, i3 return 0; } -i64 (__fastcall *lua_settop) (u64, u64) = (i64 (__fastcall *) (u64, u64))PROC_ADDRESS ("lua51.dll", "lua_settop"); -i64 (__fastcall *lua_pushboolean) (u64, u64) = (i64 (__fastcall *) (u64, u64))PROC_ADDRESS ("lua51.dll", "lua_pushboolean"); -i64 (__fastcall *lua_pushstring) (u64, u64) = (i64 (__fastcall *) (u64, u64))PROC_ADDRESS ("lua51.dll", "lua_pushstring"); +FUNCTION_PTR (i64, lua_settop, PROC_ADDRESS ("lua51.dll", "lua_settop"), u64, u64); +FUNCTION_PTR (i64, lua_pushboolean, PROC_ADDRESS ("lua51.dll", "lua_pushboolean"), u64, u64); +FUNCTION_PTR (i64, lua_pushstring, PROC_ADDRESS ("lua51.dll", "lua_pushstring"), u64, u64); i64 lua_pushtrue (i64 a1) { @@ -100,7 +100,7 @@ Init () { i32 xRes = 1920; i32 yRes = 1080; bool unlockSongs = true; - bool fixLanguage = false; + bool fixLanguage = false; bool demoMovie = true; bool modeCollabo025 = false; bool modeCollabo026 = false; @@ -130,7 +130,7 @@ Init () { unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs); auto chn00 = openConfigSection (patches, "chn00"); if (chn00) { - fixLanguage = readConfigBool (chn00, "fix_language", fixLanguage); + fixLanguage = readConfigBool (chn00, "fix_language", fixLanguage); demoMovie = readConfigBool (chn00, "demo_movie", demoMovie); modeCollabo025 = readConfigBool (chn00, "mode_collabo025", modeCollabo025); modeCollabo026 = readConfigBool (chn00, "mode_collabo026", modeCollabo026); diff --git a/src/patches/versions/JPN39.cpp b/src/patches/versions/JPN39.cpp index dbcecd2..39f3d7b 100644 --- a/src/patches/versions/JPN39.cpp +++ b/src/patches/versions/JPN39.cpp @@ -14,9 +14,9 @@ HOOK_DYNAMIC (i64, __fastcall, curl_easy_setopt, i64 a1, i64 a2, i64 a3, i64 a4, return originalcurl_easy_setopt (a1, a2, a3, a4, a5); } -i64 (__fastcall *lua_settop) (u64, u64) = (i64 (__fastcall *) (u64, u64))PROC_ADDRESS ("lua51.dll", "lua_settop"); -i64 (__fastcall *lua_pushboolean) (u64, u64) = (i64 (__fastcall *) (u64, u64))PROC_ADDRESS ("lua51.dll", "lua_pushboolean"); -i64 (__fastcall *lua_pushstring) (u64, u64) = (i64 (__fastcall *) (u64, u64))PROC_ADDRESS ("lua51.dll", "lua_pushstring"); +FUNCTION_PTR (i64, lua_settop, PROC_ADDRESS ("lua51.dll", "lua_settop"), u64, u64); +FUNCTION_PTR (i64, lua_pushboolean, PROC_ADDRESS ("lua51.dll", "lua_pushboolean"), u64, u64); +FUNCTION_PTR (i64, lua_pushstring, PROC_ADDRESS ("lua51.dll", "lua_pushstring"), u64, u64); i64 lua_pushtrue (i64 a1) { @@ -25,9 +25,9 @@ lua_pushtrue (i64 a1) { return 1; } -HOOK (i64, AvailableMode_Collabo024, ASLR (0x1402DE710), i64 a1) { return lua_pushtrue (a1); } -HOOK (i64, AvailableMode_Collabo025, ASLR (0x1402DE6B0), i64 a1) { return lua_pushtrue (a1); } -HOOK (i64, AvailableMode_Collabo026, ASLR (0x1402DE670), i64 a1) { return lua_pushtrue (a1); } +HOOK (i64, AvailableMode_Collabo024, ASLR (0x1402DE710), i64 a1) { return lua_pushtrue (a1); } +HOOK (i64, AvailableMode_Collabo025, ASLR (0x1402DE6B0), i64 a1) { return lua_pushtrue (a1); } +HOOK (i64, AvailableMode_Collabo026, ASLR (0x1402DE670), i64 a1) { return lua_pushtrue (a1); } HOOK (i64, AvailableMode_AprilFool001, ASLR (0x1402DE5B0), i64 a1) { return lua_pushtrue (a1); } const i32 datatableBufferSize = 1024 * 1024 * 12; @@ -60,8 +60,8 @@ ReplaceLeaBufferAddress (const std::vector &bufferAddresses, void *ne SafetyHookMid changeLanguageTypeHook{}; void -ChangeLanguageType(SafetyHookContext& ctx) { - int* pFontType = (int *) ctx.rax; +ChangeLanguageType (SafetyHookContext &ctx) { + int *pFontType = (int *)ctx.rax; if (*pFontType == 4) *pFontType = 2; } @@ -97,7 +97,7 @@ Init () { i32 xRes = 1920; i32 yRes = 1080; bool unlockSongs = true; - bool fixLanguage = false; + bool fixLanguage = false; bool chsPatch = false; bool modeCollabo025 = false; bool modeCollabo026 = false; @@ -111,7 +111,7 @@ Init () { unlockSongs = readConfigBool (patches, "unlock_songs", unlockSongs); auto jpn39 = openConfigSection (patches, "jpn39"); if (jpn39) { - fixLanguage = readConfigBool (jpn39, "fix_language", fixLanguage); + fixLanguage = readConfigBool (jpn39, "fix_language", fixLanguage); chsPatch = readConfigBool (jpn39, "chs_patch", chsPatch); modeCollabo025 = readConfigBool (jpn39, "mode_collabo025", modeCollabo025); modeCollabo026 = readConfigBool (jpn39, "mode_collabo026", modeCollabo026); @@ -200,8 +200,8 @@ Init () { INSTALL_HOOK (GetCabinetLanguage); } - if (modeCollabo025) INSTALL_HOOK (AvailableMode_Collabo025); - if (modeCollabo026) INSTALL_HOOK (AvailableMode_Collabo026); + if (modeCollabo025) INSTALL_HOOK (AvailableMode_Collabo025); + if (modeCollabo026) INSTALL_HOOK (AvailableMode_Collabo026); if (modeAprilFool001) INSTALL_HOOK (AvailableMode_AprilFool001); // Disable live check