mirror of
https://github.com/reactos/reactos.git
synced 2024-10-14 21:25:14 +00:00
[kernel32]
Viliam Lejcik (lejcik AT gmail DOT com>: Various locale fixes (missing checks, wrong or no errors set etc.) See issue #4898 for more details. svn path=/trunk/; revision=44650
This commit is contained in:
parent
98423a8531
commit
6ceb354c5c
|
@ -219,8 +219,7 @@ EnumDateFormatsExA(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// FIXME: Unknown date format
|
SetLastError(ERROR_INVALID_FLAGS);
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -288,8 +287,7 @@ EnumDateFormatsExW(
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// FIXME: Unknown date format
|
SetLastError(ERROR_INVALID_FLAGS);
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -334,7 +332,10 @@ static HANDLE NLS_RegOpenKey(HANDLE hRootKey, LPCWSTR szKeyName)
|
||||||
InitializeObjectAttributes(&attr, &keyName, OBJ_CASE_INSENSITIVE, hRootKey, NULL);
|
InitializeObjectAttributes(&attr, &keyName, OBJ_CASE_INSENSITIVE, hRootKey, NULL);
|
||||||
|
|
||||||
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS)
|
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
SetLastError( ERROR_BADDB );
|
||||||
hkey = 0;
|
hkey = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return hkey;
|
return hkey;
|
||||||
}
|
}
|
||||||
|
@ -2397,6 +2398,8 @@ IsValidLanguageGroup(
|
||||||
case LGRPID_SUPPORTED:
|
case LGRPID_SUPPORTED:
|
||||||
|
|
||||||
hKey = NLS_RegOpenKey( 0, szLangGroupsKeyName );
|
hKey = NLS_RegOpenKey( 0, szLangGroupsKeyName );
|
||||||
|
if (!hKey)
|
||||||
|
break;
|
||||||
|
|
||||||
swprintf( szValueName, szFormat, LanguageGroup );
|
swprintf( szValueName, szFormat, LanguageGroup );
|
||||||
|
|
||||||
|
@ -2408,10 +2411,13 @@ IsValidLanguageGroup(
|
||||||
bInstalled = TRUE;
|
bInstalled = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hKey)
|
|
||||||
NtClose( hKey );
|
NtClose( hKey );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINT("Invalid flags: %lx\n", dwFlags);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((dwFlags == LGRPID_SUPPORTED && bSupported) ||
|
if ((dwFlags == LGRPID_SUPPORTED && bSupported) ||
|
||||||
|
@ -2452,6 +2458,7 @@ IsValidLocale(LCID Locale,
|
||||||
HANDLE KeyHandle;
|
HANDLE KeyHandle;
|
||||||
PWSTR ValueData;
|
PWSTR ValueData;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
BOOL Installed = FALSE;
|
||||||
|
|
||||||
DPRINT("IsValidLocale() called\n");
|
DPRINT("IsValidLocale() called\n");
|
||||||
|
|
||||||
|
@ -2485,6 +2492,7 @@ IsValidLocale(LCID Locale,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("NtOpenKey() failed (Status %lx)\n", Status);
|
DPRINT("NtOpenKey() failed (Status %lx)\n", Status);
|
||||||
|
SetLastError(ERROR_BADDB);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2526,19 +2534,30 @@ IsValidLocale(LCID Locale,
|
||||||
|
|
||||||
ValueData = (PWSTR)&KeyInfo->Data[0];
|
ValueData = (PWSTR)&KeyInfo->Data[0];
|
||||||
if ((KeyInfo->Type == REG_SZ) &&
|
if ((KeyInfo->Type == REG_SZ) &&
|
||||||
(KeyInfo->DataLength == 2 * sizeof(WCHAR)) &&
|
(KeyInfo->DataLength == 2 * sizeof(WCHAR)))
|
||||||
(ValueData[0] == L'1'))
|
|
||||||
{
|
{
|
||||||
|
/* Find out if there is support for the language group
|
||||||
|
* installed, to which this language belongs */
|
||||||
|
KeyHandle = NLS_RegOpenKey(0, szLangGroupsKeyName);
|
||||||
|
if (KeyHandle)
|
||||||
|
{
|
||||||
|
WCHAR Value[2];
|
||||||
|
if (NLS_RegGetDword(KeyHandle, ValueData, (LPDWORD) Value) &&
|
||||||
|
Value[0] == L'1')
|
||||||
|
{
|
||||||
|
Installed = TRUE;
|
||||||
DPRINT("Locale is supported and installed\n");
|
DPRINT("Locale is supported and installed\n");
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
|
}
|
||||||
return TRUE;
|
|
||||||
|
NtClose(KeyHandle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
|
||||||
|
|
||||||
DPRINT("IsValidLocale() called\n");
|
DPRINT("IsValidLocale() called\n");
|
||||||
|
|
||||||
return FALSE;
|
return Installed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -109,7 +109,7 @@ BOOL NLS_isSystemLocale(LCID lcid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* NLS_isSystemLocale <internal>
|
* NLS_getDefaultLocale <internal>
|
||||||
*
|
*
|
||||||
* Return default system or user locale
|
* Return default system or user locale
|
||||||
*/
|
*/
|
||||||
|
@ -1023,7 +1023,7 @@ INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags,
|
||||||
{
|
{
|
||||||
lcid = NLS_getDefaultLocale(lcid);
|
lcid = NLS_getDefaultLocale(lcid);
|
||||||
}
|
}
|
||||||
else if(!IsValidLocale(lcid, 0))
|
else if(!IsValidLocale(lcid, LCID_INSTALLED))
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_PARAMETER);
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1403,8 +1403,17 @@ INT WINAPI GetCurrencyFormatW(LCID lcid, DWORD dwFlags,
|
||||||
lpCurrencyStr,
|
lpCurrencyStr,
|
||||||
cchOut);
|
cchOut);
|
||||||
|
|
||||||
|
if(NLS_isSystemLocale(lcid))
|
||||||
|
{
|
||||||
|
lcid = NLS_getDefaultLocale(lcid);
|
||||||
|
}
|
||||||
|
else if(!IsValidLocale(lcid, LCID_INSTALLED))
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_INVALID_PARAMETER);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpCurrencyStr) ||
|
if (!lpszValue || cchOut < 0 || (cchOut > 0 && !lpCurrencyStr) ||
|
||||||
!IsValidLocale(lcid, 0) ||
|
|
||||||
(lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep ||
|
(lpFormat && (dwFlags || !lpFormat->lpDecimalSep || !lpFormat->lpThousandSep ||
|
||||||
!lpFormat->lpCurrencySymbol || lpFormat->NegativeOrder > 15 ||
|
!lpFormat->lpCurrencySymbol || lpFormat->NegativeOrder > 15 ||
|
||||||
lpFormat->PositiveOrder > 3)))
|
lpFormat->PositiveOrder > 3)))
|
||||||
|
|
Loading…
Reference in a new issue