Index: reactos/base/setup/usetup/mui.c =================================================================== --- reactos/base/setup/usetup/mui.c (revision 72204) +++ reactos/base/setup/usetup/mui.c (working copy) @@ -384,6 +384,7 @@ ULONG Disposition; ULONG uIndex = 0; ULONG uCount = 0; + ULONG uReverseIndex, uTotalCount, uSize; WCHAR szKeyName[48] = L"\\Registry\\User\\.DEFAULT\\Keyboard Layout"; WCHAR szValueName[3 + 1]; WCHAR szLangID[8 + 1]; @@ -466,11 +467,22 @@ return FALSE; } + /* get total count */ do { if (uIndex > 19) break; + ++uIndex; + } while (MuiLayouts[uIndex].LangID != NULL); - swprintf(szValueName, L"%u", uIndex + 1); + /* set registry values in reverse order */ + uTotalCount = uIndex; + uIndex = 0; + uReverseIndex = uTotalCount - 1; + do + { + if (uIndex > 19) break; + + swprintf(szValueName, L"%u", uReverseIndex + 1); RtlInitUnicodeString(&ValueName, szValueName); swprintf(szLangID, L"0000%s", MuiLayouts[uIndex].LangID); @@ -477,12 +489,13 @@ if (_wcsicmp(szLangID, MuiLayouts[uIndex].LayoutID) == 0) { + uSize = (wcslen(MuiLayouts[uIndex].LayoutID) + 1) * sizeof(WCHAR); Status = NtSetValueKey(KeyHandle, &ValueName, 0, REG_SZ, - (PVOID)MuiLayouts[uIndex].LayoutID, - (wcslen(MuiLayouts[uIndex].LayoutID)+1) * sizeof(WCHAR)); + MuiLayouts[uIndex].LayoutID, + uSize); if (!NT_SUCCESS(Status)) { DPRINT1("NtSetValueKey() failed (Status = %lx, uIndex = %d)\n", Status, uIndex); @@ -494,12 +507,13 @@ else { swprintf(szLangID, L"d%03lu%s", uCount, MuiLayouts[uIndex].LangID); + uSize = (wcslen(szLangID) + 1) * sizeof(WCHAR); Status = NtSetValueKey(KeyHandle, &ValueName, 0, REG_SZ, - (PVOID)szLangID, - (wcslen(szLangID)+1) * sizeof(WCHAR)); + szLangID, + uSize); if (!NT_SUCCESS(Status)) { DPRINT1("NtSetValueKey() failed (Status = %lx, uIndex = %d)\n", Status, uIndex); @@ -510,12 +524,13 @@ RtlInitUnicodeString(&ValueName, szLangID); + uSize = (wcslen(MuiLayouts[uIndex].LayoutID) + 1) * sizeof(WCHAR); Status = NtSetValueKey(SubKeyHandle, &ValueName, 0, REG_SZ, - (PVOID)MuiLayouts[uIndex].LayoutID, - (wcslen(MuiLayouts[uIndex].LayoutID)+1) * sizeof(WCHAR)); + MuiLayouts[uIndex].LayoutID, + uSize); if (!NT_SUCCESS(Status)) { DPRINT1("NtSetValueKey() failed (Status = %lx, uIndex = %u)\n", Status, uIndex); @@ -528,8 +543,8 @@ } uIndex++; - } - while (MuiLayouts[uIndex].LangID != NULL); + uReverseIndex--; + } while (MuiLayouts[uIndex].LangID != NULL); if (uIndex > 1) AddHotkeySettings(L"2", L"2", L"1");