Changeset 40993 in vbox
- Timestamp:
- Apr 19, 2012 2:25:38 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxDrvCfg-win.h
r37479 r40993 70 70 VBOXDRVCFG_DECL(HRESULT) VBoxDrvCfgSvcStart(LPCWSTR lpszSvcName); 71 71 72 HRESULT VBoxDrvCfgDrvUpdate(LPCWSTR pcszwHwId, LPCWSTR pcsxwInf, BOOL *pbRebootRequired); 73 72 74 RT_C_DECLS_END 73 75 -
trunk/include/VBox/VBoxNetCfg-win.h
r38792 r40993 69 69 OUT GUID *pGuid, OUT BSTR *lppszName, 70 70 OUT BSTR *pErrMsg); 71 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinUpdateHostOnlyNetworkInterface(LPCWSTR pcsxwInf, BOOL *pbRebootRequired); 71 72 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRemoveHostOnlyNetworkInterface(IN const GUID *pGUID, OUT BSTR *pErrMsg); 72 73 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRemoveAllNetDevicesOfId(IN LPCWSTR lpszPnPId); 74 75 typedef enum 76 { 77 VBOXNECTFGWINPROPCHANGE_TYPE_UNDEFINED = 0, 78 VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE, 79 VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE 80 } VBOXNECTFGWINPROPCHANGE_TYPE; 81 82 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinPropChangeAllNetDevicesOfId(IN LPCWSTR lpszPnPId, VBOXNECTFGWINPROPCHANGE_TYPE enmPcType); 73 83 74 84 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGenHostOnlyNetworkNetworkIp(OUT PULONG pNetIp, OUT PULONG pNetMask); -
trunk/src/VBox/Devices/Makefile.kmk
r40888 r40993 87 87 $(PATH_STAGE_LIB)/USBLib$(VBOX_SUFF_LIB) 88 88 VBoxDDU_LIBS.win += \ 89 $(PATH_STAGE_LIB)/VBoxDrvCfg$(VBOX_SUFF_LIB) 89 $(PATH_STAGE_LIB)/VBoxDrvCfg$(VBOX_SUFF_LIB) \ 90 $(PATH_SDK_W2K3DDK_LIB)/Newdev.lib 90 91 endif 91 92 ifeq ($(KBUILD_TARGET),l4) -
trunk/src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk
r39333 r40993 160 160 $(WinNetConfig_1_TARGET) \ 161 161 $(VBoxDrvCfg_1_TARGET) \ 162 $(PATH_SDK_W2K3DDK_LIB)/Newdev.lib \ 162 163 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \ 163 164 $(PATH_SDK_WINPSDK_LIB)/WbemUuid.Lib … … 174 175 $(WinNetConfig_1_TARGET) \ 175 176 $(VBoxDrvCfg_1_TARGET) \ 177 $(PATH_SDK_W2K3DDK_LIB)/Newdev.lib \ 176 178 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \ 177 179 $(PATH_SDK_WINPSDK_LIB)/WbemUuid.Lib … … 187 189 $(WinNetConfig_1_TARGET) \ 188 190 $(VBoxDrvCfg_1_TARGET) \ 191 $(PATH_SDK_W2K3DDK_LIB)/Newdev.lib \ 189 192 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \ 190 193 $(PATH_SDK_WINPSDK_LIB)/WbemUuid.Lib … … 201 204 $(WinNetConfig_1_TARGET) \ 202 205 $(VBoxDrvCfg_1_TARGET) \ 206 $(PATH_SDK_W2K3DDK_LIB)/Newdev.lib \ 203 207 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \ 204 208 $(PATH_SDK_WINPSDK_LIB)/WbemUuid.Lib -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp
r38797 r40993 448 448 } 449 449 450 typedef struct VBOXNECTFGWINPROPCHANGE 451 { 452 VBOXNECTFGWINPROPCHANGE_TYPE enmPcType; 453 HRESULT hr; 454 } VBOXNECTFGWINPROPCHANGE ,*PVBOXNECTFGWINPROPCHANGE; 455 456 static BOOL vboxNetCfgWinPropChangeAllNetDevicesOfIdCallback(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext) 457 { 458 PVBOXNECTFGWINPROPCHANGE pPc = (PVBOXNECTFGWINPROPCHANGE)pContext; 459 HRESULT hr = S_OK; 460 SP_PROPCHANGE_PARAMS PcParams; 461 memset (&PcParams, 0, sizeof (PcParams)); 462 463 PcParams.ClassInstallHeader.cbSize = sizeof (SP_CLASSINSTALL_HEADER); 464 PcParams.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE; 465 PcParams.Scope = DICS_FLAG_GLOBAL; 466 PcParams.HwProfile = 0; 467 switch(pPc->enmPcType) 468 { 469 case VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE: 470 PcParams.StateChange = DICS_DISABLE; 471 break; 472 case VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE: 473 PcParams.StateChange = DICS_ENABLE; 474 break; 475 default: 476 NonStandardLogFlow(("unexpected prop change type: %d\n", pPc->enmPcType)); 477 pPc->hr = E_INVALIDARG; 478 return FALSE; 479 } 480 481 482 if (SetupDiSetClassInstallParams(hDevInfo, pDev, &PcParams.ClassInstallHeader, sizeof (PcParams))) 483 { 484 if (SetupDiSetSelectedDevice(hDevInfo, pDev)) 485 { 486 if (SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, hDevInfo, pDev)) 487 { 488 SP_DEVINSTALL_PARAMS devParams; 489 devParams.cbSize = sizeof(devParams); 490 if (SetupDiGetDeviceInstallParams(hDevInfo,pDev,&devParams)) 491 { 492 if (devParams.Flags & (DI_NEEDRESTART|DI_NEEDREBOOT)) 493 { 494 hr = S_FALSE; 495 NonStandardLogFlow(("PropChange: !!!REBOOT REQUIRED!!!\n")); 496 } 497 } 498 } 499 else 500 { 501 DWORD dwErr = GetLastError(); 502 NonStandardLogFlow(("SetupDiCallClassInstaller failed with %ld\n", dwErr)); 503 hr = HRESULT_FROM_WIN32(dwErr); 504 } 505 } 506 else 507 { 508 DWORD dwErr = GetLastError(); 509 NonStandardLogFlow(("SetupDiSetSelectedDevice failed with %ld\n", dwErr)); 510 hr = HRESULT_FROM_WIN32(dwErr); 511 } 512 } 513 else 514 { 515 DWORD dwErr = GetLastError(); 516 NonStandardLogFlow(("SetupDiSetClassInstallParams failed with %ld\n", dwErr)); 517 hr = HRESULT_FROM_WIN32(dwErr); 518 } 519 520 return TRUE; 521 } 522 450 523 typedef BOOL (*VBOXNETCFGWIN_NETENUM_CALLBACK) (HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext); 451 524 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinEnumNetDevices(LPCWSTR pPnPId, VBOXNETCFGWIN_NETENUM_CALLBACK callback, PVOID pContext) … … 553 626 { 554 627 return VBoxNetCfgWinEnumNetDevices(lpszPnPId, vboxNetCfgWinRemoveAllNetDevicesOfIdCallback, NULL); 628 } 629 630 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinPropChangeAllNetDevicesOfId(IN LPCWSTR lpszPnPId, VBOXNECTFGWINPROPCHANGE_TYPE enmPcType) 631 { 632 VBOXNECTFGWINPROPCHANGE Pc; 633 Pc.enmPcType = enmPcType; 634 Pc.hr = S_OK; 635 return VBoxNetCfgWinEnumNetDevices(lpszPnPId, vboxNetCfgWinPropChangeAllNetDevicesOfIdCallback, &Pc); 555 636 } 556 637 … … 2349 2430 } 2350 2431 2432 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinUpdateHostOnlyNetworkInterface(LPCWSTR pcsxwInf, BOOL *pbRebootRequired) 2433 { 2434 return VBoxDrvCfgDrvUpdate(DRIVERHWID, pcsxwInf, pbRebootRequired); 2435 } 2436 2351 2437 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface(IN LPCWSTR pInfPath, IN bool bIsInfPathFile, 2352 2438 OUT GUID *pGuid, OUT BSTR *lppszName, OUT BSTR *pErrMsg) -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/tools/VBoxNetAdpInstall.cpp
r36184 r40993 17 17 18 18 #include <VBox/VBoxNetCfg-win.h> 19 #include <VBox/VBoxDrvCfg-win.h> 19 20 #include <stdio.h> 21 22 #include <devguid.h> 20 23 21 24 #define VBOX_NETADP_INF L".\\VBoxNetAdp.inf" … … 94 97 } 95 98 99 static int VBoxNetAdpUninstall() 100 { 101 int r = 1; 102 VBoxNetCfgWinSetLogging(winNetCfgLogger); 103 104 printf("uninstalling all Host-Only interfaces..\n"); 105 106 HRESULT hr = CoInitialize(NULL); 107 if(hr == S_OK) 108 { 109 hr = VBoxNetCfgWinRemoveAllNetDevicesOfId(L"sun_VBoxNetAdp"); 110 if(hr == S_OK) 111 { 112 hr = VBoxDrvCfgInfUninstallAllSetupDi(&GUID_DEVCLASS_NET, L"Net", L"sun_VBoxNetAdp", 0/* could be SUOI_FORCEDELETE */); 113 if(hr == S_OK) 114 { 115 printf("uninstalled successfully\n"); 116 } 117 else 118 { 119 printf("uninstalled successfully, but failed to remove infs\n"); 120 } 121 r = 0; 122 } 123 else 124 { 125 printf("uninstall failed, hr = 0x%x\n", hr); 126 } 127 128 CoUninitialize(); 129 } 130 else 131 { 132 wprintf(L"Error initializing COM (0x%x)\n", hr); 133 } 134 135 VBoxNetCfgWinSetLogging(NULL); 136 137 return r; 138 } 139 140 static int VBoxNetAdpUpdate() 141 { 142 int r = 1; 143 VBoxNetCfgWinSetLogging(winNetCfgLogger); 144 145 printf("uninstalling all Host-Only interfaces..\n"); 146 147 HRESULT hr = CoInitialize(NULL); 148 if(hr == S_OK) 149 { 150 BOOL fRebootRequired = FALSE; 151 hr = VBoxNetCfgWinUpdateHostOnlyNetworkInterface(VBOX_NETADP_INF, &fRebootRequired); 152 if(hr == S_OK) 153 { 154 if (fRebootRequired) 155 printf("!!REBOOT REQUIRED!!\n"); 156 printf("updated successfully\n"); 157 r = 0; 158 } 159 else 160 { 161 printf("update failed, hr = 0x%x\n", hr); 162 } 163 164 CoUninitialize(); 165 } 166 else 167 { 168 wprintf(L"Error initializing COM (0x%x)\n", hr); 169 } 170 171 VBoxNetCfgWinSetLogging(NULL); 172 173 return r; 174 } 175 176 static int VBoxNetAdpDisable() 177 { 178 int r = 1; 179 VBoxNetCfgWinSetLogging(winNetCfgLogger); 180 181 printf("disabling all Host-Only interfaces..\n"); 182 183 HRESULT hr = CoInitialize(NULL); 184 if(hr == S_OK) 185 { 186 hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(L"sun_VBoxNetAdp", VBOXNECTFGWINPROPCHANGE_TYPE_DISABLE); 187 if(hr == S_OK) 188 { 189 printf("disable succeeded!\n"); 190 r = 0; 191 } 192 else 193 { 194 printf("disable failed, hr = 0x%x\n", hr); 195 } 196 197 CoUninitialize(); 198 } 199 else 200 { 201 wprintf(L"Error initializing COM (0x%x)\n", hr); 202 } 203 204 VBoxNetCfgWinSetLogging(NULL); 205 206 return r; 207 } 208 209 static int VBoxNetAdpEnable() 210 { 211 int r = 1; 212 VBoxNetCfgWinSetLogging(winNetCfgLogger); 213 214 printf("enabling all Host-Only interfaces..\n"); 215 216 HRESULT hr = CoInitialize(NULL); 217 if(hr == S_OK) 218 { 219 hr = VBoxNetCfgWinPropChangeAllNetDevicesOfId(L"sun_VBoxNetAdp", VBOXNECTFGWINPROPCHANGE_TYPE_ENABLE); 220 if(hr == S_OK) 221 { 222 printf("disable succeeded!\n"); 223 r = 0; 224 } 225 else 226 { 227 printf("disable failed, hr = 0x%x\n", hr); 228 } 229 230 CoUninitialize(); 231 } 232 else 233 { 234 wprintf(L"Error initializing COM (0x%x)\n", hr); 235 } 236 237 VBoxNetCfgWinSetLogging(NULL); 238 239 return r; 240 } 241 242 static void printUsage() 243 { 244 printf("Host-Only network adapter configuration tool\n" 245 " Usage: VBoxNetAdpInstall [cmd]\n" 246 " cmd can be one of the following values:\n" 247 " i - install a new host-only interface\n" 248 " u - uninstall all host-only interfaces\n" 249 " a - update the host-only driver\n" 250 " d - disable all host-only interfaces\n" 251 " e - enable all host-only interfaces\n" 252 " h - print this message\n"); 253 } 254 96 255 int __cdecl main(int argc, char **argv) 97 256 { 98 return VBoxNetAdpInstall(); 99 } 257 if (argc < 2) 258 return VBoxNetAdpInstall(); 259 if (argc > 2) 260 { 261 printUsage(); 262 return 1; 263 } 264 265 __debugbreak(); 266 267 if (!strcmp(argv[1], "i")) 268 return VBoxNetAdpInstall(); 269 if (!strcmp(argv[1], "u")) 270 return VBoxNetAdpUninstall(); 271 if (!strcmp(argv[1], "a")) 272 return VBoxNetAdpUpdate(); 273 if (!strcmp(argv[1], "d")) 274 return VBoxNetAdpDisable(); 275 if (!strcmp(argv[1], "e")) 276 return VBoxNetAdpEnable(); 277 278 printUsage(); 279 return !strcmp(argv[1], "h"); 280 } -
trunk/src/VBox/HostDrivers/win/cfg/VBoxDrvCfg.cpp
r38731 r40993 24 24 #include <malloc.h> 25 25 #include <stdio.h> 26 27 #include <Newdev.h> 26 28 27 29 static PFNVBOXDRVCFG_LOG g_pfnVBoxDrvCfgLog; … … 811 813 return hr; 812 814 } 815 816 817 HRESULT VBoxDrvCfgDrvUpdate(LPCWSTR pcszwHwId, LPCWSTR pcsxwInf, BOOL *pbRebootRequired) 818 { 819 if (pbRebootRequired) 820 *pbRebootRequired = FALSE; 821 BOOL bRebootRequired = FALSE; 822 WCHAR InfFullPath[MAX_PATH]; 823 DWORD dwChars = GetFullPathNameW(pcsxwInf, 824 sizeof (InfFullPath) / sizeof (InfFullPath[0]), 825 InfFullPath, 826 NULL /* LPTSTR *lpFilePart */ 827 ); 828 if (!dwChars || dwChars >= MAX_PATH) 829 { 830 NonStandardLogCrap(("GetFullPathNameW failed, WinEr(%d), dwChars(%d)\n", GetLastError(), dwChars)); 831 return E_INVALIDARG; 832 } 833 834 835 if (!UpdateDriverForPlugAndPlayDevicesW(NULL, /* HWND hwndParent */ 836 pcszwHwId, 837 InfFullPath, 838 INSTALLFLAG_FORCE, 839 &bRebootRequired)) 840 { 841 NonStandardLogCrap(("UpdateDriverForPlugAndPlayDevicesW failed, WinEr(%d)\n", GetLastError(), dwChars)); 842 return E_FAIL; 843 } 844 845 846 if (bRebootRequired) 847 NonStandardLogCrap(("!!Driver Update: REBOOT REQUIRED!!\n", GetLastError(), dwChars)); 848 849 if (pbRebootRequired) 850 *pbRebootRequired = bRebootRequired; 851 852 return S_OK; 853 } -
trunk/src/VBox/Installer/win/InstallHelper/Makefile.kmk
r38082 r40993 40 40 $(PATH_STAGE_LIB)/WinNetConfig.lib \ 41 41 $(PATH_STAGE_LIB)/VBoxDrvCfg.lib \ 42 $(PATH_SDK_W2K3DDK_LIB)/Newdev.lib \ 42 43 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \ 43 44 $(PATH_SDK_WINPSDK_LIB)/WbemUuid.Lib -
trunk/src/VBox/Main/Makefile.kmk
r40976 r40993 389 389 $(PATH_STAGE_LIB)/WinNetConfig$(VBOX_SUFF_LIB) \ 390 390 $(PATH_STAGE_LIB)/VBoxDrvCfg$(VBOX_SUFF_LIB) \ 391 $(PATH_SDK_W2K3DDK_LIB)/Newdev.lib \ 391 392 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \ 392 393 $(PATH_SDK_WINPSDK_LIB)/WbemUuid.Lib … … 579 580 VBoxC_LIBS.win += \ 580 581 $(PATH_STAGE_LIB)/VBoxDrvCfg$(VBOX_SUFF_LIB) \ 582 $(PATH_SDK_W2K3DDK_LIB)/Newdev.lib \ 581 583 $(PATH_STAGE_LIB)/WinNetConfig$(VBOX_SUFF_LIB) \ 582 584 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \
Note:
See TracChangeset
for help on using the changeset viewer.