mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-01 22:30:42 -07:00
gitadora: (arena model) text encoding hook (#482)
## Link to GitHub Issue, if one exists #477 ## Description of change Fix Japanese text broken in the game UI when system ACP is not SHIFT-JIS. ## Testing Checked song select and in-game title display.
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "avs/game.h"
|
#include "avs/game.h"
|
||||||
#include "games/iidx/iidx.h"
|
#include "games/iidx/iidx.h"
|
||||||
|
#include "games/gitadora/gitadora.h"
|
||||||
#include "util/detour.h"
|
#include "util/detour.h"
|
||||||
#include "util/logging.h"
|
#include "util/logging.h"
|
||||||
#include "util/utils.h"
|
#include "util/utils.h"
|
||||||
@@ -24,6 +25,7 @@ static decltype(GetLocaleInfoEx) *GetLocaleInfoEx_orig = nullptr;
|
|||||||
#ifdef SPICE64
|
#ifdef SPICE64
|
||||||
static decltype(GetSystemDefaultLCID) *GetSystemDefaultLCID_orig = nullptr;
|
static decltype(GetSystemDefaultLCID) *GetSystemDefaultLCID_orig = nullptr;
|
||||||
static decltype(IsDBCSLeadByte) *IsDBCSLeadByte_orig = nullptr;
|
static decltype(IsDBCSLeadByte) *IsDBCSLeadByte_orig = nullptr;
|
||||||
|
static decltype(WideCharToMultiByte) *WideCharToMultiByte_orig = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static NTSTATUS NTAPI RtlMultiByteToUnicodeN_hook(
|
static NTSTATUS NTAPI RtlMultiByteToUnicodeN_hook(
|
||||||
@@ -173,6 +175,41 @@ static BOOL WINAPI IsDBCSLeadByte_hook (
|
|||||||
return IsDBCSLeadByteEx(CODEPAGE_SHIFT_JIS, TestChar);
|
return IsDBCSLeadByteEx(CODEPAGE_SHIFT_JIS, TestChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
int
|
||||||
|
WINAPI
|
||||||
|
WideCharToMultiByte_hook(
|
||||||
|
UINT CodePage,
|
||||||
|
DWORD dwFlags,
|
||||||
|
LPCWCH lpWideCharStr,
|
||||||
|
int cchWideChar,
|
||||||
|
LPSTR lpMultiByteStr,
|
||||||
|
int cbMultiByte,
|
||||||
|
LPCCH lpDefaultChar,
|
||||||
|
LPBOOL lpUsedDefaultChar
|
||||||
|
)
|
||||||
|
{
|
||||||
|
switch (CodePage) {
|
||||||
|
case CP_ACP:
|
||||||
|
case CP_THREAD_ACP:
|
||||||
|
SetThreadLocale(MAKELANGID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN));
|
||||||
|
CodePage = CODEPAGE_SHIFT_JIS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return WideCharToMultiByte_orig(
|
||||||
|
CodePage,
|
||||||
|
dwFlags,
|
||||||
|
lpWideCharStr,
|
||||||
|
cchWideChar,
|
||||||
|
lpMultiByteStr,
|
||||||
|
cbMultiByte,
|
||||||
|
lpDefaultChar,
|
||||||
|
lpUsedDefaultChar);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void hooks::lang::early_init() {
|
void hooks::lang::early_init() {
|
||||||
@@ -213,6 +250,15 @@ void hooks::lang::early_init() {
|
|||||||
IsDBCSLeadByte_hook,
|
IsDBCSLeadByte_hook,
|
||||||
&IsDBCSLeadByte_orig);
|
&IsDBCSLeadByte_orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (games::gitadora::is_arena_model()) {
|
||||||
|
log_info("hooks::lang", "hooking WideCharToMultiByte");
|
||||||
|
detour::trampoline_try(
|
||||||
|
"kernel32.dll",
|
||||||
|
"WideCharToMultiByte",
|
||||||
|
WideCharToMultiByte_hook,
|
||||||
|
&WideCharToMultiByte_orig);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user