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));