[SETUPLIB] Make the settings' Process* functions take an actual value instead of a GENERIC_LIST

The reason is to avoid enforcing the usage of a specific list
container by the users of the setup library. This is a departure
of what I originally thought would be the best, in commits
92692eae3 (r74553), 8f2c4f7a6 (r75700)

This should actually make some parts of the GUI setup code simpler
(e.g. using the win32 comboboxes to store the list contents).
This commit is contained in:
Hermès Bélusca-Maïto 2024-02-15 23:10:55 +01:00
parent fc3eeb61f3
commit b02dd8eb22
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
5 changed files with 79 additions and 77 deletions

View file

@ -538,8 +538,16 @@ PrepareCopyInfFile(
} }
/* Add specific files depending of computer type */ /* Add specific files depending of computer type */
if (!ProcessComputerFiles(InfFile, pSetupData->ComputerList, &AdditionalSectionName)) {
PGENERIC_LIST_ENTRY Entry;
Entry = GetCurrentListEntry(pSetupData->ComputerList);
ASSERT(Entry);
pSetupData->ComputerType = ((PGENENTRY)GetListEntryData(Entry))->Id;
ASSERT(pSetupData->ComputerType);
if (!ProcessComputerFiles(InfFile, pSetupData->ComputerType, &AdditionalSectionName))
return FALSE; return FALSE;
}
if (AdditionalSectionName && if (AdditionalSectionName &&
!AddSectionToCopyQueue(pSetupData, InfFile, !AddSectionToCopyQueue(pSetupData, InfFile,

View file

@ -785,33 +785,29 @@ CreateDisplayDriverList(
BOOLEAN BOOLEAN
ProcessComputerFiles( ProcessComputerFiles(
IN HINF InfFile, _In_ HINF InfFile,
IN PGENERIC_LIST List, _In_ PCWSTR ComputerType,
OUT PWSTR* AdditionalSectionName) _Out_ PWSTR* AdditionalSectionName)
{ {
PGENERIC_LIST_ENTRY Entry;
static WCHAR SectionName[128]; static WCHAR SectionName[128];
DPRINT("ProcessComputerFiles() called\n"); DPRINT("ProcessComputerFiles(%S) called\n", ComputerType);
Entry = GetCurrentListEntry(List); RtlStringCchPrintfW(SectionName, _countof(SectionName),
if (Entry == NULL) L"Files.%s", ComputerType);
return FALSE;
RtlStringCchPrintfW(SectionName, ARRAYSIZE(SectionName),
L"Files.%s", ((PGENENTRY)GetListEntryData(Entry))->Id);
*AdditionalSectionName = SectionName; *AdditionalSectionName = SectionName;
// TODO: More things to do?
return TRUE; return TRUE;
} }
BOOLEAN BOOLEAN
ProcessDisplayRegistry( ProcessDisplayRegistry(
IN HINF InfFile, _In_ HINF InfFile,
IN PGENERIC_LIST List) _In_ PCWSTR DisplayType)
{ {
NTSTATUS Status; NTSTATUS Status;
PGENERIC_LIST_ENTRY Entry;
INFCONTEXT Context; INFCONTEXT Context;
PCWSTR Buffer; PCWSTR Buffer;
PCWSTR ServiceName; PCWSTR ServiceName;
@ -822,15 +818,9 @@ ProcessDisplayRegistry(
HANDLE KeyHandle; HANDLE KeyHandle;
WCHAR RegPath[255]; WCHAR RegPath[255];
DPRINT("ProcessDisplayRegistry() called\n"); DPRINT("ProcessDisplayRegistry(%S) called\n", DisplayType);
Entry = GetCurrentListEntry(List); if (!SpInfFindFirstLine(InfFile, L"Display", DisplayType, &Context))
if (Entry == NULL)
return FALSE;
if (!SpInfFindFirstLine(InfFile, L"Display",
((PGENENTRY)GetListEntryData(Entry))->Id,
&Context))
{ {
DPRINT1("SpInfFindFirstLine() failed\n"); DPRINT1("SpInfFindFirstLine() failed\n");
return FALSE; return FALSE;
@ -935,7 +925,7 @@ ProcessDisplayRegistry(
return FALSE; return FALSE;
} }
Height = wcstoul(Buffer, 0, 0); Height = wcstoul(Buffer, NULL, 10);
Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE, KeyHandle, Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE, KeyHandle,
L"DefaultSettings.YResolution", L"DefaultSettings.YResolution",
REG_DWORD, REG_DWORD,
@ -955,7 +945,7 @@ ProcessDisplayRegistry(
return FALSE; return FALSE;
} }
Bpp = wcstoul(Buffer, 0, 0); Bpp = wcstoul(Buffer, NULL, 10);
Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE, KeyHandle, Status = RtlWriteRegistryValue(RTL_REGISTRY_HANDLE, KeyHandle,
L"DefaultSettings.BitsPerPel", L"DefaultSettings.BitsPerPel",
REG_DWORD, REG_DWORD,
@ -977,25 +967,14 @@ ProcessDisplayRegistry(
BOOLEAN BOOLEAN
ProcessLocaleRegistry( ProcessLocaleRegistry(
IN PGENERIC_LIST List) _In_ PCWSTR LanguageId)
{ {
PGENERIC_LIST_ENTRY Entry;
PCWSTR LanguageId;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName; UNICODE_STRING KeyName;
UNICODE_STRING ValueName; UNICODE_STRING ValueName;
HANDLE KeyHandle; HANDLE KeyHandle;
NTSTATUS Status; NTSTATUS Status;
Entry = GetCurrentListEntry(List);
if (Entry == NULL)
return FALSE;
LanguageId = ((PGENENTRY)GetListEntryData(Entry))->Id;
if (LanguageId == NULL)
return FALSE;
DPRINT("LanguageId: %S\n", LanguageId); DPRINT("LanguageId: %S\n", LanguageId);
/* Open the default users locale key */ /* Open the default users locale key */
@ -1286,22 +1265,15 @@ CreateKeyboardLayoutList(
BOOLEAN BOOLEAN
ProcessKeyboardLayoutRegistry( ProcessKeyboardLayoutRegistry(
IN PGENERIC_LIST List, _In_ PCWSTR pszLayoutId,
IN PCWSTR LanguageId) _In_ PCWSTR LanguageId)
{ {
PGENERIC_LIST_ENTRY Entry;
PCWSTR pszLayoutId;
KLID LayoutId; KLID LayoutId;
const MUI_LAYOUTS* LayoutsList; const MUI_LAYOUTS* LayoutsList;
MUI_LAYOUTS NewLayoutsList[20]; // HACK: Hardcoded fixed size "20" is a hack. Please verify against lang/*.h MUI_LAYOUTS NewLayoutsList[20]; // HACK: Hardcoded fixed size "20" is a hack. Please verify against lang/*.h
ULONG uIndex; ULONG uIndex;
ULONG uOldPos = 0; ULONG uOldPos = 0;
Entry = GetCurrentListEntry(List);
if (Entry == NULL)
return FALSE;
pszLayoutId = ((PGENENTRY)GetListEntryData(Entry))->Id;
LayoutId = (KLID)(pszLayoutId ? wcstoul(pszLayoutId, NULL, 16) : 0); LayoutId = (KLID)(pszLayoutId ? wcstoul(pszLayoutId, NULL, 16) : 0);
if (LayoutId == 0) if (LayoutId == 0)
return FALSE; return FALSE;
@ -1394,10 +1366,9 @@ SetGeoID(
return TRUE; return TRUE;
} }
BOOLEAN BOOLEAN
SetDefaultPagefile( SetDefaultPagefile(
IN WCHAR Drive) _In_ WCHAR Drive)
{ {
NTSTATUS Status; NTSTATUS Status;
HANDLE KeyHandle; HANDLE KeyHandle;

View file

@ -43,14 +43,14 @@ CreateDisplayDriverList(
BOOLEAN BOOLEAN
ProcessComputerFiles( ProcessComputerFiles(
IN HINF InfFile, _In_ HINF InfFile,
IN PGENERIC_LIST List, _In_ PCWSTR ComputerType,
OUT PWSTR* AdditionalSectionName); _Out_ PWSTR* AdditionalSectionName);
BOOLEAN BOOLEAN
ProcessDisplayRegistry( ProcessDisplayRegistry(
IN HINF InfFile, _In_ HINF InfFile,
IN PGENERIC_LIST List); _In_ PCWSTR DisplayType);
PGENERIC_LIST PGENERIC_LIST
CreateKeyboardDriverList( CreateKeyboardDriverList(
@ -72,16 +72,18 @@ GetDefaultLanguageIndex(VOID);
BOOLEAN BOOLEAN
ProcessKeyboardLayoutRegistry( ProcessKeyboardLayoutRegistry(
IN PGENERIC_LIST List, _In_ PCWSTR pszLayoutId,
IN PCWSTR LanguageId); _In_ PCWSTR LanguageId);
#if 0
BOOLEAN BOOLEAN
ProcessKeyboardLayoutFiles( ProcessKeyboardLayoutFiles(
IN PGENERIC_LIST List); IN PGENERIC_LIST List);
#endif
BOOLEAN BOOLEAN
ProcessLocaleRegistry( ProcessLocaleRegistry(
IN PGENERIC_LIST List); _In_ PCWSTR LanguageId);
BOOLEAN BOOLEAN
SetGeoID( SetGeoID(
@ -89,6 +91,6 @@ SetGeoID(
BOOLEAN BOOLEAN
SetDefaultPagefile( SetDefaultPagefile(
IN WCHAR Drive); _In_ WCHAR Drive);
/* EOF */ /* EOF */

View file

@ -789,12 +789,6 @@ InitializeSetup(
{ {
RtlZeroMemory(pSetupData, sizeof(*pSetupData)); RtlZeroMemory(pSetupData, sizeof(*pSetupData));
// pSetupData->ComputerList = NULL;
// pSetupData->DisplayList = NULL;
// pSetupData->KeyboardList = NULL;
// pSetupData->LayoutList = NULL;
// pSetupData->LanguageList = NULL;
/* Initialize error handling */ /* Initialize error handling */
pSetupData->LastErrorNumber = ERROR_SUCCESS; pSetupData->LastErrorNumber = ERROR_SUCCESS;
pSetupData->ErrorRoutine = NULL; pSetupData->ErrorRoutine = NULL;
@ -1059,23 +1053,36 @@ DoUpdate:
{ {
/* See the explanation for this test above */ /* See the explanation for this test above */
PGENERIC_LIST_ENTRY Entry;
PCWSTR LanguageId; // LocaleID;
Entry = GetCurrentListEntry(pSetupData->DisplayList);
ASSERT(Entry);
pSetupData->DisplayType = ((PGENENTRY)GetListEntryData(Entry))->Id;
ASSERT(pSetupData->DisplayType);
/* Update display registry settings */ /* Update display registry settings */
if (StatusRoutine) StatusRoutine(DisplaySettingsUpdate); if (StatusRoutine) StatusRoutine(DisplaySettingsUpdate);
if (!ProcessDisplayRegistry(pSetupData->SetupInf, pSetupData->DisplayList)) if (!ProcessDisplayRegistry(pSetupData->SetupInf, pSetupData->DisplayType))
{ {
ErrorNumber = ERROR_UPDATE_DISPLAY_SETTINGS; ErrorNumber = ERROR_UPDATE_DISPLAY_SETTINGS;
goto Cleanup; goto Cleanup;
} }
Entry = GetCurrentListEntry(pSetupData->LanguageList);
ASSERT(Entry);
LanguageId = ((PGENENTRY)GetListEntryData(Entry))->Id;
ASSERT(LanguageId);
/* Set the locale */ /* Set the locale */
if (StatusRoutine) StatusRoutine(LocaleSettingsUpdate); if (StatusRoutine) StatusRoutine(LocaleSettingsUpdate);
if (!ProcessLocaleRegistry(pSetupData->LanguageList)) if (!ProcessLocaleRegistry(/*pSetupData->*/LanguageId))
{ {
ErrorNumber = ERROR_UPDATE_LOCALESETTINGS; ErrorNumber = ERROR_UPDATE_LOCALESETTINGS;
goto Cleanup; goto Cleanup;
} }
/* Add keyboard layouts */ /* Add the keyboard layouts for the given language (without user override) */
if (StatusRoutine) StatusRoutine(KeybLayouts); if (StatusRoutine) StatusRoutine(KeybLayouts);
if (!AddKeyboardLayouts(SelectedLanguageId)) if (!AddKeyboardLayouts(SelectedLanguageId))
{ {
@ -1083,6 +1090,24 @@ DoUpdate:
goto Cleanup; goto Cleanup;
} }
if (!IsUnattendedSetup)
{
Entry = GetCurrentListEntry(pSetupData->LayoutList);
ASSERT(Entry);
pSetupData->LayoutId = ((PGENENTRY)GetListEntryData(Entry))->Id;
ASSERT(pSetupData->LayoutId);
/* Update keyboard layout settings with user-overridden values */
// FIXME: Wouldn't it be better to do it all at once
// with the AddKeyboardLayouts() step?
if (StatusRoutine) StatusRoutine(KeybSettingsUpdate);
if (!ProcessKeyboardLayoutRegistry(pSetupData->LayoutId, SelectedLanguageId))
{
ErrorNumber = ERROR_UPDATE_KBSETTINGS;
goto Cleanup;
}
}
/* Set GeoID */ /* Set GeoID */
if (!SetGeoID(MUIGetGeoID(SelectedLanguageId))) if (!SetGeoID(MUIGetGeoID(SelectedLanguageId)))
{ {
@ -1090,17 +1115,6 @@ DoUpdate:
goto Cleanup; goto Cleanup;
} }
if (!IsUnattendedSetup)
{
/* Update keyboard layout settings */
if (StatusRoutine) StatusRoutine(KeybSettingsUpdate);
if (!ProcessKeyboardLayoutRegistry(pSetupData->LayoutList, SelectedLanguageId))
{
ErrorNumber = ERROR_UPDATE_KBSETTINGS;
goto Cleanup;
}
}
/* Add codepage information to registry */ /* Add codepage information to registry */
if (StatusRoutine) StatusRoutine(CodePageInfoUpdate); if (StatusRoutine) StatusRoutine(CodePageInfoUpdate);
if (!AddCodePage(SelectedLanguageId)) if (!AddCodePage(SelectedLanguageId))

View file

@ -122,6 +122,13 @@ typedef struct _USETUP_DATA
PGENERIC_LIST LayoutList; PGENERIC_LIST LayoutList;
PGENERIC_LIST LanguageList; PGENERIC_LIST LanguageList;
/* Settings *****/
PCWSTR ComputerType;
PCWSTR DisplayType;
// PCWSTR KeyboardDriver;
// PCWSTR MouseDriver;
PCWSTR LayoutId; // DefaultKBLayout
/* Other stuff *****/ /* Other stuff *****/
WCHAR LocaleID[9]; WCHAR LocaleID[9];
LANGID LanguageId; LANGID LanguageId;