VirtualBox

Changeset 106839 in vbox


Ignore:
Timestamp:
Nov 5, 2024 5:22:30 PM (7 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165750
Message:

Windows driver installation: Made it a bit smarter wrt model / PnP ID detection within files. bugref:10762

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/GuestHost/VBoxWinDrvInst.h

    r106323 r106839  
    9595unsigned VBoxWinDrvInstSetVerbosity(VBOXWINDRVINST hDrvInst, uint8_t uVerbosity);
    9696void VBoxWinDrvInstSetLogCallback(VBOXWINDRVINST hDrvInst, PFNVBOXWINDRIVERLOGMSG pfnLog, void *pvUser);
    97 int VBoxWinDrvInstInstall(VBOXWINDRVINST hDrvInst, const char *pszInfFile, const char *pszPnpId, uint32_t fFlags);
     97int VBoxWinDrvInstInstallEx(VBOXWINDRVINST hDrvInst, const char *pszInfFile, const char *pszModel, const char *pszPnpId, uint32_t fFlags);
     98int VBoxWinDrvInstInstall(VBOXWINDRVINST hDrvInst, const char *pszInfFile, uint32_t fFlags);
    9899int VBoxWinDrvInstInstallExecuteInf(VBOXWINDRVINST hDrvInst, const char *pszInfFile, const char *pszSection, uint32_t fFlags);
    99100int VBoxWinDrvInstUninstall(VBOXWINDRVINST hDrvInst, const char *pszInfFile, const char *pszModel, const char *pszPnPId, uint32_t fFlags);
  • trunk/src/VBox/Additions/WINNT/Installer/VBoxDrvInst.cpp

    r106529 r106839  
    617617            if (RT_SUCCESS(rc))
    618618            {
    619                 rc = VBoxWinDrvInstInstall(hWinDrvInst, pszInfFile, pszPnpId,
    620                                            VBOX_WIN_DRIVERINSTALL_F_SILENT | VBOX_WIN_DRIVERINSTALL_F_FORCE);
     619                rc = VBoxWinDrvInstInstallEx(hWinDrvInst, pszInfFile, NULL /* pszModel */, pszPnpId,
     620                                             VBOX_WIN_DRIVERINSTALL_F_SILENT | VBOX_WIN_DRIVERINSTALL_F_FORCE);
    621621
    622622                VBoxWinDrvInstDestroy(hWinDrvInst);
  • trunk/src/VBox/GuestHost/installation/VBoxWinDrvCommon.cpp

    r106395 r106839  
    139139 *
    140140 * @returns VBox status code.
     141 * @retval  VERR_NOT_FOUND if no model has been found.
    141142 * @param   hInf                INF handle to use.
    142143 * @param   ppwszValue          Where to return the model name on success.
    143144 * @param   pcwcValue           Where to return the number of characters for \a ppwszValue. Optional an can be NULL.
     145 *
     146 * @note    Only for non-"primitive" drivers.
    144147 */
    145148int VBoxWinDrvInfQueryModelsSectionName(HINF hInf, PRTUTF16 *ppwszValue, PDWORD pcwcValue)
     
    152155    static PRTUTF16 s_apwszSections[] =
    153156    {
    154         /* The more specific (using decorations), the better. Try these first. */
    155         L"Manufacturer"     VBOXWINDRVINF_DOT_NT_NATIVE_ARCH_STR,
    156         L"DefaultInstall"   VBOXWINDRVINF_DOT_NT_NATIVE_ARCH_STR,
    157         L"DefaultUninstall" VBOXWINDRVINF_DOT_NT_NATIVE_ARCH_STR,
    158         /* Try undecorated sections last. */
     157        /* Most likely (and doesn't have a decoration). */
    159158        L"Manufacturer",
    160         L"DefaultInstall",
    161         L"DefaultUninstall"
     159        L"Manufacturer" VBOXWINDRVINF_DOT_NT_NATIVE_ARCH_STR,
     160        /* Note: Don't search for "DefaultInstall" or "DefaultUninstall" sections here, as
     161         *       those only are used for "primitive" drivers. */
    162162    };
    163163
     
    419419 *
    420420 * @returns VBox status code.
     421 * @retval  VERR_NOT_FOUND if no model has been found.
    421422 * @param   hInf                INF handle to use.
    422423 * @param   ppwszModel          Where to return the model on success.
    423424 *                              Needs to be free'd by RTUtf16Free().
     425 *
     426 * @note    Only for non-"primitive" drivers.
    424427 */
    425428int VBoxWinDrvInfQueryFirstModel(HINF hInf, PRTUTF16 *ppwszModel)
     
    434437 *
    435438 * @returns VBox status code.
     439 * @retval  VERR_NOT_FOUND if no PnP ID has been found.
    436440 * @param   hInf                INF handle to use.
    437441 * @param   pwszModel           Model to query PnP ID for.
    438442 * @param   ppwszPnPId          Where to return the PnP ID on success.
    439443 *                              Needs to be free'd by RTUtf16Free().
     444 *
     445 * @note    Only for non-"primitive" drivers.
    440446 */
    441447int VBoxWinDrvInfQueryFirstPnPId(HINF hInf, PRTUTF16 pwszModel, PRTUTF16 *ppwszPnPId)
    442448{
     449    if (!pwszModel) /* No model given? Bail out early. */
     450        return VERR_NOT_FOUND;
     451
    443452    *ppwszPnPId = NULL;
    444453
  • trunk/src/VBox/GuestHost/installation/VBoxWinDrvInst.cpp

    r106828 r106839  
    647647        case VBOXWINDRVINSTMODE_UNINSTALL:
    648648        {
     649            RTUtf16Free(pParms->u.UnInstall.pwszModel);
     650            pParms->u.UnInstall.pwszModel = NULL;
    649651            RTUtf16Free(pParms->u.UnInstall.pwszPnpId);
    650652            pParms->u.UnInstall.pwszPnpId = NULL;
     
    758760 * @param   pwszInfPathAbs      Absolute path of INF file to use for [un]installation.
    759761 * @param   pwszSection         Section to invoke for [un]installation.
     762 *                              If NULL, the "DefaultInstall" / "DefaultUninstall" section will be tried.
    760763 * @param   pfnCallback         Callback to invoke for each found section.
    761764 */
     
    763766                                   PFNVBOXWINDRVINST_TRYINFSECTION_CALLBACK pfnCallback)
    764767{
    765     vboxWinDrvInstLogVerbose(pCtx, 1, "Trying section \"%ls\"", pwszSection);
     768    if (pwszSection)
     769        vboxWinDrvInstLogVerbose(pCtx, 1, "Trying section \"%ls\"", pwszSection);
    766770
    767771    /* Sorted by most likely-ness. */
     
    812816                vboxWinDrvInstLogError(pCtx, "Trying INF section failed with %Rrc", rc);
    813817        }
     818
     819        if (RT_SUCCESS(rc)) /* Bail out if callback above succeeded. */
     820            break;
    814821    }
    815822
    816823    if (rc == VERR_NOT_FOUND)
    817824    {
    818         vboxWinDrvInstLogWarn(pCtx, "No matching section to try found -- buggy driver?");
     825        vboxWinDrvInstLogWarn(pCtx, "No matching sections to try found -- buggy driver?");
    819826        rc = VINF_SUCCESS;
    820827    }
     
    10581065static int vboxWinDrvInstallPerform(PVBOXWINDRVINSTINTERNAL pCtx, PVBOXWINDRVINSTPARMS pParms)
    10591066{
    1060     int rc = VINF_SUCCESS;
     1067    int rc = vboxWinDrvParmsDetermine(pCtx, pParms, false /* fForce */);
     1068    if (RT_FAILURE(rc))
     1069        return rc;
    10611070
    10621071    switch (pParms->enmMode)
     
    10761085             */
    10771086            DWORD dwInstallFlags = 0;
    1078             if (uNtVer >= RTSYSTEM_MAKE_NT_VERSION(6, 0, 0)) /* for Vista / 2008 Server and up. */
     1087            if (uNtVer >= RTSYSTEM_MAKE_NT_VERSION(66, 0, 0)) /* for Vista / 2008 Server and up. */
    10791088            {
    10801089                if (pParms->fFlags & VBOX_WIN_DRIVERINSTALL_F_FORCE)
     
    10841093
    10851094                fRc = g_pfnDiInstallDriverW(NULL /* hWndParent */, pParms->pwszInfFile, dwInstallFlags, &fReboot);
     1095                if (!fRc)
     1096                {
     1097                    DWORD const dwErr = GetLastError();
     1098
     1099                    /*
     1100                     * Work around an error code wich only appears on old(er) Windows Server editions (e.g. 2012 R2 or 2016)
     1101                     * where SetupAPI tells "unable to mark devices that match new inf", which ultimately results in
     1102                     * ERROR_LINE_NOT_FOUND. This probably is because of primitive drivers which don't have a PnP ID set in
     1103                     * the INF file.
     1104                     *
     1105                     * pnputil.exe also gives the same error in the SetupAPI log when handling the very same INF file.
     1106                     *
     1107                     * So skip this error and pretend everything is fine. */
     1108                    if (dwErr == ERROR_LINE_NOT_FOUND)
     1109                        fRc = true;
     1110
     1111                    if (!fRc)
     1112                        rc = vboxWinDrvInstLogLastError(pCtx, "DiInstallDriverW() failed");
     1113                }
     1114
    10861115                if (fRc)
    10871116                {
    1088                     rc = vboxWinDrvParmsDetermine(pCtx, pParms, true /* fForce */);
    1089                     if (RT_SUCCESS(rc))
    1090                         /* rc ignored, keep going */ vboxWinDrvTryInfSection(pCtx,
    1091                                                                              pParms->pwszInfFile, pParms->u.UnInstall.pwszModel,
    1092                                                                              vboxWinDrvInstallTryInfSectionCallback);
     1117                    rc = vboxWinDrvTryInfSection(pCtx,
     1118                                                 pParms->pwszInfFile, pParms->u.UnInstall.pwszModel,
     1119                                                 vboxWinDrvInstallTryInfSectionCallback);
    10931120                }
    1094                 else
    1095                     rc = vboxWinDrvInstLogLastError(pCtx, "DiInstallDriverW() failed");
    10961121            }
    10971122            else /* For Windows 2000 and below. */
    10981123            {
    1099                 /* If no PnP ID (Hardware ID) is explicitly given, try guessing the PnP ID from the given INF file. */
    1100                 size_t cchPnpId = RTUtf16Len(pParms->u.UnInstall.pwszPnpId);
    1101                 if (   !cchPnpId
    1102                     || cchPnpId > MAX_DEVICE_ID_LEN)
    1103                 {
    1104                     vboxWinDrvInstLogInfo(pCtx, "PnP ID not specified explicitly or invalid, determining from given INF file");
    1105                     rc = vboxWinDrvParmsDetermine(pCtx, pParms, true /* fForce */);
    1106                     if (RT_SUCCESS(rc))
    1107                         cchPnpId = RTUtf16Len(pParms->u.UnInstall.pwszPnpId);
    1108                 }
    1109 
    1110                 if (RT_FAILURE(rc))
    1111                     break;
    1112 
    1113                 /* Still not having any PnP ID? */
    1114                 if (cchPnpId == 0)
    1115                 {
    1116                     vboxWinDrvInstLogError(pCtx, "No (valid) PnP ID found; can't continue");
    1117                     rc = VERR_NOT_FOUND;
    1118                     break;
    1119                 }
    1120                 else
     1124                bool fPreInstall     = false; /* Whether to pre-install the driver. */
     1125                bool fInstallSection = false; /* Whether to install the section of the specified driver model. */
     1126
     1127                if (pParms->u.UnInstall.pwszPnpId)
    11211128                {
    11221129                    if (pParms->fFlags & VBOX_WIN_DRIVERINSTALL_F_SILENT)
     
    11471154                                vboxWinDrvInstLogInfo(pCtx, "Device (\"%ls\") not found (yet), pre-installing driver ...",
    11481155                                                      pParms->u.UnInstall.pwszPnpId);
    1149 
    1150                                 RTUTF16 wszInfFileAbs[RTPATH_MAX] = { 0 };
    1151                                 LPWSTR  pwszInfFile = NULL;
    1152                                 if (   GetFullPathNameW(pParms->pwszInfFile, RT_ELEMENTS(wszInfFileAbs), wszInfFileAbs, &pwszInfFile)
    1153                                     && pwszInfFile)
    1154                                 {
    1155                                     RTUTF16 wszSrcPathAbs[RTPATH_MAX] = { 0 };
    1156                                     rc = RTUtf16CopyEx(wszSrcPathAbs, RT_ELEMENTS(wszSrcPathAbs), wszInfFileAbs,
    1157                                                        RTUtf16Len(wszInfFileAbs) - RTUtf16Len(pwszInfFile));
    1158                                     if (RT_SUCCESS(rc))
    1159                                     {
    1160                                         RTUTF16 wszDstPathAbs[RTPATH_MAX] = { 0 };
    1161                                         fRc = g_pfnSetupCopyOEMInfW(wszInfFileAbs, wszSrcPathAbs, SPOST_PATH, 0,
    1162                                                                     wszDstPathAbs, RT_ELEMENTS(wszDstPathAbs), NULL, NULL);
    1163 
    1164                                         vboxWinDrvInstLogVerbose(pCtx, 1, "   INF file: %ls", wszInfFileAbs);
    1165                                         vboxWinDrvInstLogVerbose(pCtx, 1, "Source path: %ls", wszSrcPathAbs);
    1166                                         vboxWinDrvInstLogVerbose(pCtx, 1, "  Dest path: %ls", wszDstPathAbs);
    1167 
    1168                                         if (fRc)
    1169                                             vboxWinDrvInstLogInfo(pCtx, "Copying OEM INF successful");
    1170                                         else
    1171                                             rc = vboxWinDrvInstLogLastError(pCtx, "Installation(SetupCopyOEMInfW) failed");
    1172                                     }
    1173                                 }
    1174                                 else
    1175                                     rc = vboxWinDrvInstLogLastError(pCtx, "GetFullPathNameW() failed");
     1156                                fPreInstall = true;
    11761157                                break;
    11771158                            }
     
    11791160                            case ERROR_NO_DRIVER_SELECTED:
    11801161                            {
    1181                                 rc = vboxWinDrvParmsDetermine(pCtx, pParms, true /* fForce */);
    1182                                 if (RT_SUCCESS(rc))
    1183                                 {
    1184                                     if (pParms->u.UnInstall.pwszModel)
    1185                                         rc = vboxWinDrvInstallInfSectionEx(pCtx, pCtx->Parms.pwszInfFile,
    1186                                                                            pParms->u.UnInstall.pwszModel);
    1187                                 }
     1162                                vboxWinDrvInstLogWarn(pCtx, "Not able to select a driver from the given INF, using given model");
     1163                                fInstallSection = true;
    11881164                                break;
    11891165                            }
     
    11951171                    }
    11961172                }
     1173                else
     1174                {
     1175                    fPreInstall     = true;
     1176                    fInstallSection = true;
     1177                }
     1178
     1179                if (fPreInstall)
     1180                {
     1181                    RTUTF16 wszInfFileAbs[RTPATH_MAX] = { 0 };
     1182                    LPWSTR  pwszInfFile = NULL;
     1183                    if (   GetFullPathNameW(pParms->pwszInfFile, RT_ELEMENTS(wszInfFileAbs), wszInfFileAbs, &pwszInfFile)
     1184                        && pwszInfFile)
     1185                    {
     1186                        RTUTF16 wszSrcPathAbs[RTPATH_MAX] = { 0 };
     1187                        rc = RTUtf16CopyEx(wszSrcPathAbs, RT_ELEMENTS(wszSrcPathAbs), wszInfFileAbs,
     1188                                           RTUtf16Len(wszInfFileAbs) - RTUtf16Len(pwszInfFile));
     1189                        if (RT_SUCCESS(rc))
     1190                        {
     1191                            RTUTF16 wszDstPathAbs[RTPATH_MAX] = { 0 };
     1192                            fRc = g_pfnSetupCopyOEMInfW(wszInfFileAbs, wszSrcPathAbs, SPOST_PATH, 0,
     1193                                                        wszDstPathAbs, RT_ELEMENTS(wszDstPathAbs), NULL, NULL);
     1194
     1195                            vboxWinDrvInstLogVerbose(pCtx, 1, "   INF file: %ls", wszInfFileAbs);
     1196                            vboxWinDrvInstLogVerbose(pCtx, 1, "Source path: %ls", wszSrcPathAbs);
     1197                            vboxWinDrvInstLogVerbose(pCtx, 1, "  Dest path: %ls", wszDstPathAbs);
     1198
     1199                            if (fRc)
     1200                                vboxWinDrvInstLogInfo(pCtx, "Copying OEM INF successful");
     1201                            else
     1202                                rc = vboxWinDrvInstLogLastError(pCtx, "Installation(SetupCopyOEMInfW) failed");
     1203                        }
     1204                    }
     1205                    else
     1206                        rc = vboxWinDrvInstLogLastError(pCtx, "GetFullPathNameW() failed");
     1207                }
     1208
     1209                if (fInstallSection)
     1210                {
     1211                    rc = vboxWinDrvTryInfSection(pCtx,
     1212                                                 pParms->pwszInfFile, pParms->u.UnInstall.pwszModel,
     1213                                                 vboxWinDrvInstallTryInfSectionCallback);
     1214                }
    11971215            }
    11981216
     
    12181236
    12191237/**
     1238 * Returns whether the given (in)installation parameters are valid or not.
     1239 *
     1240 * @returns \c true if valid, \c false if not.
     1241 * @param   pCtx                Windows driver installer context.
     1242 * @param   pParms              Windows driver (un)installation parameters to validate.
     1243 */
     1244static bool vboxWinDrvParmsAreValid(PVBOXWINDRVINSTINTERNAL pCtx, PVBOXWINDRVINSTPARMS pParms)
     1245{
     1246    if (pParms->u.UnInstall.pwszPnpId)
     1247    {
     1248        size_t const cchPnpId = RTUtf16Len(pParms->u.UnInstall.pwszPnpId);
     1249        if (   !cchPnpId
     1250            || cchPnpId > MAX_DEVICE_ID_LEN)
     1251        {
     1252            vboxWinDrvInstLogVerbose(pCtx, 1, "PnP ID not specified explicitly or invalid");
     1253            return false;
     1254        }
     1255    }
     1256
     1257    return true;
     1258}
     1259
     1260/**
    12201261 * Determines (un)installation parameters from a given set of parameters, logged.
    12211262 *
     
    12251266 * @param   pParms              Windows driver installation parameters to determine for.
    12261267 * @param   fForce              Whether to overwrite already set parameters or not.
     1268 *
     1269 * @note    Only can deal with the first model / PnP ID found for now.
    12271270 */
    12281271static int vboxWinDrvParmsDetermine(PVBOXWINDRVINSTINTERNAL pCtx, PVBOXWINDRVINSTPARMS pParms, bool fForce)
     
    12401283            if (!pParms->u.UnInstall.pwszModel || fForce)
    12411284            {
    1242                 vboxWinDrvInstLogVerbose(pCtx, 1, "Determining first model ...");
    1243                 VBoxWinDrvInfQueryFirstModel(hInf, &pParms->u.UnInstall.pwszModel);
     1285                vboxWinDrvInstLogVerbose(pCtx, 1, "Determining model ...");
     1286                if (fForce)
     1287                {
     1288                    RTUtf16Free(pParms->u.UnInstall.pwszModel);
     1289                    pParms->u.UnInstall.pwszModel = NULL;
     1290                }
     1291                rc = VBoxWinDrvInfQueryFirstModel(hInf, &pParms->u.UnInstall.pwszModel);
     1292                if (rc == VERR_NOT_FOUND)
     1293                {
     1294                    vboxWinDrvInstLogVerbose(pCtx, 1, "No model found, probably a primitive driver");
     1295                    rc = VINF_SUCCESS; /* Reset rc, non-fatal. */
     1296                }
    12441297            }
    12451298            if (!pParms->u.UnInstall.pwszPnpId  || fForce)
    12461299            {
    1247                 vboxWinDrvInstLogVerbose(pCtx, 1, "Determining first PnP ID ...");
    1248                 VBoxWinDrvInfQueryFirstPnPId(hInf,
    1249                                              pParms->u.UnInstall.pwszModel, &pParms->u.UnInstall.pwszPnpId);
     1300                if (pParms->u.UnInstall.pwszModel)
     1301                {
     1302                    vboxWinDrvInstLogVerbose(pCtx, 1, "Determining PnP ID ...");
     1303                    if (fForce)
     1304                    {
     1305                        RTUtf16Free(pParms->u.UnInstall.pwszPnpId);
     1306                        pParms->u.UnInstall.pwszPnpId = NULL;
     1307                    }
     1308                    /* ignore rc */ VBoxWinDrvInfQueryFirstPnPId(hInf,
     1309                                                                 pParms->u.UnInstall.pwszModel, &pParms->u.UnInstall.pwszPnpId);
     1310                }
     1311                else
     1312                    vboxWinDrvInstLogVerbose(pCtx, 1, "No first model found/set, skipping determining PnP ID");
    12501313            }
    12511314            VBoxWinDrvInfClose(hInf);
     
    12581321             || pParms->u.UnInstall.pwszPnpId)
    12591322    {
     1323        /* Nothing to do for us here. */
    12601324        rc = VINF_SUCCESS;
    12611325    }
     
    14391503            {
    14401504                rc = vboxWinDrvUninstallFromDriverStore(pCtx, pParms, pList);
    1441                 if (RT_SUCCESS(rc))
    1442                 {
    1443 
    1444                 }
    14451505
    14461506                VBoxWinDrvStoreListFree(pList);
     
    14941554    }
    14951555
     1556    if (!vboxWinDrvParmsAreValid(pCtx, pParms))
     1557    {
     1558        vboxWinDrvInstLogError(pCtx, "%s parameters are invalid, can't continue", fInstall ? "Installation" : "Uninstallation");
     1559        return VERR_INVALID_PARAMETER;
     1560    }
     1561
    14961562    int rc;
    14971563    if (fInstall)
     
    15101576        }
    15111577    }
    1512     else
    1513         vboxWinDrvInstLogError(pCtx, "Unable to %sinstall driver, rc=%Rrc", fInstall ? "" : "un", rc);
     1578
     1579    /* Note: Call vboxWinDrvInstLogEx() to not increase the error/warn count here. */
     1580    if (pCtx->cErrors)
     1581        vboxWinDrvInstLogEx(pCtx, VBOXWINDRIVERLOGTYPE_ERROR, "%sstalling driver(s) failed with %u errors, %u warnings (rc=%Rrc)",
     1582                            fInstall ? "In" : "Unin", pCtx->cErrors, pCtx->cWarnings, rc);
     1583    else if (pCtx->cWarnings)
     1584        vboxWinDrvInstLogEx(pCtx, VBOXWINDRIVERLOGTYPE_WARN, "%sstalling driver(s) succeeded with %u warnings",
     1585                            fInstall ? "In" : "Unin", pCtx->cWarnings);
    15141586
    15151587    return rc;
     
    16651737
    16661738/**
    1667  * Installs a driver.
     1739 * Installs a driver, extended version.
    16681740 *
    16691741 * @returns VBox status code.
    16701742 * @param   hDrvInst            Windows driver installer handle to use.
    16711743 * @param   pszInfFile          INF file to use.
     1744 * @param   pszModel            Model name to use. Optional and can be NULL.
    16721745 * @param   pszPnpId            PnP ID to use. NT-style wildcards supported. Optional and can be NULL.
    16731746 * @param   fFlags              Installation flags (of type VBOX_WIN_DRIVERINSTALL_F_XXX) to use.
    16741747 */
    1675 int VBoxWinDrvInstInstall(VBOXWINDRVINST hDrvInst, const char *pszInfFile, const char *pszPnpId, uint32_t fFlags)
     1748int VBoxWinDrvInstInstallEx(VBOXWINDRVINST hDrvInst,
     1749                            const char *pszInfFile, const char *pszModel, const char *pszPnpId, uint32_t fFlags)
    16761750{
    16771751    PVBOXWINDRVINSTINTERNAL pCtx = hDrvInst;
     
    16911765        vboxWinDrvInstLogError(pCtx, "Failed to build path for INF file \"%s\", rc=%Rrc", pszInfFile, rc);
    16921766
    1693     if (RT_SUCCESS(rc) && pszPnpId) /* PnP ID is optional. */
     1767    if (RT_SUCCESS(rc) && pszModel) /* Model is optional. */
     1768        rc = RTStrToUtf16(pszModel, &pCtx->Parms.u.UnInstall.pwszModel);
     1769    if (RT_SUCCESS(rc) && pszPnpId) /* Ditto. */
    16941770        rc = RTStrToUtf16(pszPnpId, &pCtx->Parms.u.UnInstall.pwszPnpId);
    16951771
     
    17081784
    17091785    return rc;
     1786}
     1787
     1788/**
     1789 * Installs a driver.
     1790 *
     1791 * @returns VBox status code.
     1792 * @param   hDrvInst            Windows driver installer handle to use.
     1793 * @param   pszInfFile          INF file to use.
     1794 * @param   fFlags              Installation flags (of type VBOX_WIN_DRIVERINSTALL_F_XXX) to use.
     1795 *
     1796 * @note    This function tries determining the model / PnP ID from the given INF file.
     1797 *          To control the behavior exactly, use VBoxWinDrvInstInstallEx().
     1798 */
     1799int VBoxWinDrvInstInstall(VBOXWINDRVINST hDrvInst, const char *pszInfFile, uint32_t fFlags)
     1800{
     1801    return VBoxWinDrvInstInstallEx(hDrvInst, pszInfFile, NULL /* pszModel */, NULL /* pszPnpId */, fFlags);
    17101802}
    17111803
  • trunk/src/VBox/Installer/win/InstallHelper/VBoxInstallHelper.cpp

    r106822 r106839  
    14721472            || rc == VERR_NOT_FOUND) /* VBoxDrvInstInfSection is optional. */
    14731473        {
    1474             char *pszPnpId = NULL;
    1475             rc = VBoxMsiQueryPropUtf8(hModule, "VBoxDrvInstPnpId", &pszPnpId);
     1474            char *pszModel = NULL;
     1475            rc = VBoxMsiQueryPropUtf8(hModule, "VBoxDrvInstModel", &pszModel);
    14761476            if (   RT_SUCCESS(rc)
    1477                 || rc == VERR_NOT_FOUND) /* VBoxDrvInstHwId is optional. */
    1478             {
    1479                 uint32_t fFlags = VBOX_WIN_DRIVERINSTALL_F_NONE;
    1480 
    1481                 DWORD dwVal;
    1482                 rc = VBoxMsiQueryPropInt32(hModule, "VBoxDrvInstFlagForce", &dwVal);
    1483                 if (RT_SUCCESS(rc))
    1484                     fFlags |= VBOX_WIN_DRIVERINSTALL_F_FORCE;
    1485                 rc = VBoxMsiQueryPropInt32(hModule, "VBoxDrvInstFlagSilent", &dwVal);
    1486                 if (RT_SUCCESS(rc))
    1487                     fFlags |= VBOX_WIN_DRIVERINSTALL_F_SILENT;
    1488 
    1489                 VBOXWINDRVINST hWinDrvInst;
    1490                 rc = VBoxWinDrvInstCreateEx(&hWinDrvInst, 1 /* uVerbostiy */, &vboxWinDrvInstLogCallback, &hModule /* pvUser */);
    1491                 if (RT_SUCCESS(rc))
     1477                || rc == VERR_NOT_FOUND) /* VBoxDrvInstModel is optional. */
     1478            {
     1479                char *pszPnpId = NULL;
     1480                rc = VBoxMsiQueryPropUtf8(hModule, "VBoxDrvInstPnpId", &pszPnpId);
     1481                if (   RT_SUCCESS(rc)
     1482                    || rc == VERR_NOT_FOUND) /* VBoxDrvInstPnpId is optional. */
    14921483                {
    1493                     if (pszInfSection && *pszInfSection)
    1494                         rc = VBoxWinDrvInstInstallExecuteInf(hWinDrvInst, pszInfFile, pszInfSection, fFlags);
    1495                     else
    1496                         rc = VBoxWinDrvInstInstall(hWinDrvInst, pszInfFile, pszPnpId, fFlags);
    1497 
    1498                     VBoxWinDrvInstDestroy(hWinDrvInst);
     1484                    uint32_t fFlags = VBOX_WIN_DRIVERINSTALL_F_NONE;
     1485
     1486                    DWORD dwVal;
     1487                    rc = VBoxMsiQueryPropInt32(hModule, "VBoxDrvInstFlagForce", &dwVal);
     1488                    if (RT_SUCCESS(rc))
     1489                        fFlags |= VBOX_WIN_DRIVERINSTALL_F_FORCE;
     1490                    rc = VBoxMsiQueryPropInt32(hModule, "VBoxDrvInstFlagSilent", &dwVal);
     1491                    if (RT_SUCCESS(rc))
     1492                        fFlags |= VBOX_WIN_DRIVERINSTALL_F_SILENT;
     1493
     1494                    VBOXWINDRVINST hWinDrvInst;
     1495                    rc = VBoxWinDrvInstCreateEx(&hWinDrvInst, 1 /* uVerbostiy */, &vboxWinDrvInstLogCallback, &hModule /* pvUser */);
     1496                    if (RT_SUCCESS(rc))
     1497                    {
     1498                        if (pszInfSection && *pszInfSection)
     1499                            rc = VBoxWinDrvInstInstallExecuteInf(hWinDrvInst, pszInfFile, pszInfSection, fFlags);
     1500                        else
     1501                            rc = VBoxWinDrvInstInstallEx(hWinDrvInst, pszInfFile, pszModel, pszPnpId, fFlags);
     1502
     1503                        VBoxWinDrvInstDestroy(hWinDrvInst);
     1504                    }
     1505
     1506                    RTStrFree(pszPnpId);
    14991507                }
    15001508
    1501                 RTStrFree(pszPnpId);
     1509                RTStrFree(pszModel);
    15021510            }
    15031511
Note: See TracChangeset for help on using the changeset viewer.

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