If W32kGetDefaultKeyLayout() is called before a user logged on, fall back to the layout set in HKU\.DEFAULT instead of falling back to US English.

This enables the layout set in 1st stage setup also in 2nd stage setup and half-fixes bug 2952. (win32csr will only use the HKU\.DEFAULT setting as it's loaded before a user logged on. Currently, we don't change the keyboard layout for win32csr, when a user logs on).

svn path=/trunk/; revision=31690
This commit is contained in:
Colin Finck 2008-01-09 17:46:36 +00:00
parent cf111d5b8d
commit 5c1602ce91

View file

@ -272,6 +272,7 @@ BOOL UserInitDefaultKeyboardLayout()
PKBL W32kGetDefaultKeyLayout(VOID) PKBL W32kGetDefaultKeyLayout(VOID)
{ {
const WCHAR szKeyboardLayoutPath[] = L"\\Keyboard Layout\\Preload"; const WCHAR szKeyboardLayoutPath[] = L"\\Keyboard Layout\\Preload";
const WCHAR szDefaultUserPath[] = L"\\REGISTRY\\USER\\.DEFAULT";
HANDLE KeyHandle; HANDLE KeyHandle;
LCID LayoutLocaleId = 0; LCID LayoutLocaleId = 0;
@ -290,41 +291,42 @@ PKBL W32kGetDefaultKeyLayout(VOID)
if( NT_SUCCESS(Status) ) if( NT_SUCCESS(Status) )
{ {
// FIXME: Is this 100% correct? // FIXME: Is this 100% correct?
// We're called very early, so \\REGISTRY\\USER might not be available yet. Check this first. // We're called very early, so HKEY_CURRENT_USER might not be available yet. Check this first.
InitializeObjectAttributes(&KeyAttributes, &CurrentUserPath, OBJ_CASE_INSENSITIVE, NULL, NULL); InitializeObjectAttributes(&KeyAttributes, &CurrentUserPath, OBJ_CASE_INSENSITIVE, NULL, NULL);
Status = ZwOpenKey(&KeyHandle, KEY_READ, &KeyAttributes); Status = ZwOpenKey(&KeyHandle, KEY_READ, &KeyAttributes);
if(Status == STATUS_OBJECT_NAME_NOT_FOUND) if(Status == STATUS_OBJECT_NAME_NOT_FOUND)
{ {
// Fall back to US English without any debug message // It is not available, so read it from HKEY_USERS\.DEFAULT
LayoutLocaleId = 0x409; RtlCopyMemory(wszBuffer, szDefaultUserPath, sizeof(szDefaultUserPath));
} }
else else
{ {
// The path is available, so build the full path to HKEY_CURRENT_USER\Keyboard Layout\Preload // The path is available
ZwClose(KeyHandle); ZwClose(KeyHandle);
RtlCopyMemory(wszBuffer, CurrentUserPath.Buffer, CurrentUserPath.MaximumLength); RtlCopyMemory(wszBuffer, CurrentUserPath.Buffer, CurrentUserPath.MaximumLength);
RtlInitUnicodeString(&FullKeyboardLayoutPath, wszBuffer); }
FullKeyboardLayoutPath.MaximumLength = MAX_PATH;
Status = RtlAppendUnicodeToString(&FullKeyboardLayoutPath, szKeyboardLayoutPath); // Build the full path
RtlInitUnicodeString(&FullKeyboardLayoutPath, wszBuffer);
FullKeyboardLayoutPath.MaximumLength = MAX_PATH;
Status = RtlAppendUnicodeToString(&FullKeyboardLayoutPath, szKeyboardLayoutPath);
if( NT_SUCCESS(Status) )
{
// Return the first keyboard layout listed there
RtlInitUnicodeString(&LayoutValueName, L"1");
Status = ReadRegistryValue(&FullKeyboardLayoutPath, &LayoutValueName, &LayoutLocaleIdString);
if( NT_SUCCESS(Status) ) if( NT_SUCCESS(Status) )
{ RtlUnicodeStringToInteger(&LayoutLocaleIdString, 16, &LayoutLocaleId);
// Return the first keyboard layout listed there
RtlInitUnicodeString(&LayoutValueName, L"1");
Status = ReadRegistryValue(&FullKeyboardLayoutPath, &LayoutValueName, &LayoutLocaleIdString);
if( NT_SUCCESS(Status) )
RtlUnicodeStringToInteger(&LayoutLocaleIdString, 16, &LayoutLocaleId);
else
DPRINT1("ReadRegistryValue failed! (%08lx).\n", Status);
}
else else
DPRINT1("RtlAppendUnicodeToString failed! (%08lx)\n", Status); DPRINT1("ReadRegistryValue failed! (%08lx).\n", Status);
} }
else
DPRINT1("RtlAppendUnicodeToString failed! (%08lx)\n", Status);
RtlFreeUnicodeString(&CurrentUserPath); RtlFreeUnicodeString(&CurrentUserPath);
} }