Changeset 106868 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Nov 7, 2024 9:30:45 AM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/installation/VBoxWinDrvInst.cpp
r106867 r106868 118 118 119 119 /** Function pointer for a general try INF section callback. */ 120 typedef int (*PFNVBOXWINDRVINST_TRYINFSECTION_CALLBACK)( PCRTUTF16 pwszInfPathAbs, PCRTUTF16 pwszSection, void *pvCtx);120 typedef int (*PFNVBOXWINDRVINST_TRYINFSECTION_CALLBACK)(HINF hInf, PCRTUTF16 pwszSection, void *pvCtx); 121 121 122 122 … … 704 704 /** Pointer to driver installer instance. */ 705 705 PVBOXWINDRVINSTINTERNAL pThis; 706 /** Weak pointer to INF file being handled. */707 PCRTUTF16 pwszInfFile;708 706 /** Weak pointer to INF section being handled. */ 709 707 PCRTUTF16 pwszSection; … … 781 779 * @returns VBox status code. 782 780 * @param pCtx Windows driver installer context. 783 * @param pwszInfPathAbs Absolute path of INF file to use for [un]installation.781 * @param hInf Handle of INF file. 784 782 * @param pwszSection Section to invoke for [un]installation. 785 783 * If NULL, the "DefaultInstall" / "DefaultUninstall" section will be tried. 786 784 * @param pfnCallback Callback to invoke for each found section. 787 785 */ 788 static int vboxWinDrvTryInfSection (PVBOXWINDRVINSTINTERNAL pCtx, PCRTUTF16 pwszInfPathAbs, PCRTUTF16 pwszSection,789 PFNVBOXWINDRVINST_TRYINFSECTION_CALLBACK pfnCallback)786 static int vboxWinDrvTryInfSectionEx(PVBOXWINDRVINSTINTERNAL pCtx, HINF hInf, PCRTUTF16 pwszSection, 787 PFNVBOXWINDRVINST_TRYINFSECTION_CALLBACK pfnCallback) 790 788 { 791 789 if (pwszSection) … … 810 808 }; 811 809 812 int rc = V INF_SUCCESS; /* Shut up MSVC. */810 int rc = VERR_NOT_FOUND; 813 811 814 812 for (size_t i = 0; i < RT_ELEMENTS(apwszTryInstallSections); i++) … … 826 824 AssertRCBreak(rc); 827 825 828 rc = pfnCallback( pwszInfPathAbs, wszTrySection, pCtx /* pvCtx */);826 rc = pfnCallback(hInf, wszTrySection, pCtx /* pvCtx */); 829 827 if (RT_SUCCESS(rc)) 830 828 break; … … 854 852 855 853 /** 854 * Generic function to for probing a list of well-known sections for [un]installation. 855 * 856 * Due to the nature of INF files this function tries different combinations of decorations (e.g. SectionName[.NTAMD64|.X86]) 857 * and invokes the given callback for the first found section. 858 * 859 * @returns VBox status code. 860 * @param pCtx Windows driver installer context. 861 * @param pwszInfPathAbs Absolute path of INF file to use for [un]installation. 862 * @param pwszSection Section to invoke for [un]installation. 863 * If NULL, the "DefaultInstall" / "DefaultUninstall" section will be tried. 864 * @param pfnCallback Callback to invoke for each found section. 865 */ 866 static int vboxWinDrvTryInfSection(PVBOXWINDRVINSTINTERNAL pCtx, PCRTUTF16 pwszInfPathAbs, PCRTUTF16 pwszSection, 867 PFNVBOXWINDRVINST_TRYINFSECTION_CALLBACK pfnCallback) 868 { 869 HINF hInf; 870 int rc = VBoxWinDrvInfOpen(pwszInfPathAbs, &hInf); 871 if (RT_FAILURE(rc)) 872 { 873 vboxWinDrvInstLogError(pCtx, "Unable to open INF file: %Rrc\n", rc); 874 return rc; 875 } 876 vboxWinDrvInstLogVerbose(pCtx, 1, "INF file \"%ls\" opened", pwszInfPathAbs); 877 878 rc = vboxWinDrvTryInfSectionEx(pCtx, hInf, pwszSection, pfnCallback); 879 880 VBoxWinDrvInfClose(hInf); 881 vboxWinDrvInstLogVerbose(pCtx, 1, "INF file \"%ls\" closed", pwszInfPathAbs); 882 883 return rc; 884 } 885 886 /** 856 887 * Uninstalls a section of a given INF file. 857 888 * … … 859 890 * @retval VERR_NOT_FOUND if the given section has not been found. 860 891 * @param pCtx Windows driver installer context. 861 * @param pwszInfFile INF file to execute.892 * @param hInf Handle of INF file. 862 893 * @param pwszSection Section within INF file to uninstall. 863 894 * Can have a platform decoration (e.g. "Foobar.NTx86"). 864 895 */ 865 static int vboxWinDrvUninstallInfSectionEx(PVBOXWINDRVINSTINTERNAL pCtx, PCRTUTF16 pwszInfFile, PCRTUTF16 pwszSection) 866 { 867 AssertPtrReturn(pwszInfFile, VERR_INVALID_POINTER); 896 static int vboxWinDrvUninstallInfSectionEx(PVBOXWINDRVINSTINTERNAL pCtx, HINF hInf, PCRTUTF16 pwszSection) 897 { 868 898 AssertPtrReturn(pwszSection, VERR_INVALID_POINTER); 869 899 900 int rc = VINF_SUCCESS; 901 870 902 vboxWinDrvInstLogInfo(pCtx, "Uninstalling INF section \"%ls\" ...", pwszSection); 871 872 HINF hInf;873 int rc = VBoxWinDrvInfOpen(pwszInfFile, &hInf);874 if (RT_FAILURE(rc))875 {876 if (rc == VERR_FILE_NOT_FOUND)877 vboxWinDrvInstLogVerbose(pCtx, 1, "INF file not found anymore, skipping");878 else879 vboxWinDrvInstLogError(pCtx, "Unable to open INF file: %Rrc", rc);880 return rc;881 }882 883 vboxWinDrvInstLogVerbose(pCtx, 1, "INF file \"%ls\" successfully opened", pwszInfFile);884 903 885 904 /* … … 926 945 } 927 946 928 VBoxWinDrvInfClose(hInf);929 930 vboxWinDrvInstLogVerbose(pCtx, 1, "INF file \"%ls\" closed", pwszInfFile);931 932 947 return rc; 933 948 } … … 939 954 * @retval VERR_NOT_FOUND if the given section has not been found. 940 955 * @param pCtx Windows driver installer context. 941 * @param pwszInfFile INF file to execute.956 * @param hInf Handle of INF file. 942 957 * @param pwszSection Section within INF file to install. 943 958 * Can have a platform decoration (e.g. "Foobar.NTx86"). 944 959 */ 945 static int vboxWinDrvInstallInfSectionEx(PVBOXWINDRVINSTINTERNAL pCtx, PCRTUTF16 pwszInfFile, PCRTUTF16 pwszSection) 946 { 947 AssertPtrReturn(pwszInfFile, VERR_INVALID_POINTER); 960 static int vboxWinDrvInstallInfSectionEx(PVBOXWINDRVINSTINTERNAL pCtx, HINF hInf, PCRTUTF16 pwszSection) 961 { 948 962 AssertPtrReturn(pwszSection, VERR_INVALID_POINTER); 949 963 964 int rc = VINF_SUCCESS; 965 950 966 vboxWinDrvInstLogInfo(pCtx, "Installing INF section \"%ls\" ...", pwszSection); 951 952 HINF hInf;953 int rc = VBoxWinDrvInfOpen(pwszInfFile, &hInf);954 if (RT_FAILURE(rc))955 {956 vboxWinDrvInstLogError(pCtx, "Unable to open INF file: %Rrc\n", rc);957 return rc;958 }959 960 vboxWinDrvInstLogVerbose(pCtx, 1, "INF file \"%ls\" successfully opened", pwszInfFile);961 967 962 968 VBOXDRVINSTINFCALLBACKCTX CallbackCtx; 963 969 RT_ZERO(CallbackCtx); 964 970 CallbackCtx.pThis = pCtx; 965 CallbackCtx.pwszInfFile = pwszInfFile;966 971 CallbackCtx.pwszSection = pwszSection; 967 972 CallbackCtx.pvSetupContext = SetupInitDefaultQueueCallback(NULL); … … 1039 1044 } 1040 1045 1041 VBoxWinDrvInfClose(hInf);1042 1043 vboxWinDrvInstLogVerbose(pCtx, 1, "INF file \"%ls\" closed", pwszInfFile);1044 1045 1046 return rc; 1046 1047 } … … 1061 1062 || pParms->enmMode == VBOXWINDRVINSTMODE_UNINSTALL_INFSECTION, VERR_INVALID_PARAMETER); 1062 1063 1063 return vboxWinDrvInstallInfSectionEx(pCtx, pParms->pwszInfFile, pParms->u.ExecuteInf.pwszSection); 1064 HINF hInf; 1065 int rc = VBoxWinDrvInfOpen(pParms->pwszInfFile, &hInf); 1066 if (RT_FAILURE(rc)) 1067 { 1068 vboxWinDrvInstLogError(pCtx, "Unable to open INF file: %Rrc\n", rc); 1069 return rc; 1070 } 1071 1072 vboxWinDrvInstLogVerbose(pCtx, 1, "INF file \"%ls\" opened", pParms->pwszInfFile); 1073 1074 rc = vboxWinDrvInstallInfSectionEx(pCtx, hInf, pParms->u.ExecuteInf.pwszSection); 1075 1076 VBoxWinDrvInfClose(hInf); 1077 vboxWinDrvInstLogVerbose(pCtx, 1, "INF file \"%ls\" closed", pParms->pwszInfFile); 1078 1079 return rc; 1064 1080 } 1065 1081 … … 1068 1084 * 1069 1085 * @returns VBox status code. 1070 * @param pwszInfPathAbs Absolute pathof INF file to use.1086 * @param hInf Handle of INF file to use. 1071 1087 * @param pwszSection Section to invoke. 1072 1088 * @param pvCtx User-supplied pointer. Usually PVBOXWINDRVINSTINTERNAL. 1073 1089 */ 1074 DECLCALLBACK(int) vboxWinDrvInstallTryInfSectionCallback( PCRTUTF16 pwszInfPathAbs, PCRTUTF16 pwszSection, void *pvCtx)1090 DECLCALLBACK(int) vboxWinDrvInstallTryInfSectionCallback(HINF hInf, PCRTUTF16 pwszSection, void *pvCtx) 1075 1091 { 1076 1092 PVBOXWINDRVINSTINTERNAL pCtx = (PVBOXWINDRVINSTINTERNAL)pvCtx; 1077 1093 1078 return vboxWinDrvInstallInfSectionEx(pCtx, pwszInfPathAbs, pwszSection);1094 return vboxWinDrvInstallInfSectionEx(pCtx, hInf, pwszSection); 1079 1095 } 1080 1096 … … 1417 1433 * 1418 1434 * @returns VBox status code. 1419 * @param pwszInfPathAbs Absolute path of INF file to use.1435 * @param hInf Handle to INF file. 1420 1436 * @param pwszSection Section to invoke. 1421 1437 * @param pvCtx User-supplied pointer. Usually PVBOXWINDRVINSTINTERNAL. 1422 1438 */ 1423 DECLCALLBACK(int) vboxWinDrvUninstallTryInfSectionCallback( PCRTUTF16 pwszInfPathAbs, PCRTUTF16 pwszSection, void *pvCtx)1439 DECLCALLBACK(int) vboxWinDrvUninstallTryInfSectionCallback(HINF hInf, PCRTUTF16 pwszSection, void *pvCtx) 1424 1440 { 1425 1441 PVBOXWINDRVINSTINTERNAL pCtx = (PVBOXWINDRVINSTINTERNAL)pvCtx; 1426 1442 1427 return vboxWinDrvUninstallInfSectionEx(pCtx, pwszInfPathAbs, pwszSection);1443 return vboxWinDrvUninstallInfSectionEx(pCtx, hInf, pwszSection); 1428 1444 } 1429 1445
Note:
See TracChangeset
for help on using the changeset viewer.