VirtualBox

Changeset 107060 in vbox for trunk/src/VBox/GuestHost


Ignore:
Timestamp:
Nov 20, 2024 2:14:22 PM (2 months ago)
Author:
vboxsync
Message:

Windows driver installation: Also detect if an INF has a Default *and* a Manufacturer section in VBoxWinDrvInfGetTypeEx(), which is considered as being invalid. bugref:10762

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/installation/VBoxWinDrvCommon.cpp

    r107057 r107060  
    8282
    8383    /* Sorted by most likely-ness. */
    84     static PRTUTF16 s_apwszSections[] =
     84    static PRTUTF16 s_apwsManufacturerSections[] =
    8585    {
    8686        /* Most likely (and doesn't have a decoration). */
     
    9393    INFCONTEXT InfCtx;
    9494    size_t     i;
    95     for (i = 0; i < RT_ELEMENTS(s_apwszSections); i++)
    96     {
    97         PRTUTF16 const pwszSection = s_apwszSections[i];
    98         rc = vboxWinDrvInfQueryContext(hInf, pwszSection, NULL, &InfCtx);
     95
     96    PCRTUTF16 pwszManufacturerSection = NULL;
     97    for (i = 0; i < RT_ELEMENTS(s_apwsManufacturerSections); i++)
     98    {
     99        rc = vboxWinDrvInfQueryContext(hInf, s_apwsManufacturerSections[i], NULL, &InfCtx);
    99100        if (RT_SUCCESS(rc))
     101        {
     102            pwszManufacturerSection = s_apwsManufacturerSections[i];
    100103            break;
    101     }
    102 
    103     if (RT_SUCCESS(rc))
    104     {
    105         if (ppwszSection)
    106             *ppwszSection = RTUtf16Dup(s_apwszSections[i]);
    107 
    108         return VBOXWINDRVINFTYPE_NORMAL;
     104        }
    109105    }
    110106
     
    122118    };
    123119
     120    PCRTUTF16 pwszPrimitiveSection = NULL;
    124121    for (i = 0; i < RT_ELEMENTS(s_apwszPrimitiveSections); i++)
    125122    {
    126         PRTUTF16 const pwszSection = s_apwszPrimitiveSections[i];
    127         rc = vboxWinDrvInfQueryContext(hInf, pwszSection, NULL, &InfCtx);
     123        rc = vboxWinDrvInfQueryContext(hInf, s_apwszPrimitiveSections[i], NULL, &InfCtx);
    128124        if (RT_SUCCESS(rc))
     125        {
     126            pwszPrimitiveSection = s_apwszPrimitiveSections[i];
    129127            break;
    130     }
    131 
    132     if (RT_SUCCESS(rc))
     128        }
     129    }
     130
     131    /* If both sections are present, consider this INF file as being invalid.
     132     * Only one or the other has to be present. */
     133    if (   pwszManufacturerSection
     134        && pwszPrimitiveSection)
     135    {
     136        return VBOXWINDRVINFTYPE_INVALID;
     137    }
     138    else if (pwszManufacturerSection)
    133139    {
    134140        if (ppwszSection)
    135             *ppwszSection = RTUtf16Dup(s_apwszPrimitiveSections[i]);
     141            *ppwszSection = RTUtf16Dup(pwszManufacturerSection);
     142
     143        return VBOXWINDRVINFTYPE_NORMAL;
     144    }
     145    else if (pwszPrimitiveSection)
     146    {
     147        if (ppwszSection)
     148            *ppwszSection = RTUtf16Dup(pwszPrimitiveSection);
    136149
    137150        return VBOXWINDRVINFTYPE_PRIMITIVE;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette