PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName =
- RTL_CONSTANT_STRING(L"Control Panel\\International");
+ RTL_CONSTANT_STRING(L"Control Panel\\Desktop");
UNICODE_STRING ValueName;
UNICODE_STRING ValueString;
ULONG ValueLength;
/* Initialize the attributes and open the key */
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
- OBJ_CASE_INSENSITIVE,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
UserKey,
NULL);
Status = ZwOpenKey(&KeyHandle, KEY_QUERY_VALUE,&ObjectAttributes);
/* Fail */
Status = STATUS_UNSUCCESSFUL;
}
-
- /* Close the key */
- ZwClose(KeyHandle);
}
+
+ /* Close the key */
+ ZwClose(KeyHandle);
}
/* Close the user key and return */
/* Check if we have a user profile */
if (UserProfile)
{
- /* Return thread locale */
- *DefaultLocaleId = PsDefaultThreadLocaleId;
+ /* Return session wide thread locale */
+ *DefaultLocaleId = MmGetSessionLocaleId();
}
else
{
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
UNICODE_STRING ValueName;
+ UNICODE_STRING LocaleString;
HANDLE KeyHandle;
ULONG ValueLength;
WCHAR ValueBuffer[20];
HANDLE UserKey;
NTSTATUS Status;
+ UCHAR KeyValueBuffer[256];
+ PKEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
PAGED_CODE();
/* Check if we have a profile */
{
/* Open the user's key */
Status = RtlOpenCurrentUser(KEY_WRITE, &UserKey);
- if (!NT_SUCCESS(Status)) return(Status);
+ if (!NT_SUCCESS(Status)) return Status;
/* Initialize the registry location */
RtlInitUnicodeString(&KeyName, L"Control Panel\\International");
UserKey = NULL;
}
- /* Initailize the object attributes */
+ /* Initialize the object attributes */
InitializeObjectAttributes(&ObjectAttributes,
- &KeyName,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- UserKey,
- NULL);
+ &KeyName,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
+ UserKey,
+ NULL);
- /* Check if we don' thave a default locale yet */
+ /* Check if we don't have a default locale yet */
if (!DefaultLocaleId)
{
- DPRINT1("TODO\n");
- Status = STATUS_SUCCESS;
- ASSERT(FALSE);
+ /* Open the key for reading */
+ Status = ZwOpenKey(&KeyHandle, KEY_QUERY_VALUE, &ObjectAttributes);
+ 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
{
REG_SZ,
ValueBuffer,
ValueLength);
-
- /* And close the key */
- ZwClose(KeyHandle);
}
}
+Cleanup:
+
+ /* Close the locale key */
+ if (KeyHandle)
+ {
+ ObCloseHandle(KeyHandle, KernelMode);
+ }
+
/* Close the user key */
if (UserKey)
{
/* Check if it was for a user */
if (UserProfile)
{
- /* Set thread locale */
- PsDefaultThreadLocaleId = DefaultLocaleId;
+ /* Set the session wide thread locale */
+ MmSetSessionLocaleId(DefaultLocaleId);
}
else
{
}
_SEH2_EXCEPT(ExSystemExceptionFilter())
{
- /* Get exception code */
- Status = _SEH2_GetExceptionCode();
+ /* Return exception code */
+ _SEH2_YIELD(return _SEH2_GetExceptionCode());
}
_SEH2_END;
- /* Return status */
- return Status;
+ /* Return success */
+ return STATUS_SUCCESS;
}
/*
NTAPI
NtSetDefaultUILanguage(IN LANGID LanguageId)
{
+ NTSTATUS Status;
PAGED_CODE();
- /* Check if we don't have a default yet */
- if (!LanguageId)
+ /* Check if the caller specified a language id */
+ if (LanguageId)
+ {
+ /* Set the pending MUI language id */
+ Status = ExpSetCurrentUserUILanguage(L"MUILanguagePending", LanguageId);
+ }
+ else
{
- /* FIXME */
- DPRINT1("TODO\n");
- ASSERT(FALSE);
+ /* 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 ExpSetCurrentUserUILanguage(L"MUILanguagePending", LanguageId);
+ return Status;
}
/* EOF */