Changeset 18704 in vbox for trunk/src/VBox
- Timestamp:
- Apr 3, 2009 4:59:22 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/HostImpl.cpp
r18252 r18704 468 468 } 469 469 470 #ifdef RT_OS_WINDOWS471 /**472 * Windows helper function for Host::COMGETTER(NetworkInterfaces).473 *474 * @returns true / false.475 *476 * @param guid The GUID.477 */478 static bool IsTAPDevice(const char *guid)479 {480 HKEY hNetcard;481 LONG status;482 DWORD len;483 int i = 0;484 bool ret = false;485 486 status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}", 0, KEY_READ, &hNetcard);487 if (status != ERROR_SUCCESS)488 return false;489 490 for (;;)491 {492 char szEnumName[256];493 char szNetCfgInstanceId[256];494 DWORD dwKeyType;495 HKEY hNetCardGUID;496 497 len = sizeof(szEnumName);498 status = RegEnumKeyExA(hNetcard, i, szEnumName, &len, NULL, NULL, NULL, NULL);499 if (status != ERROR_SUCCESS)500 break;501 502 status = RegOpenKeyExA(hNetcard, szEnumName, 0, KEY_READ, &hNetCardGUID);503 if (status == ERROR_SUCCESS)504 {505 len = sizeof(szNetCfgInstanceId);506 status = RegQueryValueExA(hNetCardGUID, "NetCfgInstanceId", NULL, &dwKeyType, (LPBYTE)szNetCfgInstanceId, &len);507 if (status == ERROR_SUCCESS && dwKeyType == REG_SZ)508 {509 char szNetProductName[256];510 char szNetProviderName[256];511 512 szNetProductName[0] = 0;513 len = sizeof(szNetProductName);514 status = RegQueryValueExA(hNetCardGUID, "ProductName", NULL, &dwKeyType, (LPBYTE)szNetProductName, &len);515 516 szNetProviderName[0] = 0;517 len = sizeof(szNetProviderName);518 status = RegQueryValueExA(hNetCardGUID, "ProviderName", NULL, &dwKeyType, (LPBYTE)szNetProviderName, &len);519 520 if ( !strcmp(szNetCfgInstanceId, guid)521 && !strcmp(szNetProductName, "VirtualBox TAP Adapter")522 && ( (!strcmp(szNetProviderName, "innotek GmbH"))523 || (!strcmp(szNetProviderName, "Sun Microsystems, Inc."))))524 {525 ret = true;526 RegCloseKey(hNetCardGUID);527 break;528 }529 }530 RegCloseKey(hNetCardGUID);531 }532 ++i;533 }534 535 RegCloseKey(hNetcard);536 return ret;537 }538 #endif /* RT_OS_WINDOWS */539 540 470 #ifdef RT_OS_SOLARIS 541 471 static void vboxSolarisAddHostIface(char *pszIface, int Instance, PCRTMAC pMac, void *pvHostNetworkInterfaceList) … … 881 811 # elif defined RT_OS_WINDOWS 882 812 # ifndef VBOX_WITH_NETFLT 883 static const char *NetworkKey = "SYSTEM\\CurrentControlSet\\Control\\Network\\" 884 "{4D36E972-E325-11CE-BFC1-08002BE10318}"; 885 HKEY hCtrlNet; 886 LONG status; 887 DWORD len; 888 status = RegOpenKeyExA (HKEY_LOCAL_MACHINE, NetworkKey, 0, KEY_READ, &hCtrlNet); 889 if (status != ERROR_SUCCESS) 890 return setError (E_FAIL, tr("Could not open registry key \"%s\""), NetworkKey); 891 892 for (int i = 0;; ++ i) 893 { 894 char szNetworkGUID [256]; 895 HKEY hConnection; 896 char szNetworkConnection [256]; 897 898 len = sizeof (szNetworkGUID); 899 status = RegEnumKeyExA (hCtrlNet, i, szNetworkGUID, &len, NULL, NULL, NULL, NULL); 900 if (status != ERROR_SUCCESS) 901 break; 902 903 if (!IsTAPDevice(szNetworkGUID)) 904 continue; 905 906 RTStrPrintf (szNetworkConnection, sizeof (szNetworkConnection), 907 "%s\\Connection", szNetworkGUID); 908 status = RegOpenKeyExA (hCtrlNet, szNetworkConnection, 0, KEY_READ, &hConnection); 909 if (status == ERROR_SUCCESS) 910 { 911 DWORD dwKeyType; 912 status = RegQueryValueExW (hConnection, TEXT("Name"), NULL, 913 &dwKeyType, NULL, &len); 914 if (status == ERROR_SUCCESS && dwKeyType == REG_SZ) 915 { 916 size_t uniLen = (len + sizeof (OLECHAR) - 1) / sizeof (OLECHAR); 917 Bstr name (uniLen + 1 /* extra zero */); 918 status = RegQueryValueExW (hConnection, TEXT("Name"), NULL, 919 &dwKeyType, (LPBYTE) name.mutableRaw(), &len); 920 if (status == ERROR_SUCCESS) 921 { 922 LogFunc(("Connection name %ls\n", name.mutableRaw())); 923 /* put a trailing zero, just in case (see MSDN) */ 924 name.mutableRaw() [uniLen] = 0; 925 /* create a new object and add it to the list */ 926 ComObjPtr <HostNetworkInterface> iface; 927 iface.createObject(); 928 /* remove the curly bracket at the end */ 929 szNetworkGUID [strlen(szNetworkGUID) - 1] = '\0'; 930 if (SUCCEEDED (iface->init (name, Guid (szNetworkGUID + 1), HostNetworkInterfaceType_Bridged))) 931 list.push_back (iface); 932 } 933 } 934 RegCloseKey (hConnection); 935 } 936 } 937 RegCloseKey (hCtrlNet); 813 hr = E_NOTIMPL; 938 814 # else /* # if defined VBOX_WITH_NETFLT */ 939 815 INetCfg *pNc; -
trunk/src/VBox/Main/win/NetIfList-win.cpp
r18676 r18704 1407 1407 1408 1408 1409 /* The original source of the VBox TAPadapter creation/destruction code has the following copyright */1409 /* The original source of the VBoxNetAdp adapter creation/destruction code has the following copyright */ 1410 1410 /* 1411 1411 Copyright 2004 by the Massachusetts Institute of Technology … … 1474 1474 /* for our purposes, 2k buffer is more 1475 1475 * than enough to obtain the hardware ID 1476 * of the VBox TAPdriver. */1476 * of the VBoxNetAdp driver. */ 1477 1477 DWORD detailBuf [2048]; 1478 1478
Note:
See TracChangeset
for help on using the changeset viewer.