Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
// EnumerateNTOSInstallations
PGENERIC_LIST
CreateNTOSInstallationsList(
    IN PPARTLIST PartList)
{
    PGENERIC_LIST List;
    PLIST_ENTRY Entry, Entry2;
    PDISKENTRY DiskEntry;
    PPARTENTRY PartEntry;

    List = CreateGenericList();
    if (List == NULL)
        return NULL;

    /* Loop each available disk ... */
    Entry = PartList->DiskListHead.Flink;
    while (Entry != &PartList->DiskListHead)
    {
        DiskEntry = CONTAINING_RECORD(Entry, DISKENTRY, ListEntry);
        Entry = Entry->Flink;

        DPRINT1("Disk #%d\n", DiskEntry->DiskNumber);

        /* ... and for each disk, loop each available partition */

        /* First, the primary partitions */
        Entry2 = DiskEntry->PrimaryPartListHead.Flink;
        while (Entry2 != &DiskEntry->PrimaryPartListHead)
        {
            PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
            Entry2 = Entry2->Flink;

            ASSERT(PartEntry->DiskEntry == DiskEntry);

            DPRINT1("   Primary Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, AutoCreate = %s, FormatState = %lu -- Should I check it? %s\n",
                    PartEntry->PartitionNumber, PartEntry->PartitionIndex,
                    PartEntry->PartitionType, PartEntry->LogicalPartition ? "TRUE" : "FALSE",
                    PartEntry->IsPartitioned ? "TRUE" : "FALSE",
                    PartEntry->New ? "Yes" : "No",
                    PartEntry->AutoCreate ? "Yes" : "No",
                    PartEntry->FormatState,
                    ShouldICheckThisPartition(PartEntry) ? "YES!" : "NO!");

            if (ShouldICheckThisPartition(PartEntry))
                FindNTOSInstallations(List, PartList, PartEntry);
        }

        /* Then, the logical partitions (present in the extended partition) */
        Entry2 = DiskEntry->LogicalPartListHead.Flink;
        while (Entry2 != &DiskEntry->LogicalPartListHead)
        {
            PartEntry = CONTAINING_RECORD(Entry2, PARTENTRY, ListEntry);
            Entry2 = Entry2->Flink;

            ASSERT(PartEntry->DiskEntry == DiskEntry);

            DPRINT1("   Logical Partition #%d, index %d - Type 0x%02x, IsLogical = %s, IsPartitioned = %s, IsNew = %s, AutoCreate = %s, FormatState = %lu -- Should I check it? %s\n",
                    PartEntry->PartitionNumber, PartEntry->PartitionIndex,
                    PartEntry->PartitionType, PartEntry->LogicalPartition ? "TRUE" : "FALSE",
                    PartEntry->IsPartitioned ? "TRUE" : "FALSE",
                    PartEntry->New ? "Yes" : "No",
                    PartEntry->AutoCreate ? "Yes" : "No",
                    PartEntry->FormatState,
                    ShouldICheckThisPartition(PartEntry) ? "YES!" : "NO!");

            if (ShouldICheckThisPartition(PartEntry))
                FindNTOSInstallations(List, PartList, PartEntry);
        }
    }

    /**** Debugging: List all the collected installations ****/
    DumpNTOSInstalls(List);

    return List;
}