try use _china.xml and cn_font from testmode

This commit is contained in:
ptmaster
2024-12-22 23:23:37 +08:00
parent 2267d82790
commit 7769800b11
4 changed files with 28 additions and 48 deletions
+7
View File
@@ -8,6 +8,7 @@ extern GameVersion gameVersion;
namespace patches::Language {
const std::vector<std::string> languages = { "jpn", "en_us", "cn_tw", "kor", "cn_cn" };
std::vector<SafetyHookMid> language_patch = { };
boolean cnFontPatches = false;
int language = 0;
FUNCTION_PTR (void, lua_settop, PROC_ADDRESS ("lua51.dll", "lua_settop"), i64, i32);
@@ -159,6 +160,7 @@ Init () {
// user_name_soshina
language_patch.push_back (safetyhook::create_mid (ASLR (0x14016164D), [](SafetyHookContext &ctx)
{ *(int *)(ctx.rsp + 0xD0) = (int)(ctx.rcx % languages.size ()); ctx.rip = ASLR (0x140161687); }));
cnFontPatches = true;
}
);
} break;
@@ -629,6 +631,11 @@ Init () {
}
}
boolean
CnFontPatches () {
return cnFontPatches;
}
void
Init () {
switch (gameVersion) {
+1
View File
@@ -120,6 +120,7 @@ namespace Timer {
void Init ();
} // namespace timer
namespace Language {
boolean CnFontPatches ();
void Init ();
}
} // namespace patches
+20 -5
View File
@@ -16,6 +16,7 @@ std::vector<std::function<void ()>> hooks = {};
std::thread *hookInstall;
std::mutex hooksMutex;
std::condition_variable hooksCV;
std::vector<SafetyHookMid> patches = {};
std::wstring
mergeCondition (std::wstring original, std::wstring addition, std::wstring value) {
@@ -435,6 +436,9 @@ Init () {
const u64 testModeLibrary = (u64)GetModuleHandle ("TestModeLibrary.dll");
const u64 testModeSetMenu = testModeLibrary + 0x99D0;
CommonModify ();
for (auto method : hooks) method ();
switch (gameVersion) {
case GameVersion::UNKNOWN: break;
case GameVersion::JPN00: break;
@@ -443,7 +447,15 @@ Init () {
INSTALL_FAST_HOOK_DYNAMIC (SceneTestModeLoading, ASLR (0x1404793D0));
INSTALL_FAST_HOOK_DYNAMIC (SceneTestModeFinalize, ASLR (0x140479600));
originalDeviceInitialize = L"DeviceInitialize.xml";
if (std::filesystem::exists ("..\\..\\Data\\x64\\testmode\\DeviceInitialize_chspatch.xml")) {
if (Language::CnFontPatches () && std::filesystem::exists ("..\\..\\Data\\x64\\testmode\\DeviceInitialize_china.xml")) {
usingDeviceInitialize = L"DeviceInitialize_china.xml";
patches.push_back (safetyhook::create_mid (ASLR (0x140465549), [](SafetyHookContext &ctx)
{ ctx.r8 = 2; ctx.rdx = (uintptr_t)"cn"; ctx.rip = ASLR (0x140465556); }));
WRITE_MEMORY (ASLR (0x140CD1E40), wchar_t, L"加载中\0");
WRITE_MEMORY (ASLR (0x140CD1E28), wchar_t, L"加载中.\0");
WRITE_MEMORY (ASLR (0x140CD1E68), wchar_t, L"加载中..\0");
WRITE_MEMORY (ASLR (0x140CD1E50), wchar_t, L"加载中...\0");
} else if (std::filesystem::exists ("..\\..\\Data\\x64\\testmode\\DeviceInitialize_chspatch.xml")) {
usingDeviceInitialize = L"DeviceInitialize_chspatch.xml";
WRITE_MEMORY (ASLR (0x140CD1E40), wchar_t, L"加載中\0");
WRITE_MEMORY (ASLR (0x140CD1E28), wchar_t, L"加載中.\0");
@@ -451,7 +463,13 @@ Init () {
WRITE_MEMORY (ASLR (0x140CD1E50), wchar_t, L"加載中...\0");
} else usingDeviceInitialize = originalDeviceInitialize;
originalTestMode = L"TestMode.xml";
if (std::filesystem::exists ("..\\..\\Data\\x64\\testmode\\TestMode_chspatch.xml")) {
if (Language::CnFontPatches () && std::filesystem::exists ("..\\..\\Data\\x64\\testmode\\TestMode_china.xml")) {
usingTestMode = L"TestMode_china.xml";
patches.push_back (safetyhook::create_mid (ASLR (0x14047C603), [](SafetyHookContext &ctx)
{ ctx.r8 = 2; ctx.rdx = (uintptr_t)"cn"; ctx.rip = ASLR (0x14047C610); }));
patches.push_back (safetyhook::create_mid (ASLR (0x1404676E7), [](SafetyHookContext &ctx)
{ ctx.r8 = 2; ctx.rdx = (uintptr_t)"cn"; ctx.rip = ASLR (0x1404676F4); }));
} else if (std::filesystem::exists ("..\\..\\Data\\x64\\testmode\\TestMode_chspatch.xml")) {
usingTestMode = L"TestMode_chspatch.xml";
} else usingTestMode = originalTestMode;
@@ -459,10 +477,7 @@ Init () {
case GameVersion::CHN00: break;
}
CommonModify ();
INSTALL_FAST_HOOK_DYNAMIC (TestModeSetMenuHook, testModeSetMenu);
for (auto method : hooks) method ();
}
void
-43
View File
@@ -225,49 +225,6 @@ MID_HOOK (AttractDemo, ASLR (0x14045A720), SafetyHookContext &ctx) {
if (TestMode::ReadTestModeValue (L"AttractDemoItem") == 1) ctx.r14 = 0;
}
// FAST_HOOK (u64, EnsoGameManagerInitialize, ASLR (0x1400E2520), u64 a1, u64 a2, u64 a3) {
// LogMessage (LogLevel::DEBUG, "Begin EnsoGameManagerInitialize");
// u64 result = originalEnsoGameManagerInitialize.fastcall<u64> (a1, a2, a3);
// LogMessage (LogLevel::DEBUG, "End EnsoGameManagerInitialize result={}", result);
// return result;
// }
// FAST_HOOK (u64, EnsoGameManagerLoading, ASLR (0x1400E2750), u64 a1, u64 a2, u64 a3) {
// LogMessage (LogLevel::DEBUG, "Begin EnsoGameManagerLoading");
// u64 result = originalEnsoGameManagerLoading.fastcall<u64> (a1, a2, a3);
// LogMessage (LogLevel::DEBUG, "End EnsoGameManagerLoading result={}", result);
// return result;
// }
// FAST_HOOK (bool, EnsoGameManagerPreparing, ASLR (0x1400E2990), u64 a1, u64 a2, u64 a3) {
// LogMessage (LogLevel::DEBUG, "Begin EnsoGameManagerPreparing");
// bool result = originalEnsoGameManagerPreparing.fastcall<u64> (a1, a2, a3); // crashes here
// LogMessage (LogLevel::DEBUG, "End EnsoGameManagerPreparing result={}", result);
// return result;
// }
// FAST_HOOK (u64, EnsoGraphicManagerPreparing, ASLR (0x1400F0AB0), u64 a1, u64 a2, u64 a3) {
// LogMessage (LogLevel::DEBUG, "Begin EnsoGraphicManagerPreparing");
// u64 result = originalEnsoGraphicManagerPreparing.fastcall<u64> (a1, a2, a3);
// LogMessage (LogLevel::DEBUG, "End EnsoGraphicManagerPreparing result={}", result);
// return result;
// }
// FAST_HOOK (u64, EnsoGameManagerStart, ASLR (0x1400E2A10), u64 a1, u64 a2, u64 a3) {
// LogMessage (LogLevel::DEBUG, "Begin EnsoGameManagerStart");
// u64 result = originalEnsoGameManagerStart.fastcall<u64> (a1, a2, a3);
// LogMessage (LogLevel::DEBUG, "End EnsoGameManagerStart result={}", result);
// return result;
// }
// FAST_HOOK (u64, EnsoGameManagerChechEnsoEnd, ASLR (0x1400E2A10), u64 a1, u64 a2, u64 a3) {
// LogMessage (LogLevel::DEBUG, "Begin EnsoGameManagerChechEnsoEnd");
// u64 result = originalEnsoGameManagerChechEnsoEnd.fastcall<u64> (a1, a2, a3);
// LogMessage (LogLevel::DEBUG, "End EnsoGameManagerChechEnsoEnd result={}", result);
// return result;
// }
// HOOK (DWORD*, AcquireMostCompatibleDisplayMode, ASLR (0x14064C870), i64 a1, DWORD *a2, DWORD *a3) {
// LogMessage (LogLevel::DEBUG, "AcquireMostCompatibleDisplayMode {:d} {:d} {:f} {:f}", a3[0], a3[1], (float)(int)a3[2], (float)(int)a3[3]);
// a3[2] = (DWORD)(int)120.0f;