VirtualBox

Ignore:
Timestamp:
Sep 5, 2022 6:12:44 PM (2 years ago)
Author:
vboxsync
Message:

Add/NT/Inst: Fixed some bugs in the NT4 video driver installation helper. bugref:10261

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestDrvInst.cpp

    r96421 r96603  
    9898
    9999/**
    100  * Inner video driver installation function.
     100 * Inner NT4 video driver installation function.
    101101 *
    102102 * This can normally return immediately on errors as the parent will do the
    103103 * cleaning up.
    104104 */
    105 static RTEXITCODE InstallVideoDriverInner(WCHAR const * const pwszDriverDir, HDEVINFO hDevInfo, HINF *phInf)
    106 {
    107     /*
    108      * Get the first found driver.
    109      * Our Inf file only contains one so this is fine.
    110      */
    111     SP_DRVINFO_DATA_W drvInfoData = { sizeof(SP_DRVINFO_DATA) };
     105static RTEXITCODE InstallNt4VideoDriverInner(WCHAR const * const pwszDriverDir, HDEVINFO hDevInfo, HINF *phInf)
     106{
     107    /*
     108     * Get the first found driver - our Inf file only contains one so this is ok.
     109     *
     110     * Note! We must use the V1 structure here as it is the only NT4 recognizes.
     111     *       There are four versioned structures:
     112     *          - SP_ALTPLATFORM_INFO
     113     *          - SP_DRVINFO_DATA_W
     114     *          - SP_BACKUP_QUEUE_PARAMS_W
     115     *          - SP_INF_SIGNER_INFO_W,
     116     *       but we only make use of SP_DRVINFO_DATA_W.
     117     */
     118    SetLastError(NO_ERROR);
     119    SP_DRVINFO_DATA_V1_W drvInfoData = { sizeof(drvInfoData) };
    112120    if (!SetupDiEnumDriverInfoW(hDevInfo, NULL, SPDIT_CLASSDRIVER, 0, &drvInfoData))
    113121        return ErrorMsgLastErr("SetupDiEnumDriverInfoW");
     
    120128        SP_DRVINFO_DETAIL_DATA_W s;
    121129        uint64_t                 au64Padding[(sizeof(SP_DRVINFO_DETAIL_DATA_W) + 256) / sizeof(uint64_t)];
    122     } DriverInfoDetailData = { { sizeof(SP_DRVINFO_DETAIL_DATA) } };
     130    } DriverInfoDetailData = { { sizeof(DriverInfoDetailData.s) } };
    123131    DWORD                    cbReqSize            = NULL;
    124132    if (   !SetupDiGetDriverInfoDetailW(hDevInfo, NULL, &drvInfoData,
     
    164172     * ...
    165173     */
    166     SP_DEVINFO_DATA deviceInfoData = { sizeof(SP_DEVINFO_DATA) };
     174    SP_DEVINFO_DATA deviceInfoData = { sizeof(deviceInfoData) };
    167175    /* Check for existing first. */
    168176    BOOL fDevInfoOkay = SetupDiOpenDeviceInfoW(hDevInfo, wszDevInstanceId, NULL, 0, &deviceInfoData);
     
    190198         * Redo the install parameter thing with deviceInfoData.
    191199         */
    192         SP_DEVINSTALL_PARAMS_W DeviceInstallParams = { sizeof(SP_DEVINSTALL_PARAMS) };
     200        SP_DEVINSTALL_PARAMS_W DeviceInstallParams = { sizeof(DeviceInstallParams) };
    193201        if (!SetupDiGetDeviceInstallParamsW(hDevInfo, &deviceInfoData, &DeviceInstallParams))
    194202            return ErrorMsgLastErr("SetupDiGetDeviceInstallParamsW(#2)"); /** @todo Original code didn't return here. */
    195203
    196         DeviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
     204        DeviceInstallParams.cbSize = sizeof(DeviceInstallParams);
    197205        DeviceInstallParams.Flags |= DI_NOFILECOPY      /* We did our own file copying */
    198206                                   | DI_DONOTCALLCONFIGMG
     
    212220
    213221        /*
    214          * Repeate the query at the start of the function.
    215          */
    216         drvInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
     222         * Repeat the query at the start of the function.
     223         */
     224        drvInfoData.cbSize = sizeof(drvInfoData);
    217225        if (!SetupDiEnumDriverInfoW(hDevInfo, &deviceInfoData, SPDIT_CLASSDRIVER, 0, &drvInfoData))
    218226            return ErrorMsgLastErr("SetupDiEnumDriverInfoW(#2)");
     
    343351 * @param   pwszDriverDir     The base directory where we find the INF.
    344352 */
    345 static RTEXITCODE InstallVideoDriver(WCHAR const * const pwszDriverDir)
     353static RTEXITCODE InstallNt4VideoDriver(WCHAR const * const pwszDriverDir)
    346354{
    347355    /*
     
    356364     */
    357365    RTEXITCODE rcExit = RTEXITCODE_FAILURE;
    358     SP_DEVINSTALL_PARAMS_W DeviceInstallParams = { sizeof(SP_DEVINSTALL_PARAMS) };
     366    SP_DEVINSTALL_PARAMS_W DeviceInstallParams = { sizeof(DeviceInstallParams) };
    359367    if (SetupDiGetDeviceInstallParamsW(hDevInfo, NULL, &DeviceInstallParams))
    360368    {
     
    362370         * Insert our install parameters and update hDevInfo with them.
    363371         */
    364         DeviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
     372        DeviceInstallParams.cbSize = sizeof(DeviceInstallParams);
    365373        DeviceInstallParams.Flags |= DI_NOFILECOPY /* We did our own file copying */
    366374                                   | DI_DONOTCALLCONFIGMG
     
    380388                {
    381389                    HINF hInf = NULL;
    382                     rcExit = InstallVideoDriverInner(pwszDriverDir, hDevInfo, &hInf);
     390                    rcExit = InstallNt4VideoDriverInner(pwszDriverDir, hDevInfo, &hInf);
    383391
    384392                    if (hInf)
     
    479487        if (cwcInstallDir > 0)
    480488        {
    481             while (cwcInstallDir > 0 && RTPATH_IS_SEP(wszInstallDir[cwcInstallDir - 1]))
     489            while (cwcInstallDir > 0 && !RTPATH_IS_SEP(wszInstallDir[cwcInstallDir - 1]))
    482490                cwcInstallDir--;
    483491            if (!cwcInstallDir) /* paranoia^3 */
     
    492500             */
    493501            if (fInstall)
    494                 rcExit = InstallVideoDriver(wszInstallDir);
     502                rcExit = InstallNt4VideoDriver(wszInstallDir);
    495503            else
    496504                rcExit = UninstallDrivers();
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