Changeset 57485 in vbox for trunk/src/VBox/Main/src-server/win
- Timestamp:
- Aug 21, 2015 8:34:03 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/win/NetIf-win.cpp
r57461 r57485 995 995 996 996 997 static int netIfListHostAdapters( std::list<ComObjPtr<HostNetworkInterface> > &list)997 static int netIfListHostAdapters(INetCfg *pNc, std::list<ComObjPtr<HostNetworkInterface> > &list) 998 998 { 999 999 #ifndef VBOX_WITH_NETFLT … … 1001 1001 return VERR_NOT_IMPLEMENTED; 1002 1002 #else /* # if defined VBOX_WITH_NETFLT */ 1003 INetCfg *pNc;1004 1003 INetCfgComponent *pMpNcc; 1005 LPWSTR lpszApp = NULL;1006 1004 HRESULT hr; 1007 1005 IEnumNetCfgComponent *pEnumComponent; 1008 1006 1009 /* we are using the INetCfg API for getting the list of miniports */ 1010 hr = VBoxNetCfgWinQueryINetCfg(&pNc, FALSE, 1011 VBOX_APP_NAME, 1012 10000, 1013 &lpszApp); 1014 Assert(hr == S_OK); 1007 hr = pNc->EnumComponents(&GUID_DEVCLASS_NET, &pEnumComponent); 1015 1008 if (hr == S_OK) 1016 1009 { 1017 hr = pNc->EnumComponents(&GUID_DEVCLASS_NET, &pEnumComponent); 1018 if (hr == S_OK) 1019 { 1020 while ((hr = pEnumComponent->Next(1, &pMpNcc, NULL)) == S_OK) 1021 { 1022 LPWSTR pwszName; 1023 ULONG uComponentStatus; 1024 hr = pMpNcc->GetDisplayName(&pwszName); 1025 if (hr == S_OK) 1026 LogRel(("netIfListHostAdapters: %ls\n", pwszName)); 1027 else 1028 LogRel(("netIfListHostAdapters: failed to get device display name (0x%x)\n", hr)); 1029 hr = pMpNcc->GetDeviceStatus(&uComponentStatus); 1030 if (hr == S_OK) 1010 while ((hr = pEnumComponent->Next(1, &pMpNcc, NULL)) == S_OK) 1011 { 1012 LPWSTR pwszName; 1013 ULONG uComponentStatus; 1014 hr = pMpNcc->GetDisplayName(&pwszName); 1015 if (hr == S_OK) 1016 LogRel(("netIfListHostAdapters: %ls\n", pwszName)); 1017 else 1018 LogRel(("netIfListHostAdapters: failed to get device display name (0x%x)\n", hr)); 1019 hr = pMpNcc->GetDeviceStatus(&uComponentStatus); 1020 if (hr == S_OK) 1021 { 1022 if (uComponentStatus == 0) 1031 1023 { 1032 if (uComponentStatus == 0) 1033 { 1034 LPWSTR pId; 1035 hr = pMpNcc->GetId(&pId); 1036 Assert(hr == S_OK); 1037 if (hr == S_OK) 1024 LPWSTR pId; 1025 hr = pMpNcc->GetId(&pId); 1026 Assert(hr == S_OK); 1027 if (hr == S_OK) 1028 { 1029 LogRel(("netIfListHostAdapters: id = %ls\n", pId)); 1030 if (!_wcsnicmp(pId, L"sun_VBoxNetAdp", sizeof(L"sun_VBoxNetAdp")/2)) 1038 1031 { 1039 LogRel(("netIfListHostAdapters: id = %ls\n", pId)); 1040 if (!_wcsnicmp(pId, L"sun_VBoxNetAdp", sizeof(L"sun_VBoxNetAdp")/2)) 1041 { 1042 vboxNetWinAddComponent(&list, pMpNcc, HostNetworkInterfaceType_HostOnly, -1); 1043 } 1044 CoTaskMemFree(pId); 1032 vboxNetWinAddComponent(&list, pMpNcc, HostNetworkInterfaceType_HostOnly, -1); 1045 1033 } 1046 else 1047 LogRel(("netIfListHostAdapters: failed to get device id (0x%x)\n", hr)); 1048 } 1034 CoTaskMemFree(pId); 1035 } 1036 else 1037 LogRel(("netIfListHostAdapters: failed to get device id (0x%x)\n", hr)); 1049 1038 } 1050 else 1051 LogRel(("netIfListHostAdapters: failed to get device status (0x%x)\n", hr)); 1052 pMpNcc->Release(); 1053 } 1054 Assert(hr == S_OK || hr == S_FALSE); 1055 1056 pEnumComponent->Release(); 1057 } 1058 else 1059 { 1060 LogRel(("netIfListHostAdapters: EnumComponents error (0x%x)\n", hr)); 1061 } 1062 1063 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE); 1039 } 1040 else 1041 LogRel(("netIfListHostAdapters: failed to get device status (0x%x)\n", hr)); 1042 pMpNcc->Release(); 1043 } 1044 Assert(hr == S_OK || hr == S_FALSE); 1045 1046 pEnumComponent->Release(); 1064 1047 } 1065 1048 else 1066 { 1067 LogRel(("netIfListHostAdapters: failed to acquire INetCfg interface (0x%x)\n", hr)); 1068 1069 if (lpszApp) 1070 { 1071 CoTaskMemFree(lpszApp); 1072 } 1073 } 1049 LogRel(("netIfListHostAdapters: EnumComponents error (0x%x)\n", hr)); 1074 1050 #endif /* # if defined VBOX_WITH_NETFLT */ 1075 1051 return VINF_SUCCESS; … … 1480 1456 return VERR_NOT_IMPLEMENTED; 1481 1457 #else /* # if defined VBOX_WITH_NETFLT */ 1482 INetCfg *pNc ;1458 INetCfg *pNc = NULL; 1483 1459 INetCfgComponent *pMpNcc; 1484 1460 INetCfgComponent *pTcpIpNcc; … … 1632 1608 } 1633 1609 1610 /* Add host-only adapters to the list */ 1611 netIfListHostAdapters(pNc, list); 1612 1634 1613 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE); 1635 1614 } 1636 1615 else 1637 LogRel(("NetIfList: failed to acquire INetCfg interface (0x%x)\n", hr)); 1638 1639 /* Add host-only adapters to the list */ 1640 netIfListHostAdapters(list); 1616 { 1617 if (pNc) 1618 pNc->Release(); 1619 pNc = NULL; 1620 LogRel(("NetIfList: failed to acquire INetCfg interface (0x%x), trying CoCreateInstance...\n", hr)); 1621 hr = CoCreateInstance(CLSID_CNetCfg, NULL, CLSCTX_INPROC_SERVER, IID_INetCfg, (PVOID*)&pNc); 1622 LogRel(("NetIfList: CoCreateInstance failed with 0x%x\n", hr)); 1623 if (pNc) 1624 pNc->Release(); 1625 } 1641 1626 1642 1627 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.