mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 17:10:22 +00:00
[NTOSKRNL]
Fix / improve NtQueryDefaultLocale, NtSetDefaultLocale, NtQueryDefaultUILanguage and NtSetDefaultUILanguage svn path=/trunk/; revision=61077
This commit is contained in:
parent
746a4e93ea
commit
7f9dd54593
1 changed files with 81 additions and 22 deletions
|
@ -178,8 +178,8 @@ NtQueryDefaultLocale(IN BOOLEAN UserProfile,
|
||||||
/* Check if we have a user profile */
|
/* Check if we have a user profile */
|
||||||
if (UserProfile)
|
if (UserProfile)
|
||||||
{
|
{
|
||||||
/* Return thread locale */
|
/* Return session wide thread locale */
|
||||||
*DefaultLocaleId = PsDefaultThreadLocaleId;
|
*DefaultLocaleId = MmGetSessionLocaleId();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -206,11 +206,14 @@ NtSetDefaultLocale(IN BOOLEAN UserProfile,
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
UNICODE_STRING KeyName;
|
UNICODE_STRING KeyName;
|
||||||
UNICODE_STRING ValueName;
|
UNICODE_STRING ValueName;
|
||||||
|
UNICODE_STRING LocaleString;
|
||||||
HANDLE KeyHandle;
|
HANDLE KeyHandle;
|
||||||
ULONG ValueLength;
|
ULONG ValueLength;
|
||||||
WCHAR ValueBuffer[20];
|
WCHAR ValueBuffer[20];
|
||||||
HANDLE UserKey;
|
HANDLE UserKey;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
UCHAR KeyValueBuffer[256];
|
||||||
|
PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
/* Check if we have a profile */
|
/* Check if we have a profile */
|
||||||
|
@ -241,12 +244,52 @@ NtSetDefaultLocale(IN BOOLEAN UserProfile,
|
||||||
UserKey,
|
UserKey,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* Check if we don' thave a default locale yet */
|
/* Check if we don't have a default locale yet */
|
||||||
if (!DefaultLocaleId)
|
if (!DefaultLocaleId)
|
||||||
{
|
{
|
||||||
DPRINT1("TODO\n");
|
/* Open the key for reading */
|
||||||
Status = STATUS_SUCCESS;
|
Status = ZwOpenKey(&KeyHandle, KEY_QUERY_VALUE, &ObjectAttributes);
|
||||||
ASSERT(FALSE);
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
KeyHandle = NULL;
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Query the key value */
|
||||||
|
KeyValueInformation = (PKEY_VALUE_PARTIAL_INFORMATION)KeyValueBuffer;
|
||||||
|
Status = ZwQueryValueKey(KeyHandle,
|
||||||
|
&ValueName,
|
||||||
|
KeyValuePartialInformation,
|
||||||
|
KeyValueInformation,
|
||||||
|
sizeof(KeyValueBuffer),
|
||||||
|
&ValueLength);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if this is a REG_DWORD */
|
||||||
|
if ((KeyValueInformation->Type == REG_DWORD) &&
|
||||||
|
(KeyValueInformation->DataLength == sizeof(ULONG)))
|
||||||
|
{
|
||||||
|
/* It contains the LCID as a DWORD */
|
||||||
|
DefaultLocaleId = *((ULONG*)KeyValueInformation->Data);
|
||||||
|
}
|
||||||
|
/* Otherwise check for a REG_SZ */
|
||||||
|
else if (KeyValueInformation->Type == REG_SZ)
|
||||||
|
{
|
||||||
|
/* Initialize a unicode string from the value data */
|
||||||
|
LocaleString.Buffer = (PWCHAR)KeyValueInformation->Data;
|
||||||
|
LocaleString.Length = (USHORT)KeyValueInformation->DataLength;
|
||||||
|
LocaleString.MaximumLength = LocaleString.Length;
|
||||||
|
|
||||||
|
/* Convert the hex string to a number */
|
||||||
|
RtlUnicodeStringToInteger(&LocaleString, 16, &DefaultLocaleId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -280,12 +323,17 @@ NtSetDefaultLocale(IN BOOLEAN UserProfile,
|
||||||
REG_SZ,
|
REG_SZ,
|
||||||
ValueBuffer,
|
ValueBuffer,
|
||||||
ValueLength);
|
ValueLength);
|
||||||
|
|
||||||
/* And close the key */
|
|
||||||
ZwClose(KeyHandle);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cleanup:
|
||||||
|
|
||||||
|
/* Close the locale key */
|
||||||
|
if (KeyHandle)
|
||||||
|
{
|
||||||
|
ObCloseHandle(KeyHandle, KernelMode);
|
||||||
|
}
|
||||||
|
|
||||||
/* Close the user key */
|
/* Close the user key */
|
||||||
if (UserKey)
|
if (UserKey)
|
||||||
{
|
{
|
||||||
|
@ -298,8 +346,8 @@ NtSetDefaultLocale(IN BOOLEAN UserProfile,
|
||||||
/* Check if it was for a user */
|
/* Check if it was for a user */
|
||||||
if (UserProfile)
|
if (UserProfile)
|
||||||
{
|
{
|
||||||
/* Set thread locale */
|
/* Set the session wide thread locale */
|
||||||
PsDefaultThreadLocaleId = DefaultLocaleId;
|
MmSetSessionLocaleId(DefaultLocaleId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -383,13 +431,13 @@ NtQueryDefaultUILanguage(OUT LANGID* LanguageId)
|
||||||
}
|
}
|
||||||
_SEH2_EXCEPT(ExSystemExceptionFilter())
|
_SEH2_EXCEPT(ExSystemExceptionFilter())
|
||||||
{
|
{
|
||||||
/* Get exception code */
|
/* Return exception code */
|
||||||
Status = _SEH2_GetExceptionCode();
|
return _SEH2_GetExceptionCode();
|
||||||
}
|
}
|
||||||
_SEH2_END;
|
_SEH2_END;
|
||||||
|
|
||||||
/* Return status */
|
/* Return success */
|
||||||
return Status;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -399,18 +447,29 @@ NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
NtSetDefaultUILanguage(IN LANGID LanguageId)
|
NtSetDefaultUILanguage(IN LANGID LanguageId)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
|
||||||
/* Check if we don't have a default yet */
|
/* Check if the caller specified a language id */
|
||||||
if (!LanguageId)
|
if (LanguageId)
|
||||||
{
|
{
|
||||||
/* FIXME */
|
/* Set the pending MUI language id */
|
||||||
DPRINT1("TODO\n");
|
Status = ExpSetCurrentUserUILanguage(L"MUILanguagePending", LanguageId);
|
||||||
ASSERT(FALSE);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Otherwise get the pending MUI language id */
|
||||||
|
Status = ExpGetCurrentUserUILanguage(L"MUILanguagePending", &LanguageId);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* And apply it as actual */
|
||||||
|
Status = ExpSetCurrentUserUILanguage(L"MultiUILanguageId", LanguageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, call the internal routine */
|
return Status;
|
||||||
return ExpSetCurrentUserUILanguage(L"MUILanguagePending", LanguageId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue