Changeset 62697 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg
- Timestamp:
- Jul 29, 2016 3:56:55 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 109271
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp
r62681 r62697 19 19 #define _WIN32_DCOM 20 20 21 22 21 #include <devguid.h> 23 22 #include <stdio.h> … … 38 37 #include <Ws2tcpip.h> 39 38 #include <ws2ipdef.h> 40 #include < netioapi.h>41 #include <ip hlpapi.h>39 #include <iprt/win/netioapi.h> 40 #include <iprt/win/iphlpapi.h> 42 41 43 42 … … 498 497 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRenameConnection(LPWSTR pGuid, PCWSTR NewName); 499 498 500 static BOOL vboxNetCfgWinRemoveAllNetDevicesOfIdCallback(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext) 501 { 499 static BOOL vboxNetCfgWinRemoveAllNetDevicesOfIdCallback(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pvContext) 500 { 501 RT_NOREF1(pvContext); 502 502 SP_REMOVEDEVICE_PARAMS rmdParams; 503 503 memset(&rmdParams, 0, sizeof(SP_REMOVEDEVICE_PARAMS)); … … 674 674 } 675 675 676 typedef BOOL (* VBOXNETCFGWIN_NETENUM_CALLBACK)(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext);676 typedef BOOL (*PFNVBOXNETCFGWINNETENUMCALLBACK)(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext); 677 677 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinEnumNetDevices(LPCWSTR pwszPnPId, 678 VBOXNETCFGWIN_NETENUM_CALLBACK callback, PVOID pContext)678 PFNVBOXNETCFGWINNETENUMCALLBACK pfnCallback, PVOID pvContext) 679 679 { 680 680 NonStandardLogFlow(("VBoxNetCfgWinEnumNetDevices: Searching for: %S\n", pwszPnPId)); … … 690 690 if (hDevInfo != INVALID_HANDLE_VALUE) 691 691 { 692 DWORD winEr ;692 DWORD winEr = NO_ERROR; 693 693 694 694 DWORD dwDevId = 0; … … 771 771 if (!wcsnicmp(pCurId, pwszPnPId, cPnPId)) 772 772 { 773 if (! callback(hDevInfo, &Dev, pContext))773 if (!pfnCallback(hDevInfo, &Dev, pvContext)) 774 774 break; 775 775 } … … 1118 1118 { 1119 1119 VARIANT vtServiceName; 1120 BOOL bIsHostOnly = FALSE;1121 1120 VariantInit(&vtServiceName); 1122 1121 … … 1198 1197 } 1199 1198 1199 #if 0 /* unused */ 1200 1200 1201 1201 static HRESULT netIfWinHasIpSettings(IWbemClassObject * pAdapterConfig, SAFEARRAY * pCheckIp, SAFEARRAY * pCheckMask, bool *pFound) … … 1273 1273 } 1274 1274 1275 #endif /* unused */ 1276 1275 1277 static HRESULT netIfWinCreateIWbemServices(IWbemServices ** ppSvc) 1276 1278 { … … 1378 1380 static HRESULT netIfWinCreateIpArray(SAFEARRAY **ppArray, in_addr* aIp, UINT cIp) 1379 1381 { 1380 HRESULT hr ;1382 HRESULT hr = S_OK; /* MSC maybe used uninitialized */ 1381 1383 SAFEARRAY * pIpArray = SafeArrayCreateVector(VT_BSTR, 0, cIp); 1382 1384 if (pIpArray) … … 1408 1410 } 1409 1411 1412 #if 0 /* unused */ 1410 1413 static HRESULT netIfWinCreateIpArrayV4V6(SAFEARRAY **ppArray, BSTR Ip) 1411 1414 { … … 1434 1437 return hr; 1435 1438 } 1439 #endif 1436 1440 1437 1441 … … 1450 1454 } 1451 1455 1456 #if 0 /* unused */ 1452 1457 static HRESULT netIfWinCreateIpArrayVariantV4V6(VARIANT * pIpAddresses, BSTR Ip) 1453 1458 { … … 1463 1468 return hr; 1464 1469 } 1465 1466 static HRESULT netIfWinEnableStatic(IWbemServices * pSvc, const GUID * pGuid, BSTR ObjPath, VARIANT * pIp, VARIANT * pMask) 1470 #endif 1471 1472 static HRESULT netIfWinEnableStatic(IWbemServices *pSvc, const GUID *pGuid, BSTR ObjPath, VARIANT *pIp, VARIANT *pMask) 1467 1473 { 1468 1474 ComPtr<IWbemClassObject> pClass; … … 1491 1497 switch (winEr) 1492 1498 { 1493 case 0:1499 case 0: 1494 1500 { 1495 1501 hr = S_OK; 1496 1502 // bool bFound; 1497 1503 // HRESULT tmpHr = netIfWinWaitIpSettings(pSvc, pGuid, pIp->parray, pMask->parray, 180, &bFound); 1504 NOREF(pGuid); 1505 break; 1498 1506 } 1499 break; 1500 default: 1501 hr = HRESULT_FROM_WIN32( winEr ); 1502 break; 1507 default: 1508 hr = HRESULT_FROM_WIN32( winEr ); 1509 break; 1503 1510 } 1504 1511 } … … 1531 1538 return hr; 1532 1539 } 1540 1541 #if 0 /* unused */ 1533 1542 1534 1543 static HRESULT netIfWinEnableStaticV4V6(IWbemServices * pSvc, const GUID * pGuid, BSTR ObjPath, BSTR Ip, BSTR Mask) … … 1620 1629 return hr; 1621 1630 } 1631 1632 #endif /* unused */ 1622 1633 1623 1634 static HRESULT netIfWinEnableDHCP(IWbemServices * pSvc, BSTR ObjPath) … … 2172 2183 static HRESULT vboxNetCfgWinNetAdpUninstall(IN INetCfg *pNc, LPCWSTR pwszId, DWORD InfRmFlags) 2173 2184 { 2174 HRESULT hr = S_OK;2185 NOREF(pNc); 2175 2186 NonStandardLog("Finding NetAdp driver package and trying to uninstall it ...\n"); 2176 2187 2177 2188 VBoxDrvCfgInfUninstallAllF(L"Net", pwszId, InfRmFlags); 2178 2189 NonStandardLog("NetAdp is not installed currently\n"); 2179 return hr;2190 return S_OK; 2180 2191 } 2181 2192 … … 2291 2302 const WCHAR * pSuffix = wcsrchr( DevName, L'#' ); 2292 2303 ULONG cbSize = sizeof(VBOX_CONNECTION_NAME); 2293 ULONG cbSufSize = 0;2294 2304 2295 2305 if (pSuffix) … … 2317 2327 static BOOL vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority(IN INetCfg *pNc, IN INetCfgComponent *pNcc, PVOID pContext) 2318 2328 { 2329 RT_NOREF1(pNc); 2319 2330 INetCfgComponentBindings *pNetCfgBindings; 2320 2331 GUID *pGuid = (GUID*)pContext; … … 2652 2663 { 2653 2664 BOOL ok; 2654 DWORD ret = 0;2655 2665 GUID netGuid; 2656 2666 SP_DEVINFO_DATA DeviceInfoData; … … 2663 2673 2664 2674 /* copy the net class GUID */ 2665 memcpy 2675 memcpy(&netGuid, &GUID_DEVCLASS_NET, sizeof (GUID_DEVCLASS_NET)); 2666 2676 2667 2677 /* return a device info set contains all installed devices of the Net class */ 2668 hDeviceInfo = SetupDiGetClassDevs 2678 hDeviceInfo = SetupDiGetClassDevs(&netGuid, NULL, NULL, DIGCF_PRESENT); 2669 2679 2670 2680 if (hDeviceInfo == INVALID_HANDLE_VALUE) 2671 SetErrBreak 2681 SetErrBreak(("SetupDiGetClassDevs failed (0x%08X)", GetLastError())); 2672 2682 2673 2683 /* enumerate the driver info list */ … … 2676 2686 TCHAR *deviceHwid; 2677 2687 2678 ok = SetupDiEnumDeviceInfo 2688 ok = SetupDiEnumDeviceInfo(hDeviceInfo, index, &DeviceInfoData); 2679 2689 2680 2690 if (!ok) … … 2690 2700 2691 2701 /* try to get the hardware ID registry property */ 2692 ok = SetupDiGetDeviceRegistryProperty 2693 2694 2695 2696 2697 2698 2702 ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo, 2703 &DeviceInfoData, 2704 SPDRP_HARDWAREID, 2705 NULL, 2706 NULL, 2707 0, 2708 &size); 2699 2709 if (!ok) 2700 2710 { … … 2705 2715 } 2706 2716 2707 deviceHwid = (TCHAR *) malloc 2708 ok = SetupDiGetDeviceRegistryProperty 2709 2710 2711 2712 2713 2714 2717 deviceHwid = (TCHAR *) malloc(size); 2718 ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo, 2719 &DeviceInfoData, 2720 SPDRP_HARDWAREID, 2721 NULL, 2722 (PBYTE)deviceHwid, 2723 size, 2724 NULL); 2715 2725 if (!ok) 2716 2726 { 2717 free 2727 free(deviceHwid); 2718 2728 deviceHwid = NULL; 2719 2729 index++; … … 2730 2740 for (TCHAR *t = deviceHwid; 2731 2741 t && *t && t < &deviceHwid[size / sizeof(TCHAR)]; 2732 t += _tcslen 2733 { 2734 if (!_tcsicmp 2742 t += _tcslen(t) + 1) 2743 { 2744 if (!_tcsicmp(DRIVERHWID, t)) 2735 2745 { 2736 2746 /* get the device instance ID */ … … 3493 3503 HRESULT vboxNetCfgWinSetupMetric(IN HKEY hKey) 3494 3504 { 3495 HRESULT rc = S_OK;3496 3505 HINSTANCE hModule = NULL; 3497 NET_LUID luid; 3498 int loopbackMetric; 3499 3500 rc = vboxLoadIpHelpFunctions(hModule); 3501 3506 HRESULT rc = vboxLoadIpHelpFunctions(hModule); 3502 3507 if (SUCCEEDED(rc)) 3508 { 3509 NET_LUID luid; 3503 3510 rc = vboxNetCfgWinGetInterfaceLUID(hKey, &luid); 3504 3505 if (SUCCEEDED(rc)) 3506 rc = vboxNetCfgWinGetLoopbackMetric(&loopbackMetric); 3507 3508 if (SUCCEEDED(rc)) 3509 rc = vboxNetCfgWinSetInterfaceMetric(&luid, loopbackMetric - 1); 3511 if (SUCCEEDED(rc)) 3512 { 3513 int loopbackMetric; 3514 rc = vboxNetCfgWinGetLoopbackMetric(&loopbackMetric); 3515 if (SUCCEEDED(rc)) 3516 rc = vboxNetCfgWinSetInterfaceMetric(&luid, loopbackMetric - 1); 3517 } 3518 } 3510 3519 3511 3520 g_pfnInitializeIpInterfaceEntry = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.