VirtualBox

Changeset 59033 in vbox


Ignore:
Timestamp:
Dec 7, 2015 5:28:06 PM (9 years ago)
Author:
vboxsync
Message:

Main/Network: fixed regression causing host adapters not to be listed when NDIS5 drivers are installed (#7973)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/win/NetIf-win.cpp

    r58885 r59033  
    14841484};
    14851485
     1486static int netIfGetUnboundHostOnlyAdapters(INetCfg *pNetCfg, std::list<BoundAdapter> &adapters)
     1487{
     1488    INetCfgComponent     *pMiniport;
     1489    HRESULT              hr;
     1490    IEnumNetCfgComponent  *pEnumComponent;
     1491
     1492    if ((hr = pNetCfg->EnumComponents(&GUID_DEVCLASS_NET, &pEnumComponent)) != S_OK)
     1493        netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to enumerate network adapter components (0x%x)\n", hr));
     1494    else
     1495    {
     1496        while ((hr = pEnumComponent->Next(1, &pMiniport, NULL)) == S_OK)
     1497        {
     1498            GUID guid;
     1499            ULONG uComponentStatus;
     1500            struct BoundAdapter adapter;
     1501            memset(&adapter, 0, sizeof(adapter));
     1502            if ((hr = pMiniport->GetDisplayName(&adapter.pName)) != S_OK)
     1503                netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to get device display name (0x%x)\n", hr));
     1504            else if ((hr = pMiniport->GetDeviceStatus(&uComponentStatus)) != S_OK)
     1505                netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to get device status (0x%x)\n", hr));
     1506            else if (uComponentStatus != 0)
     1507                netIfLog(("netIfGetUnboundHostOnlyAdapters: wrong device status (0x%x)\n", uComponentStatus));
     1508            else if ((hr = pMiniport->GetId(&adapter.pHwId)) != S_OK)
     1509                netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to get device id (0x%x)\n", hr));
     1510            else if (_wcsnicmp(adapter.pHwId, L"sun_VBoxNetAdp", sizeof(L"sun_VBoxNetAdp")/2))
     1511                netIfLog(("netIfGetUnboundHostOnlyAdapters: not host-only id = %ls, ignored\n", adapter.pHwId));
     1512            else if ((hr = pMiniport->GetInstanceGuid(&guid)) != S_OK)
     1513                netIfLog(("netIfGetUnboundHostOnlyAdapters: failed to get instance id (0x%x)\n", hr));
     1514            else
     1515            {
     1516                adapter.guid = *(Guid(guid).raw());
     1517                netIfLog(("netIfGetUnboundHostOnlyAdapters: guid=%RTuuid, name=%ls id = %ls\n", &adapter.guid, adapter.pName, adapter.pHwId));
     1518                adapters.push_back(adapter);
     1519                adapter.pName = adapter.pHwId = NULL; /* do not free, will be done later */
     1520            }
     1521            if (adapter.pHwId)
     1522                CoTaskMemFree(adapter.pHwId);
     1523            if (adapter.pName)
     1524                CoTaskMemFree(adapter.pName);
     1525            pMiniport->Release();
     1526        }
     1527        Assert(hr == S_OK || hr == S_FALSE);
     1528
     1529        pEnumComponent->Release();
     1530    }
     1531    netIfLog(("netIfGetUnboundHostOnlyAdapters: return\n"));
     1532    return VINF_SUCCESS;
     1533}
     1534
    14861535static HRESULT netIfGetBoundAdapters(std::list<BoundAdapter> &boundAdapters)
    14871536{
     
    15041553    }
    15051554
    1506     if ((hr = pNetCfg->FindComponent(L"oracle_VBoxNetLwf", &pFilter)) != S_OK)
    1507         netIfLog(("netIfGetBoundAdapters: could not find 'oracle_VBoxNetLwf' component (0x%x)\n", hr));
     1555    if ((hr = pNetCfg->FindComponent(L"oracle_VBoxNetLwf", &pFilter)) != S_OK
     1556        /* fall back to NDIS5 miniport lookup */
     1557        && (hr = pNetCfg->FindComponent(L"sun_VBoxNetFlt", &pFilter)))
     1558        netIfLog(("netIfGetBoundAdapters: could not find either 'oracle_VBoxNetLwf' or 'sun_VBoxNetFlt' components (0x%x)\n", hr));
    15081559    else
    15091560    {
     
    15691620                                            netIfLog(("netIfGetBoundAdapters: %ls: failed to get hardware id (0x%x)\n",
    15701621                                                      pwszName, hr));
     1622                                        else if (!_wcsnicmp(pwszHwId, L"sun_VBoxNetAdp", sizeof(L"sun_VBoxNetAdp")/2))
     1623                                            netIfLog(("netIfGetBoundAdapters: host-only adapter %ls, ignored\n", pwszName));
    15711624                                        else if ((hr = pAdapter->GetInstanceGuid(&guid)) != S_OK)
    15721625                                            netIfLog(("netIfGetBoundAdapters: %ls: failed to get instance GUID (0x%x)\n",
     
    16051658        pFilter->Release();
    16061659    }
     1660    /* Host-only adapters are not necessarily bound, add them separately. */
     1661    netIfGetUnboundHostOnlyAdapters(pNetCfg, boundAdapters);
    16071662    VBoxNetCfgWinReleaseINetCfg(pNetCfg, FALSE);
    16081663
     
    18131868                    for (it = boundAdapters.begin(); it != boundAdapters.end(); ++it)
    18141869                    {
    1815                         if (!RTUuidCompareStr(Guid((*it).guid).raw(), pszUuid + 1))
     1870                        if (!RTUuidCompareStr(&(*it).guid, pszUuid + 1))
    18161871                        {
    18171872                            (*it).pAdapter = pAdapter;
Note: See TracChangeset for help on using the changeset viewer.

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