1
0
mirror of synced 2024-12-22 00:35:53 +01:00
bananatools/platform/locale.c
2023-01-02 23:39:03 -05:00

71 lines
1.8 KiB
C

#include <windows.h>
#include "hook/table.h"
#include "platform/locale.h"
#include "util/dprintf.h"
static GEOID WINAPI my_GetUserGeoID(GEOCLASS GeoClass);
static LCID WINAPI my_GetUserDefaultLCID();
static LANGID WINAPI my_GetSystemDefaultUILanguage();
static GEOID (WINAPI *next_GetUserGeoID)(GEOCLASS GeoClass);
static LCID (WINAPI *next_GetUserDefaultLCID)();
static LANGID (WINAPI *next_GetSystemDefaultUILanguage)();
static const struct hook_symbol bnusio_hooks[] = {
{
.name = "GetUserGeoID",
.patch = my_GetUserGeoID,
.link = (void **) &next_GetUserGeoID
},{
.name = "GetUserDefaultLCID",
.patch = my_GetUserDefaultLCID,
.link = (void **) &next_GetUserDefaultLCID
},{
.name = "GetSystemDefaultUILanguage",
.patch = my_GetSystemDefaultUILanguage,
.link = (void **) &next_GetSystemDefaultUILanguage
},
};
static void locale_hook_insert_hooks(HMODULE target)
{
hook_table_apply(
target,
"kernel32.dll",
bnusio_hooks,
_countof(bnusio_hooks));
}
HRESULT locale_hook_init(const struct locale_config *cfg)
{
locale_hook_insert_hooks(NULL);
dprintf("Locale: Init\n");
return S_OK;
}
GEOID WINAPI my_GetUserGeoID(GEOCLASS GeoClass)
{
dprintf("Locale: returning Japan GeoID\n");
return 0x7a;
}
LCID WINAPI my_GetUserDefaultLCID()
{
// This function seems to get spammed quite a bit, so commenting
// this out to quiet down the logs. Change to 1 to log this again
#if 0
dprintf("Locale: %s returning Japanese LCID\n", __func__);
#endif
return MAKELCID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN);
}
LANGID WINAPI my_GetSystemDefaultUILanguage()
{
dprintf("Locale: returning Japanese LANGID\n");
return LANGIDFROMLCID(MAKELCID(LANG_JAPANESE, SUBLANG_JAPANESE_JAPAN));
}