[*] Prevent SysPanic/SysAsserts under Windows Vista and beta builds of Windows 7 during locale lookup. This shouldn't impact Windows XP. Perhaps Winserver 2003, beta 7, and other releases of older Windows could crash on start up.

Unrelated note, Windows XP does in fact have NLS support with these APIs; we just need to use "nlsdl.dll". Fortunately, we already have Windows XP paths, and that DLL is nothing more than a 24kb stub that calls GetLocaleInfoW. Something we already do ourselves.
This commit is contained in:
Reece Wilson 2024-05-13 21:27:07 +01:00
parent e86a414837
commit 26209ea066

View File

@ -91,20 +91,40 @@ namespace Aurora::Locale
static void SetLanguageWin32()
{
int ret;
int ret { ERROR_NOT_SUPPORTED };
wchar_t name[LOCALE_NAME_MAX_LENGTH] = { 0 };
wchar_t *pName { nullptr };
if (pLCIDToLocaleName)
{
ret = pLCIDToLocaleName(LOCALE_USER_DEFAULT, name, LOCALE_NAME_MAX_LENGTH, LOCALE_ALLOW_NEUTRAL_NAMES);
if (AuSWInfo::IsWindows7OrGreater())
{
ret = pLCIDToLocaleName(LOCALE_USER_DEFAULT, name, LOCALE_NAME_MAX_LENGTH, LOCALE_ALLOW_NEUTRAL_NAMES);
}
else
{
ret = pLCIDToLocaleName(LOCALE_USER_DEFAULT, name, LOCALE_NAME_MAX_LENGTH, 0);
}
if (ret)
{
pName = name;
}
else
{
pName = nullptr; /* LOCALE_NAME_USER_DEFAULT. Windows XP < x <= Windows Vista/Beta 7 - detection failure? Windows server? */
}
#if 0
SysAssert(ret, "Couldn't acquire win32 locale information");
#endif
}
{
wchar_t language[LOCALE_NAME_MAX_LENGTH] = { 0 };
if (pGetLocaleInfoEx)
{
ret = pGetLocaleInfoEx(name, LOCALE_SISO639LANGNAME, language, LOCALE_NAME_MAX_LENGTH);
ret = pGetLocaleInfoEx(pName, LOCALE_SISO639LANGNAME, language, LOCALE_NAME_MAX_LENGTH);
SysAssert(ret, "Couldn't acquire win32 provided ISO 639 map of {}", ConvertFromWChar(name));
}
else if (pGetLocaleInfoW)
@ -120,7 +140,7 @@ namespace Aurora::Locale
wchar_t country[LOCALE_NAME_MAX_LENGTH] = { 0 };
if (pGetLocaleInfoEx)
{
ret = pGetLocaleInfoEx(name, LOCALE_SISO3166CTRYNAME, country, LOCALE_NAME_MAX_LENGTH);
ret = pGetLocaleInfoEx(pName, LOCALE_SISO3166CTRYNAME, country, LOCALE_NAME_MAX_LENGTH);
SysAssert(ret, "Couldn't acquire win32 provided ISO 3166 map of {}", ConvertFromWChar(name));
}
else if (pGetLocaleInfoW)