Implement NtQueryDefaultUILanguage, NtQueryInstallUILanguage and NtSetDefaultUILanguage.

svn path=/trunk/; revision=10873
This commit is contained in:
Eric Kohl 2004-09-16 11:47:18 +00:00
parent 1672f6069e
commit 9f8dc789cf
2 changed files with 221 additions and 63 deletions

View file

@ -1,4 +1,4 @@
; $Id: ntdll.def,v 1.130 2004/09/16 10:25:15 gvg Exp $ ; $Id: ntdll.def,v 1.131 2004/09/16 11:47:18 ekohl Exp $
; ;
; ReactOS Operating System ; ReactOS Operating System
; ;
@ -161,6 +161,7 @@ NtProtectVirtualMemory@20
NtPulseEvent@8 NtPulseEvent@8
NtQueryAttributesFile@8 NtQueryAttributesFile@8
NtQueryDefaultLocale@8 NtQueryDefaultLocale@8
NtQueryDefaultUILanguage@4
NtQueryDirectoryFile@44 NtQueryDirectoryFile@44
NtQueryDirectoryObject@28 NtQueryDirectoryObject@28
NtQueryEaFile@36 NtQueryEaFile@36
@ -172,8 +173,9 @@ NtQueryInformationPort@20
NtQueryInformationProcess@20 NtQueryInformationProcess@20
NtQueryInformationThread@20 NtQueryInformationThread@20
NtQueryInformationToken@20 NtQueryInformationToken@20
NtQueryIoCompletion@20 NtQueryInstallUILanguage@4
NtQueryIntervalProfile@8 NtQueryIntervalProfile@8
NtQueryIoCompletion@20
NtQueryKey@20 NtQueryKey@20
NtQueryMultipleValueKey@24 NtQueryMultipleValueKey@24
NtQueryMutant@20 NtQueryMutant@20
@ -219,6 +221,7 @@ NtSetContextChannel@4
NtSetContextThread@8 NtSetContextThread@8
NtSetDefaultHardErrorPort@4 NtSetDefaultHardErrorPort@4
NtSetDefaultLocale@8 NtSetDefaultLocale@8
NtSetDefaultUILanguage@4
NtSetEaFile@16 NtSetEaFile@16
NtSetEvent@8 NtSetEvent@8
NtSetHighEventPair@4 NtSetHighEventPair@4
@ -776,6 +779,7 @@ ZwQueueApcThread@20
ZwQueryInformationAtom@20 ZwQueryInformationAtom@20
ZwQueryAttributesFile@8 ZwQueryAttributesFile@8
ZwQueryDefaultLocale@8 ZwQueryDefaultLocale@8
ZwQueryDefaultUILanguage@4
ZwQueryDirectoryFile@44 ZwQueryDirectoryFile@44
ZwQueryDirectoryObject@28 ZwQueryDirectoryObject@28
ZwQueryEaFile@36 ZwQueryEaFile@36
@ -786,6 +790,7 @@ ZwQueryInformationPort@20
ZwQueryInformationProcess@20 ZwQueryInformationProcess@20
ZwQueryInformationThread@20 ZwQueryInformationThread@20
ZwQueryInformationToken@20 ZwQueryInformationToken@20
ZwQueryInstallUILanguage@4
ZwQueryIntervalProfile@8 ZwQueryIntervalProfile@8
ZwQueryIoCompletion@20 ZwQueryIoCompletion@20
ZwQueryKey@20 ZwQueryKey@20
@ -832,6 +837,7 @@ ZwSetContextChannel@4
ZwSetContextThread@8 ZwSetContextThread@8
ZwSetDefaultHardErrorPort@4 ZwSetDefaultHardErrorPort@4
ZwSetDefaultLocale@8 ZwSetDefaultLocale@8
ZwSetDefaultUILanguage@4
ZwSetEaFile@16 ZwSetEaFile@16
ZwSetEvent@8 ZwSetEvent@8
ZwSetHighEventPair@4 ZwSetHighEventPair@4

View file

@ -1,4 +1,4 @@
/* $Id: locale.c,v 1.10 2004/08/15 16:39:10 chorns Exp $ /* $Id: locale.c,v 1.11 2004/09/16 11:45:06 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -12,6 +12,8 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ntoskrnl.h> #include <ntoskrnl.h>
#define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -24,12 +26,12 @@ LCID PsDefaultThreadLocaleId = 0;
LCID PsDefaultSystemLocaleId = 0; LCID PsDefaultSystemLocaleId = 0;
BOOL PsDefaultThreadLocaleInitialized = FALSE; BOOL PsDefaultThreadLocaleInitialized = FALSE;
static LANGID PsInstallUILanguageId = 0;
#define VALUE_BUFFER_SIZE 256 #define VALUE_BUFFER_SIZE 256
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID INIT_FUNCTION
PiInitDefaultLocale(VOID)
/* /*
* FUNCTION: * FUNCTION:
* Initializes the default locale. * Initializes the default locale.
@ -39,6 +41,8 @@ PiInitDefaultLocale(VOID)
* Returns: * Returns:
* None. * None.
*/ */
VOID INIT_FUNCTION
PiInitDefaultLocale(VOID)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName; UNICODE_STRING KeyName;
@ -48,16 +52,13 @@ PiInitDefaultLocale(VOID)
UCHAR ValueBuffer[VALUE_BUFFER_SIZE]; UCHAR ValueBuffer[VALUE_BUFFER_SIZE];
PKEY_VALUE_PARTIAL_INFORMATION ValueInfo; PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
UNICODE_STRING ValueString; UNICODE_STRING ValueString;
ULONG LocaleValue; ULONG Value;
NTSTATUS Status; NTSTATUS Status;
ValueInfo = (PKEY_VALUE_PARTIAL_INFORMATION)ValueBuffer; ValueInfo = (PKEY_VALUE_PARTIAL_INFORMATION)ValueBuffer;
/* read system locale */
RtlRosInitUnicodeStringFromLiteral(&KeyName, RtlRosInitUnicodeStringFromLiteral(&KeyName,
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language"); L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language");
RtlRosInitUnicodeStringFromLiteral(&ValueName,
L"Default");
InitializeObjectAttributes(&ObjectAttributes, InitializeObjectAttributes(&ObjectAttributes,
&KeyName, &KeyName,
@ -69,6 +70,9 @@ PiInitDefaultLocale(VOID)
&ObjectAttributes); &ObjectAttributes);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
/* Read system locale */
RtlRosInitUnicodeStringFromLiteral(&ValueName,
L"Default");
Status = NtQueryValueKey(KeyHandle, Status = NtQueryValueKey(KeyHandle,
&ValueName, &ValueName,
KeyValuePartialInformation, KeyValuePartialInformation,
@ -83,20 +87,44 @@ PiInitDefaultLocale(VOID)
Status = RtlUnicodeStringToInteger(&ValueString, Status = RtlUnicodeStringToInteger(&ValueString,
16, 16,
&LocaleValue); &Value);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
DPRINT("System locale: %08lu\n", LocaleValue); DPRINT("System locale: %08lx\n", Value);
PsDefaultSystemLocaleId = (LCID)LocaleValue; PsDefaultSystemLocaleId = (LCID)Value;
} }
} }
/* Read install language id */
RtlRosInitUnicodeStringFromLiteral(&ValueName,
L"InstallLanguage");
Status = NtQueryValueKey(KeyHandle,
&ValueName,
KeyValuePartialInformation,
ValueBuffer,
VALUE_BUFFER_SIZE,
&ValueLength);
if ((NT_SUCCESS(Status)) && (ValueInfo->Type == REG_SZ))
{
ValueString.Length = ValueInfo->DataLength;
ValueString.MaximumLength = ValueInfo->DataLength;
ValueString.Buffer = (PWSTR)ValueInfo->Data;
Status = RtlUnicodeStringToInteger(&ValueString,
16,
&Value);
if (NT_SUCCESS(Status))
{
DPRINT("Install language id: %04lx\n", Value);
PsInstallUILanguageId = (LANGID)Value;
}
}
NtClose(KeyHandle); NtClose(KeyHandle);
} }
} }
VOID STDCALL
PiInitThreadLocale(VOID)
/* /*
* FUNCTION: * FUNCTION:
* Initializes the default thread locale. * Initializes the default thread locale.
@ -106,6 +134,8 @@ PiInitThreadLocale(VOID)
* Returns: * Returns:
* None. * None.
*/ */
VOID STDCALL
PiInitThreadLocale(VOID)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName; UNICODE_STRING KeyName;
@ -164,9 +194,6 @@ PiInitThreadLocale(VOID)
} }
NTSTATUS STDCALL
NtQueryDefaultLocale(IN BOOLEAN ThreadOrSystem,
OUT PLCID DefaultLocaleId)
/* /*
* FUNCTION: * FUNCTION:
* Returns the default locale. * Returns the default locale.
@ -177,6 +204,9 @@ NtQueryDefaultLocale(IN BOOLEAN ThreadOrSystem,
* Returns: * Returns:
* Status. * Status.
*/ */
NTSTATUS STDCALL
NtQueryDefaultLocale(IN BOOLEAN ThreadOrSystem,
OUT PLCID DefaultLocaleId)
{ {
if (DefaultLocaleId == NULL) if (DefaultLocaleId == NULL)
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
@ -187,6 +217,7 @@ NtQueryDefaultLocale(IN BOOLEAN ThreadOrSystem,
{ {
PiInitThreadLocale(); PiInitThreadLocale();
} }
/* set thread locale */ /* set thread locale */
*DefaultLocaleId = PsDefaultThreadLocaleId; *DefaultLocaleId = PsDefaultThreadLocaleId;
} }
@ -195,13 +226,11 @@ NtQueryDefaultLocale(IN BOOLEAN ThreadOrSystem,
/* set system locale */ /* set system locale */
*DefaultLocaleId = PsDefaultSystemLocaleId; *DefaultLocaleId = PsDefaultSystemLocaleId;
} }
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
} }
NTSTATUS STDCALL
NtSetDefaultLocale(IN BOOLEAN ThreadOrSystem,
IN LCID DefaultLocaleId)
/* /*
* FUNCTION: * FUNCTION:
* Sets the default locale. * Sets the default locale.
@ -212,6 +241,9 @@ NtSetDefaultLocale(IN BOOLEAN ThreadOrSystem,
* Returns: * Returns:
* Status. * Status.
*/ */
NTSTATUS STDCALL
NtSetDefaultLocale(IN BOOLEAN ThreadOrSystem,
IN LCID DefaultLocaleId)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName; UNICODE_STRING KeyName;
@ -261,7 +293,7 @@ NtSetDefaultLocale(IN BOOLEAN ThreadOrSystem,
} }
ValueLength = swprintf(ValueBuffer, ValueLength = swprintf(ValueBuffer,
L"%08lu", L"%08lx",
(ULONG)DefaultLocaleId); (ULONG)DefaultLocaleId);
ValueLength = (ValueLength + 1) * sizeof(WCHAR); ValueLength = (ValueLength + 1) * sizeof(WCHAR);
@ -297,44 +329,164 @@ NtSetDefaultLocale(IN BOOLEAN ThreadOrSystem,
PsDefaultSystemLocaleId = DefaultLocaleId; PsDefaultSystemLocaleId = DefaultLocaleId;
} }
return(STATUS_SUCCESS); return STATUS_SUCCESS;
} }
/* /*
* @unimplemented * @implemented
*/ */
NTSTATUS NTSTATUS STDCALL
STDCALL NtQueryDefaultUILanguage(OUT PLANGID LanguageId)
NtQueryDefaultUILanguage(
PLANGID LanguageId
)
{ {
UNIMPLEMENTED; UCHAR ValueBuffer[VALUE_BUFFER_SIZE];
return STATUS_NOT_IMPLEMENTED; PKEY_VALUE_PARTIAL_INFORMATION ValueInfo;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
UNICODE_STRING ValueName;
UNICODE_STRING ValueString;
ULONG ValueLength;
ULONG Value;
HANDLE UserKey;
HANDLE KeyHandle;
NTSTATUS Status;
Status = RtlOpenCurrentUser(KEY_READ,
&UserKey);
if (!NT_SUCCESS(Status))
{
*LanguageId = PsInstallUILanguageId;
return STATUS_SUCCESS;
}
RtlRosInitUnicodeStringFromLiteral(&KeyName,
L"Control Panel\\International");
RtlRosInitUnicodeStringFromLiteral(&ValueName,
L"MultiUILanguageId");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
UserKey,
NULL);
Status = NtOpenKey(&KeyHandle,
KEY_QUERY_VALUE,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
*LanguageId = PsInstallUILanguageId;
return STATUS_SUCCESS;
}
ValueInfo = (PKEY_VALUE_PARTIAL_INFORMATION)ValueBuffer;
Status = NtQueryValueKey(KeyHandle,
&ValueName,
KeyValuePartialInformation,
ValueBuffer,
VALUE_BUFFER_SIZE,
&ValueLength);
NtClose(KeyHandle);
NtClose(UserKey);
if (!NT_SUCCESS(Status) || ValueInfo->Type != REG_SZ)
{
*LanguageId = PsInstallUILanguageId;
return STATUS_SUCCESS;
}
ValueString.Length = ValueInfo->DataLength;
ValueString.MaximumLength = ValueInfo->DataLength;
ValueString.Buffer = (PWSTR)ValueInfo->Data;
Status = RtlUnicodeStringToInteger(&ValueString,
16,
&Value);
if (!NT_SUCCESS(Status))
{
*LanguageId = PsInstallUILanguageId;
return STATUS_SUCCESS;
}
DPRINT("Default language id: %04lx\n", Value);
*LanguageId = Value;
return STATUS_SUCCESS;
} }
/* /*
* @unimplemented * @implemented
*/ */
NTSTATUS NTSTATUS STDCALL
STDCALL NtQueryInstallUILanguage(OUT PLANGID LanguageId)
NtQueryInstallUILanguage(
PLANGID LanguageId
)
{ {
UNIMPLEMENTED; *LanguageId = PsInstallUILanguageId;
return STATUS_NOT_IMPLEMENTED;
return STATUS_SUCCESS;
} }
/* /*
* @unimplemented * @implemented
*/ */
NTSTATUS NTSTATUS STDCALL
STDCALL NtSetDefaultUILanguage(IN LANGID LanguageId)
NtSetDefaultUILanguage(
LANGID LanguageId
)
{ {
UNIMPLEMENTED; OBJECT_ATTRIBUTES ObjectAttributes;
return STATUS_NOT_IMPLEMENTED; UNICODE_STRING KeyName;
UNICODE_STRING ValueName;
WCHAR ValueBuffer[8];
ULONG ValueLength;
HANDLE UserHandle;
HANDLE KeyHandle;
NTSTATUS Status;
Status = RtlOpenCurrentUser(KEY_WRITE,
&UserHandle);
if (!NT_SUCCESS(Status))
{
return Status;
}
RtlRosInitUnicodeStringFromLiteral(&KeyName,
L"Control Panel\\Desktop");
RtlRosInitUnicodeStringFromLiteral(&ValueName,
L"MultiUILanguageId");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
UserHandle,
NULL);
Status = NtOpenKey(&KeyHandle,
KEY_SET_VALUE,
&ObjectAttributes);
if (!NT_SUCCESS(Status))
{
NtClose(UserHandle);
return Status;
}
ValueLength = swprintf(ValueBuffer,
L"%04lX",
(ULONG)LanguageId);
ValueLength = (ValueLength + 1) * sizeof(WCHAR);
Status = NtSetValueKey(KeyHandle,
&ValueName,
0,
REG_SZ,
ValueBuffer,
ValueLength);
NtClose(KeyHandle);
NtClose(UserHandle);
return Status;
} }
/* EOF */ /* EOF */