Changeset 19083 in vbox
- Timestamp:
- Apr 21, 2009 3:06:55 PM (16 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk
r18900 r19083 147 147 WinNetConfig_SOURCES = \ 148 148 win/WinNetConfig.cpp 149 WinNetConfig_INCS.win += $(PATH_TOOL_$(VBOX_VCC_TOOL)_INC) 149 150 150 151 # … … 155 156 NetFltInstall_SDKS = WINPSDK W2K3DDK VBOX_NTDLL 156 157 NetFltInstall_SOURCES = win/NetFltInstall.cpp 157 NetFltInstall_LIBS = $(TARGET_WinNetConfig) 158 NetFltInstall_LIBS = $(TARGET_WinNetConfig) \ 159 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \ 160 $(PATH_SDK_WINPSDK_LIB)/WbemUuid.Lib 158 161 159 162 … … 165 168 NetFltUninstall_SDKS = WINPSDK W2K3DDK VBOX_NTDLL 166 169 NetFltUninstall_SOURCES = win/NetFltUninstall.cpp 167 NetFltUninstall_LIBS = $(TARGET_WinNetConfig) 170 NetFltUninstall_LIBS = $(TARGET_WinNetConfig) \ 171 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \ 172 $(PATH_SDK_WINPSDK_LIB)/WbemUuid.Lib 168 173 169 174 -
trunk/src/VBox/Main/Makefile.kmk
r19062 r19083 541 541 542 542 ifdef VBOX_WITH_NETFLT 543 VBoxC_LIBS.win += $(PATH_LIB)/WinNetConfig.lib 543 VBoxC_LIBS.win += $(PATH_LIB)/WinNetConfig.lib \ 544 $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/comsupp.lib \ 545 $(PATH_SDK_WINPSDK_LIB)/WbemUuid.Lib 544 546 endif 545 547 -
trunk/src/VBox/Main/win/NetIf-win.cpp
r18732 r19083 800 800 } 801 801 802 static int netIfEnableStaticIpConfig(const Guid &guid, ULONG ip, ULONG mask)803 {804 HRESULT hr;805 ComPtr <IWbemServices> pSvc;806 hr = netIfWinCreateIWbemServices(pSvc.asOutParam());807 if(SUCCEEDED(hr))808 {809 ComPtr <IWbemClassObject> pAdapterConfig;810 hr = netIfWinFindAdapterClassById(pSvc, guid, pAdapterConfig.asOutParam());811 if(SUCCEEDED(hr))812 {813 BOOL bIsHostOnly;814 hr = netIfWinIsHostOnly(pAdapterConfig, &bIsHostOnly);815 if(SUCCEEDED(hr))816 {817 if(bIsHostOnly)818 {819 in_addr aIp[1];820 in_addr aMask[1];821 aIp[0].S_un.S_addr = ip;822 aMask[0].S_un.S_addr = mask;823 824 BSTR ObjPath;825 hr = netIfWinAdapterConfigPath(pAdapterConfig, &ObjPath);826 if(SUCCEEDED(hr))827 {828 hr = netIfWinEnableStaticV4(pSvc, ObjPath, aIp, aMask, ip != 0 ? 1 : 0);829 if(SUCCEEDED(hr))830 {831 #if 0832 in_addr aGw[1];833 aGw[0].S_un.S_addr = gw;834 hr = netIfWinSetGatewaysV4(pSvc, ObjPath, aGw, 1);835 if(SUCCEEDED(hr))836 #endif837 {838 // hr = netIfWinUpdateConfig(pIf);839 }840 }841 SysFreeString(ObjPath);842 }843 }844 else845 {846 hr = E_FAIL;847 }848 }849 }850 }851 852 return SUCCEEDED(hr) ? VINF_SUCCESS : VERR_GENERAL_FAILURE;853 }854 855 802 static int netIfEnableStaticIpConfigV6(const Guid & guid, IN_BSTR aIPV6Address, IN_BSTR aIPV6Mask, IN_BSTR aIPV6DefaultGateway) 856 803 { … … 1407 1354 1408 1355 1409 /* The original source of the VBoxNetAdp adapter creation/destruction code has the following copyright */1410 /*1411 Copyright 2004 by the Massachusetts Institute of Technology1412 1413 All rights reserved.1414 1415 Permission to use, copy, modify, and distribute this software and its1416 documentation for any purpose and without fee is hereby granted,1417 provided that the above copyright notice appear in all copies and that1418 both that copyright notice and this permission notice appear in1419 supporting documentation, and that the name of the Massachusetts1420 Institute of Technology (M.I.T.) not be used in advertising or publicity1421 pertaining to distribution of the software without specific, written1422 prior permission.1423 1424 M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING1425 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL1426 M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR1427 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,1428 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,1429 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS1430 SOFTWARE.1431 */1432 1433 1434 #define DRIVERHWID _T("sun_VBoxNetAdp")1435 1436 #define SetErrBreak(strAndArgs) \1437 if (1) { \1438 aErrMsg = Utf8StrFmt strAndArgs; vrc = VERR_GENERAL_FAILURE; \1439 Assert(0);\1440 break; \1441 } else do {} while (0)1442 1443 /* static */1444 static int createNetworkInterface (SVCHlpClient *aClient,1445 BSTR * pName,1446 Guid &aGUID, Utf8Str &aErrMsg)1447 {1448 LogFlowFuncEnter();1449 // LogFlowFunc (("Network connection name = '%s'\n", aName.raw()));1450 1451 AssertReturn (aClient, VERR_INVALID_POINTER);1452 // AssertReturn (!aName.isNull(), VERR_INVALID_PARAMETER);1453 1454 int vrc = VINF_SUCCESS;1455 1456 HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE;1457 SP_DEVINFO_DATA DeviceInfoData;1458 DWORD ret = 0;1459 BOOL found = FALSE;1460 BOOL registered = FALSE;1461 BOOL destroyList = FALSE;1462 WCHAR pWCfgGuidString [50];1463 WCHAR DevName[256];1464 1465 do1466 {1467 BOOL ok;1468 GUID netGuid;1469 SP_DRVINFO_DATA DriverInfoData;1470 SP_DEVINSTALL_PARAMS DeviceInstallParams;1471 TCHAR className [MAX_PATH];1472 DWORD index = 0;1473 PSP_DRVINFO_DETAIL_DATA pDriverInfoDetail;1474 /* for our purposes, 2k buffer is more1475 * than enough to obtain the hardware ID1476 * of the VBoxNetAdp driver. */1477 DWORD detailBuf [2048];1478 1479 HKEY hkey = NULL;1480 DWORD cbSize;1481 DWORD dwValueType;1482 1483 /* initialize the structure size */1484 DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);1485 DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA);1486 1487 /* copy the net class GUID */1488 memcpy(&netGuid, &GUID_DEVCLASS_NET, sizeof(GUID_DEVCLASS_NET));1489 1490 /* create an empty device info set associated with the net class GUID */1491 hDeviceInfo = SetupDiCreateDeviceInfoList (&netGuid, NULL);1492 if (hDeviceInfo == INVALID_HANDLE_VALUE)1493 SetErrBreak (("SetupDiCreateDeviceInfoList failed (0x%08X)",1494 GetLastError()));1495 1496 /* get the class name from GUID */1497 ok = SetupDiClassNameFromGuid (&netGuid, className, MAX_PATH, NULL);1498 if (!ok)1499 SetErrBreak (("SetupDiClassNameFromGuid failed (0x%08X)",1500 GetLastError()));1501 1502 /* create a device info element and add the new device instance1503 * key to registry */1504 ok = SetupDiCreateDeviceInfo (hDeviceInfo, className, &netGuid, NULL, NULL,1505 DICD_GENERATE_ID, &DeviceInfoData);1506 if (!ok)1507 SetErrBreak (("SetupDiCreateDeviceInfo failed (0x%08X)",1508 GetLastError()));1509 1510 /* select the newly created device info to be the currently1511 selected member */1512 ok = SetupDiSetSelectedDevice (hDeviceInfo, &DeviceInfoData);1513 if (!ok)1514 SetErrBreak (("SetupDiSetSelectedDevice failed (0x%08X)",1515 GetLastError()));1516 1517 /* build a list of class drivers */1518 ok = SetupDiBuildDriverInfoList (hDeviceInfo, &DeviceInfoData,1519 SPDIT_CLASSDRIVER);1520 if (!ok)1521 SetErrBreak (("SetupDiBuildDriverInfoList failed (0x%08X)",1522 GetLastError()));1523 1524 destroyList = TRUE;1525 1526 /* enumerate the driver info list */1527 while (TRUE)1528 {1529 BOOL ret;1530 1531 ret = SetupDiEnumDriverInfo (hDeviceInfo, &DeviceInfoData,1532 SPDIT_CLASSDRIVER, index, &DriverInfoData);1533 1534 /* if the function failed and GetLastError() returned1535 * ERROR_NO_MORE_ITEMS, then we have reached the end of the1536 * list. Othewise there was something wrong with this1537 * particular driver. */1538 if (!ret)1539 {1540 if(GetLastError() == ERROR_NO_MORE_ITEMS)1541 break;1542 else1543 {1544 index++;1545 continue;1546 }1547 }1548 1549 pDriverInfoDetail = (PSP_DRVINFO_DETAIL_DATA) detailBuf;1550 pDriverInfoDetail->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);1551 1552 /* if we successfully find the hardware ID and it turns out to1553 * be the one for the loopback driver, then we are done. */1554 if (SetupDiGetDriverInfoDetail (hDeviceInfo,1555 &DeviceInfoData,1556 &DriverInfoData,1557 pDriverInfoDetail,1558 sizeof (detailBuf),1559 NULL))1560 {1561 TCHAR * t;1562 1563 /* pDriverInfoDetail->HardwareID is a MULTISZ string. Go through the1564 * whole list and see if there is a match somewhere. */1565 t = pDriverInfoDetail->HardwareID;1566 while (t && *t && t < (TCHAR *) &detailBuf [RT_ELEMENTS(detailBuf)])1567 {1568 if (!_tcsicmp(t, DRIVERHWID))1569 break;1570 1571 t += _tcslen(t) + 1;1572 }1573 1574 if (t && *t && t < (TCHAR *) &detailBuf [RT_ELEMENTS(detailBuf)])1575 {1576 found = TRUE;1577 break;1578 }1579 }1580 1581 index ++;1582 }1583 1584 if (!found)1585 SetErrBreak (("Could not find Host Interface Networking driver! "1586 "Please reinstall"));1587 1588 /* set the loopback driver to be the currently selected */1589 ok = SetupDiSetSelectedDriver (hDeviceInfo, &DeviceInfoData,1590 &DriverInfoData);1591 if (!ok)1592 SetErrBreak (("SetupDiSetSelectedDriver failed (0x%08X)",1593 GetLastError()));1594 1595 /* register the phantom device to prepare for install */1596 ok = SetupDiCallClassInstaller (DIF_REGISTERDEVICE, hDeviceInfo,1597 &DeviceInfoData);1598 if (!ok)1599 SetErrBreak (("SetupDiCallClassInstaller failed (0x%08X)",1600 GetLastError()));1601 1602 /* registered, but remove if errors occur in the following code */1603 registered = TRUE;1604 1605 /* ask the installer if we can install the device */1606 ok = SetupDiCallClassInstaller (DIF_ALLOW_INSTALL, hDeviceInfo,1607 &DeviceInfoData);1608 if (!ok)1609 {1610 if (GetLastError() != ERROR_DI_DO_DEFAULT)1611 SetErrBreak (("SetupDiCallClassInstaller (DIF_ALLOW_INSTALL) failed (0x%08X)",1612 GetLastError()));1613 /* that's fine */1614 }1615 1616 /* install the files first */1617 ok = SetupDiCallClassInstaller (DIF_INSTALLDEVICEFILES, hDeviceInfo,1618 &DeviceInfoData);1619 if (!ok)1620 SetErrBreak (("SetupDiCallClassInstaller (DIF_INSTALLDEVICEFILES) failed (0x%08X)",1621 GetLastError()));1622 1623 /* get the device install parameters and disable filecopy */1624 DeviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);1625 ok = SetupDiGetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,1626 &DeviceInstallParams);1627 if (ok)1628 {1629 DeviceInstallParams.Flags |= DI_NOFILECOPY;1630 ok = SetupDiSetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,1631 &DeviceInstallParams);1632 if (!ok)1633 SetErrBreak (("SetupDiSetDeviceInstallParams failed (0x%08X)",1634 GetLastError()));1635 }1636 1637 /*1638 * Register any device-specific co-installers for this device,1639 */1640 1641 ok = SetupDiCallClassInstaller (DIF_REGISTER_COINSTALLERS,1642 hDeviceInfo,1643 &DeviceInfoData);1644 if (!ok)1645 SetErrBreak (("SetupDiCallClassInstaller (DIF_REGISTER_COINSTALLERS) failed (0x%08X)",1646 GetLastError()));1647 1648 /*1649 * install any installer-specified interfaces.1650 * and then do the real install1651 */1652 ok = SetupDiCallClassInstaller (DIF_INSTALLINTERFACES,1653 hDeviceInfo,1654 &DeviceInfoData);1655 if (!ok)1656 SetErrBreak (("SetupDiCallClassInstaller (DIF_INSTALLINTERFACES) failed (0x%08X)",1657 GetLastError()));1658 1659 ok = SetupDiCallClassInstaller (DIF_INSTALLDEVICE,1660 hDeviceInfo,1661 &DeviceInfoData);1662 if (!ok)1663 SetErrBreak (("SetupDiCallClassInstaller (DIF_INSTALLDEVICE) failed (0x%08X)",1664 GetLastError()));1665 1666 /* Figure out NetCfgInstanceId */1667 hkey = SetupDiOpenDevRegKey (hDeviceInfo,1668 &DeviceInfoData,1669 DICS_FLAG_GLOBAL,1670 0,1671 DIREG_DRV,1672 KEY_READ);1673 if (hkey == INVALID_HANDLE_VALUE)1674 SetErrBreak (("SetupDiOpenDevRegKey failed (0x%08X)",1675 GetLastError()));1676 1677 cbSize = sizeof (pWCfgGuidString);1678 DWORD ret;1679 ret = RegQueryValueExW (hkey, L"NetCfgInstanceId", NULL,1680 &dwValueType, (LPBYTE) pWCfgGuidString, &cbSize);1681 1682 RegCloseKey (hkey);1683 1684 if(!SetupDiGetDeviceRegistryPropertyW(hDeviceInfo, &DeviceInfoData,1685 SPDRP_FRIENDLYNAME , /* IN DWORD Property,*/1686 NULL, /*OUT PDWORD PropertyRegDataType, OPTIONAL*/1687 (PBYTE)DevName, /*OUT PBYTE PropertyBuffer,*/1688 sizeof(DevName), /* IN DWORD PropertyBufferSize,*/1689 NULL /*OUT PDWORD RequiredSize OPTIONAL*/1690 ))1691 {1692 int err = GetLastError();1693 if(err != ERROR_INVALID_DATA)1694 {1695 SetErrBreak (("SetupDiGetDeviceRegistryProperty failed (0x%08X)",1696 err));1697 }1698 1699 if(!SetupDiGetDeviceRegistryPropertyW(hDeviceInfo, &DeviceInfoData,1700 SPDRP_DEVICEDESC , /* IN DWORD Property,*/1701 NULL, /*OUT PDWORD PropertyRegDataType, OPTIONAL*/1702 (PBYTE)DevName, /*OUT PBYTE PropertyBuffer,*/1703 sizeof(DevName), /* IN DWORD PropertyBufferSize,*/1704 NULL /*OUT PDWORD RequiredSize OPTIONAL*/1705 ))1706 {1707 err = GetLastError();1708 SetErrBreak (("SetupDiGetDeviceRegistryProperty failed (0x%08X)",1709 err));1710 }1711 }1712 }1713 while (0);1714 1715 /*1716 * cleanup1717 */1718 1719 if (hDeviceInfo != INVALID_HANDLE_VALUE)1720 {1721 /* an error has occured, but the device is registered, we must remove it */1722 if (ret != 0 && registered)1723 SetupDiCallClassInstaller (DIF_REMOVE, hDeviceInfo, &DeviceInfoData);1724 1725 found = SetupDiDeleteDeviceInfo (hDeviceInfo, &DeviceInfoData);1726 1727 /* destroy the driver info list */1728 if (destroyList)1729 SetupDiDestroyDriverInfoList (hDeviceInfo, &DeviceInfoData,1730 SPDIT_CLASSDRIVER);1731 /* clean up the device info set */1732 SetupDiDestroyDeviceInfoList (hDeviceInfo);1733 }1734 1735 /* return the network connection GUID on success */1736 if (RT_SUCCESS (vrc))1737 {1738 Bstr str(DevName);1739 str.detachTo(pName);1740 1741 WCHAR ConnectoinName[128];1742 ULONG cbName = sizeof(ConnectoinName);1743 1744 HRESULT hr = VBoxNetCfgWinGenHostonlyConnectionName (DevName, ConnectoinName, &cbName);1745 if(hr == S_OK)1746 {1747 hr = VBoxNetCfgWinRenameConnection (pWCfgGuidString, ConnectoinName);1748 }1749 1750 /* remove the curly bracket at the end */1751 pWCfgGuidString [wcslen (pWCfgGuidString) - 1] = L'\0';1752 LogFlowFunc (("Network connection GUID string = {%ls}\n", pWCfgGuidString + 1));1753 1754 aGUID = Guid (Utf8Str (pWCfgGuidString + 1));1755 LogFlowFunc (("Network connection GUID = {%RTuuid}\n", aGUID.raw()));1756 Assert (!aGUID.isEmpty());1757 }1758 1759 LogFlowFunc (("vrc=%Rrc\n", vrc));1760 LogFlowFuncLeave();1761 return vrc;1762 }1763 1764 /* static */1765 static int removeNetworkInterface (SVCHlpClient *aClient,1766 const Guid &aGUID,1767 Utf8Str &aErrMsg)1768 {1769 LogFlowFuncEnter();1770 LogFlowFunc (("Network connection GUID = {%RTuuid}\n", aGUID.raw()));1771 1772 AssertReturn (aClient, VERR_INVALID_POINTER);1773 AssertReturn (!aGUID.isEmpty(), VERR_INVALID_PARAMETER);1774 1775 int vrc = VINF_SUCCESS;1776 1777 do1778 {1779 TCHAR lszPnPInstanceId [512] = {0};1780 1781 /* We have to find the device instance ID through a registry search */1782 1783 HKEY hkeyNetwork = 0;1784 HKEY hkeyConnection = 0;1785 1786 do1787 {1788 char strRegLocation [256];1789 sprintf (strRegLocation,1790 "SYSTEM\\CurrentControlSet\\Control\\Network\\"1791 "{4D36E972-E325-11CE-BFC1-08002BE10318}\\{%s}",1792 aGUID.toString().raw());1793 LONG status;1794 status = RegOpenKeyExA (HKEY_LOCAL_MACHINE, strRegLocation, 0,1795 KEY_READ, &hkeyNetwork);1796 if ((status != ERROR_SUCCESS) || !hkeyNetwork)1797 SetErrBreak ((1798 "Host interface network is not found in registry (%s) [1]",1799 strRegLocation));1800 1801 status = RegOpenKeyExA (hkeyNetwork, "Connection", 0,1802 KEY_READ, &hkeyConnection);1803 if ((status != ERROR_SUCCESS) || !hkeyConnection)1804 SetErrBreak ((1805 "Host interface network is not found in registry (%s) [2]",1806 strRegLocation));1807 1808 DWORD len = sizeof (lszPnPInstanceId);1809 DWORD dwKeyType;1810 status = RegQueryValueExW (hkeyConnection, L"PnPInstanceID", NULL,1811 &dwKeyType, (LPBYTE) lszPnPInstanceId, &len);1812 if ((status != ERROR_SUCCESS) || (dwKeyType != REG_SZ))1813 SetErrBreak ((1814 "Host interface network is not found in registry (%s) [3]",1815 strRegLocation));1816 }1817 while (0);1818 1819 if (hkeyConnection)1820 RegCloseKey (hkeyConnection);1821 if (hkeyNetwork)1822 RegCloseKey (hkeyNetwork);1823 1824 if (RT_FAILURE (vrc))1825 break;1826 1827 /*1828 * Now we are going to enumerate all network devices and1829 * wait until we encounter the right device instance ID1830 */1831 1832 HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE;1833 1834 do1835 {1836 BOOL ok;1837 DWORD ret = 0;1838 GUID netGuid;1839 SP_DEVINFO_DATA DeviceInfoData;1840 DWORD index = 0;1841 BOOL found = FALSE;1842 DWORD size = 0;1843 1844 /* initialize the structure size */1845 DeviceInfoData.cbSize = sizeof (SP_DEVINFO_DATA);1846 1847 /* copy the net class GUID */1848 memcpy (&netGuid, &GUID_DEVCLASS_NET, sizeof (GUID_DEVCLASS_NET));1849 1850 /* return a device info set contains all installed devices of the Net class */1851 hDeviceInfo = SetupDiGetClassDevs (&netGuid, NULL, NULL, DIGCF_PRESENT);1852 1853 if (hDeviceInfo == INVALID_HANDLE_VALUE)1854 SetErrBreak (("SetupDiGetClassDevs failed (0x%08X)", GetLastError()));1855 1856 /* enumerate the driver info list */1857 while (TRUE)1858 {1859 TCHAR *deviceHwid;1860 1861 ok = SetupDiEnumDeviceInfo (hDeviceInfo, index, &DeviceInfoData);1862 1863 if (!ok)1864 {1865 if (GetLastError() == ERROR_NO_MORE_ITEMS)1866 break;1867 else1868 {1869 index++;1870 continue;1871 }1872 }1873 1874 /* try to get the hardware ID registry property */1875 ok = SetupDiGetDeviceRegistryProperty (hDeviceInfo,1876 &DeviceInfoData,1877 SPDRP_HARDWAREID,1878 NULL,1879 NULL,1880 0,1881 &size);1882 if (!ok)1883 {1884 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)1885 {1886 index++;1887 continue;1888 }1889 1890 deviceHwid = (TCHAR *) malloc (size);1891 ok = SetupDiGetDeviceRegistryProperty (hDeviceInfo,1892 &DeviceInfoData,1893 SPDRP_HARDWAREID,1894 NULL,1895 (PBYTE)deviceHwid,1896 size,1897 NULL);1898 if (!ok)1899 {1900 free (deviceHwid);1901 deviceHwid = NULL;1902 index++;1903 continue;1904 }1905 }1906 else1907 {1908 /* something is wrong. This shouldn't have worked with a NULL buffer */1909 index++;1910 continue;1911 }1912 1913 for (TCHAR *t = deviceHwid;1914 t && *t && t < &deviceHwid[size / sizeof(TCHAR)];1915 t += _tcslen (t) + 1)1916 {1917 if (!_tcsicmp (DRIVERHWID, t))1918 {1919 /* get the device instance ID */1920 TCHAR devID [MAX_DEVICE_ID_LEN];1921 if (CM_Get_Device_ID(DeviceInfoData.DevInst,1922 devID, MAX_DEVICE_ID_LEN, 0) == CR_SUCCESS)1923 {1924 /* compare to what we determined before */1925 if (wcscmp(devID, lszPnPInstanceId) == 0)1926 {1927 found = TRUE;1928 break;1929 }1930 }1931 }1932 }1933 1934 if (deviceHwid)1935 {1936 free (deviceHwid);1937 deviceHwid = NULL;1938 }1939 1940 if (found)1941 break;1942 1943 index++;1944 }1945 1946 if (found == FALSE)1947 SetErrBreak (("Host Interface Network driver not found (0x%08X)",1948 GetLastError()));1949 1950 ok = SetupDiSetSelectedDevice (hDeviceInfo, &DeviceInfoData);1951 if (!ok)1952 SetErrBreak (("SetupDiSetSelectedDevice failed (0x%08X)",1953 GetLastError()));1954 1955 ok = SetupDiCallClassInstaller (DIF_REMOVE, hDeviceInfo, &DeviceInfoData);1956 if (!ok)1957 SetErrBreak (("SetupDiCallClassInstaller (DIF_REMOVE) failed (0x%08X)",1958 GetLastError()));1959 }1960 while (0);1961 1962 /* clean up the device info set */1963 if (hDeviceInfo != INVALID_HANDLE_VALUE)1964 SetupDiDestroyDeviceInfoList (hDeviceInfo);1965 1966 if (RT_FAILURE (vrc))1967 break;1968 }1969 while (0);1970 1971 LogFlowFunc (("vrc=%Rrc\n", vrc));1972 LogFlowFuncLeave();1973 return vrc;1974 }1975 1976 #undef SetErrBreak1977 1978 1356 int netIfNetworkInterfaceHelperServer (SVCHlpClient *aClient, 1979 1357 SVCHlpMsg::Code aMsgCode) … … 1985 1363 1986 1364 int vrc = VINF_SUCCESS; 1365 HRESULT hrc; 1987 1366 1988 1367 switch (aMsgCode) … … 1999 1378 Utf8Str errMsg; 2000 1379 Bstr name; 2001 vrc = createNetworkInterface (aClient, name.asOutParam(), guid, errMsg); 2002 2003 if (RT_SUCCESS (vrc)) 1380 Bstr bstrErr; 1381 1382 hrc = VBoxNetCfgWinCreateHostOnlyNetworkInterface (guid.asOutParam(), name.asOutParam(), bstrErr.asOutParam()); 1383 1384 if (hrc == S_OK) 2004 1385 { 2005 1386 /* write success followed by GUID */ … … 2013 1394 else 2014 1395 { 1396 vrc = VERR_GENERAL_FAILURE; 1397 errMsg = Utf8Str(bstrErr); 2015 1398 /* write failure followed by error message */ 2016 1399 if (errMsg.isEmpty()) … … 2029 1412 2030 1413 Guid guid; 1414 Bstr bstrErr; 1415 2031 1416 vrc = aClient->read (guid); 2032 1417 if (RT_FAILURE (vrc)) break; 2033 1418 2034 1419 Utf8Str errMsg; 2035 vrc = removeNetworkInterface (aClient, guid, errMsg);2036 2037 if ( RT_SUCCESS (vrc))1420 hrc = VBoxNetCfgWinRemoveHostOnlyNetworkInterface ((const GUID*)guid.raw(), bstrErr.asOutParam()); 1421 1422 if (hrc == S_OK) 2038 1423 { 2039 1424 /* write parameter-less success */ … … 2043 1428 else 2044 1429 { 1430 vrc = VERR_GENERAL_FAILURE; 1431 errMsg = Utf8Str(bstrErr); 2045 1432 /* write failure followed by error message */ 2046 1433 if (errMsg.isEmpty()) … … 2069 1456 2070 1457 Utf8Str errMsg; 2071 vrc = netIfEnableStaticIpConfigV6 (guid, Bstr(ipV6), maskLengthV6);1458 vrc = VERR_NOT_IMPLEMENTED; 2072 1459 2073 1460 if (RT_SUCCESS (vrc)) … … 2104 1491 2105 1492 Utf8Str errMsg; 2106 vrc = netIfEnableStaticIpConfig (guid, ip, mask);2107 2108 if ( RT_SUCCESS (vrc))1493 hrc = VBoxNetCfgWinEnableStaticIpConfig ((const GUID *)guid.raw(), ip, mask); 1494 1495 if (hrc == S_OK) 2109 1496 { 2110 1497 /* write success followed by GUID */ … … 2114 1501 else 2115 1502 { 1503 vrc = VERR_GENERAL_FAILURE; 2116 1504 /* write failure followed by error message */ 2117 1505 if (errMsg.isEmpty()) … … 2134 1522 2135 1523 Utf8Str errMsg; 2136 vrc = netIfEnableDynamicIpConfig (guid);2137 2138 if ( RT_SUCCESS (vrc))1524 hrc = VBoxNetCfgWinEnableDynamicIpConfig ((const GUID *)guid.raw()); 1525 1526 if (hrc == S_OK) 2139 1527 { 2140 1528 /* write success followed by GUID */ … … 2144 1532 else 2145 1533 { 1534 vrc = VERR_GENERAL_FAILURE; 2146 1535 /* write failure followed by error message */ 2147 1536 if (errMsg.isEmpty()) … … 2164 1553 2165 1554 Utf8Str errMsg; 2166 vrc = netIfDhcpRediscover (guid);2167 2168 if ( RT_SUCCESS (vrc))1555 hrc = VBoxNetCfgWinDhcpRediscover ((const GUID *)guid.raw()); 1556 1557 if (hrc == S_OK) 2169 1558 { 2170 1559 /* write success followed by GUID */ … … 2174 1563 else 2175 1564 { 1565 vrc = VERR_GENERAL_FAILURE; 2176 1566 /* write failure followed by error message */ 2177 1567 if (errMsg.isEmpty())
Note:
See TracChangeset
for help on using the changeset viewer.