PGENERIC_LIST CreateKeyboardDriverList( HINF InfFile) { CHAR Buffer[128]; PGENERIC_LIST List; INFCONTEXT Context; PWCHAR KeyName; PWCHAR KeyValue; PWCHAR UserData; List = CreateGenericList(); if (List == NULL) return NULL; if (!SetupFindFirstLineW (InfFile, L"Keyboard", NULL, &Context)) { DestroyGenericList(List, FALSE); return NULL; } do { if (!INF_GetData (&Context, &KeyName, &KeyValue)) { /* FIXME: Handle error! */ DPRINT("INF_GetData() failed\n"); break; } UserData = (WCHAR*)RtlAllocateHeap(ProcessHeap, 0, (wcslen(KeyName) + 1) * sizeof(WCHAR)); if (UserData == NULL) { /* FIXME: Handle error! */ } wcscpy(UserData, KeyName); sprintf(Buffer, "%S", KeyValue); AppendGenericListEntry(List, Buffer, UserData, FALSE); } while (SetupFindNextLine(&Context, &Context)); return List; }
PGENERIC_LIST CreateKeyboardLayoutList(HINF InfFile, WCHAR * DefaultKBLayout) { CHAR Buffer[128]; PGENERIC_LIST List; INFCONTEXT Context; PWCHAR KeyName; PWCHAR KeyValue; PWCHAR UserData; const MUI_LAYOUTS * LayoutsList; ULONG uIndex = 0; BOOL KeyboardLayoutsFound = FALSE; /* Get default layout id */ if (!SetupFindFirstLineW (InfFile, L"NLS", L"DefaultLayout", &Context)) return NULL; if (!INF_GetData (&Context, NULL, &KeyValue)) return NULL; wcscpy(DefaultKBLayout, KeyValue); List = CreateGenericList(); if (List == NULL) return NULL; LayoutsList = MUIGetLayoutsList(); do { if (!SetupFindFirstLineW(InfFile, L"KeyboardLayout", NULL, &Context)) { DestroyGenericList(List, FALSE); return NULL; } do { if (!INF_GetData (&Context, &KeyName, &KeyValue)) { /* FIXME: Handle error! */ DPRINT("INF_GetData() failed\n"); DestroyGenericList(List, FALSE); return NULL; } if (_wcsicmp(LayoutsList[uIndex].LayoutID, KeyName) == 0) { UserData = (WCHAR*) RtlAllocateHeap(ProcessHeap, 0, (wcslen(KeyName) + 1) * sizeof(WCHAR)); if (UserData == NULL) { /* FIXME: Handle error! */ DPRINT("RtlAllocateHeap() failed\n"); DestroyGenericList(List, FALSE); return NULL; } wcscpy(UserData, KeyName); sprintf(Buffer, "%S", KeyValue); AppendGenericListEntry(List, Buffer, UserData, _wcsicmp(KeyName, DefaultKBLayout) ? FALSE : TRUE); KeyboardLayoutsFound = TRUE; } } while (SetupFindNextLine(&Context, &Context)); uIndex++; } while (LayoutsList[uIndex].LangID != NULL); /* FIXME: Handle this case */ if (!KeyboardLayoutsFound) { DPRINT1("No keyboard layouts have been found\n"); DestroyGenericList(List, FALSE); return NULL; } return List; }
PGENERIC_LIST CreateLanguageList(HINF InfFile, WCHAR * DefaultLanguage) { CHAR Buffer[128]; PGENERIC_LIST List; INFCONTEXT Context; PWCHAR KeyName; PWCHAR KeyValue; PWCHAR UserData = NULL; ULONG uIndex = 0; /* Get default language id */ if (!SetupFindFirstLineW (InfFile, L"NLS", L"DefaultLanguage", &Context)) return NULL; if (!INF_GetData (&Context, NULL, &KeyValue)) return NULL; wcscpy(DefaultLanguage, KeyValue); SelectedLanguageId = KeyValue; List = CreateGenericList(); if (List == NULL) return NULL; if (!SetupFindFirstLineW (InfFile, L"Language", NULL, &Context)) { DestroyGenericList(List, FALSE); return NULL; } do { if (!INF_GetData (&Context, &KeyName, &KeyValue)) { /* FIXME: Handle error! */ DPRINT("INF_GetData() failed\n"); break; } if (IsLanguageAvailable(KeyName)) { UserData = (WCHAR*) RtlAllocateHeap(ProcessHeap, 0, (wcslen(KeyName) + 1) * sizeof(WCHAR)); if (UserData == NULL) { /* FIXME: Handle error! */ } wcscpy(UserData, KeyName); if (!_wcsicmp(KeyName, DefaultLanguage)) DefaultLanguageIndex = uIndex; sprintf(Buffer, "%S", KeyValue); AppendGenericListEntry(List, Buffer, UserData, FALSE); uIndex++; } } while (SetupFindNextLine(&Context, &Context)); /* Only one language available, make it the default one */ if(uIndex == 1 && UserData != NULL) { DefaultLanguageIndex = 0; wcscpy(DefaultLanguage, UserData); } return List; }
PGENERIC_LIST CreateDisplayDriverList(HINF InfFile) { CHAR Buffer[128]; PGENERIC_LIST List; INFCONTEXT Context; PWCHAR KeyName; PWCHAR KeyValue; PWCHAR UserData; WCHAR DisplayIdentifier[128]; WCHAR DisplayKey[32]; /* Get the display identification */ if (!GetDisplayIdentifier(DisplayIdentifier, 128)) { DisplayIdentifier[0] = 0; } DPRINT("Display identifier: '%S'\n", DisplayIdentifier); /* Search for matching device identifier */ if (!SetupFindFirstLineW(InfFile, L"Map.Display", NULL, &Context)) { /* FIXME: error message */ return NULL; } do { if (!INF_GetDataField(&Context, 1, &KeyValue)) { /* FIXME: Handle error! */ DPRINT("INF_GetDataField() failed\n"); return NULL; } DPRINT("KeyValue: %S\n", KeyValue); if (wcsstr(DisplayIdentifier, KeyValue)) { if (!INF_GetDataField(&Context, 0, &KeyName)) { /* FIXME: Handle error! */ DPRINT("INF_GetDataField() failed\n"); return NULL; } DPRINT("Display key: %S\n", KeyName); wcscpy(DisplayKey, KeyName); } } while (SetupFindNextLine(&Context, &Context)); List = CreateGenericList(); if (List == NULL) return NULL; if (!SetupFindFirstLineW (InfFile, L"Display", NULL, &Context)) { DestroyGenericList(List, FALSE); return NULL; } do { if (!INF_GetDataField(&Context, 0, &KeyName)) { DPRINT1("INF_GetDataField() failed\n"); break; } if (!INF_GetDataField(&Context, 1, &KeyValue)) { DPRINT1("INF_GetDataField() failed\n"); break; } UserData = (WCHAR*) RtlAllocateHeap(ProcessHeap, 0, (wcslen(KeyName) + 1) * sizeof(WCHAR)); if (UserData == NULL) { DPRINT1("RtlAllocateHeap() failed\n"); DestroyGenericList(List, TRUE); return NULL; } wcscpy(UserData, KeyName); sprintf(Buffer, "%S", KeyValue); AppendGenericListEntry(List, Buffer, UserData, _wcsicmp(KeyName, DisplayKey) ? FALSE : TRUE); } while (SetupFindNextLine(&Context, &Context)); #if 0 AppendGenericListEntry(List, "Other display driver", NULL, TRUE); #endif return List; }
static PNTOS_INSTALLATION AddNTOSInstallation( IN PGENERIC_LIST List, IN PCWSTR SystemRootArcPath, IN PUNICODE_STRING SystemRootNtPath, // or PCWSTR ? IN PCWSTR PathComponent, // Pointer inside SystemRootNtPath buffer IN ULONG DiskNumber, IN ULONG PartitionNumber, IN PPARTENTRY PartEntry OPTIONAL, IN PCWSTR InstallationName) { PNTOS_INSTALLATION NtOsInstall; SIZE_T ArcPathLength, NtPathLength; CHAR InstallNameA[MAX_PATH]; /* Is there already any installation with these settings? */ NtOsInstall = FindExistingNTOSInstall(List, SystemRootArcPath, SystemRootNtPath); if (NtOsInstall) { DPRINT1("An NTOS installation with name \"%S\" already exists on disk #%d, partition #%d, in SystemRoot '%wZ'\n", NtOsInstall->InstallationName, NtOsInstall->DiskNumber, NtOsInstall->PartitionNumber, &NtOsInstall->SystemNtPath); // // NOTE: We may use its "IsDefault" attribute, and only keep the entries that have IsDefault == TRUE... // Setting IsDefault to TRUE would imply searching for the "Default" entry in the loader configuration file. // return NtOsInstall; } ArcPathLength = (wcslen(SystemRootArcPath) + 1) * sizeof(WCHAR); // NtPathLength = ROUND_UP(SystemRootNtPath->Length + sizeof(UNICODE_NULL), sizeof(WCHAR)); NtPathLength = SystemRootNtPath->Length + sizeof(UNICODE_NULL); /* None was found, so add a new one */ NtOsInstall = RtlAllocateHeap(ProcessHeap, HEAP_ZERO_MEMORY, sizeof(*NtOsInstall) + ArcPathLength + NtPathLength); if (!NtOsInstall) return NULL; NtOsInstall->DiskNumber = DiskNumber; NtOsInstall->PartitionNumber = PartitionNumber; NtOsInstall->PartEntry = PartEntry; RtlInitEmptyUnicodeString(&NtOsInstall->SystemArcPath, (PWCHAR)(NtOsInstall + 1), ArcPathLength); RtlCopyMemory(NtOsInstall->SystemArcPath.Buffer, SystemRootArcPath, ArcPathLength); NtOsInstall->SystemArcPath.Length = ArcPathLength - sizeof(UNICODE_NULL); RtlInitEmptyUnicodeString(&NtOsInstall->SystemNtPath, (PWCHAR)((ULONG_PTR)(NtOsInstall + 1) + ArcPathLength), NtPathLength); RtlCopyUnicodeString(&NtOsInstall->SystemNtPath, SystemRootNtPath); NtOsInstall->PathComponent = NtOsInstall->SystemNtPath.Buffer + (PathComponent - SystemRootNtPath->Buffer); StringCchCopyW(NtOsInstall->InstallationName, ARRAYSIZE(NtOsInstall->InstallationName), InstallationName); // Having the GENERIC_LIST storing the display item string plainly sucks... StringCchPrintfA(InstallNameA, ARRAYSIZE(InstallNameA), "%S", InstallationName); AppendGenericListEntry(List, InstallNameA, NtOsInstall, FALSE); return NtOsInstall; }