Changeset 22485 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/win
- Timestamp:
- Aug 26, 2009 6:57:05 PM (15 years ago)
- Location:
- trunk/src/VBox/HostDrivers/VBoxNetFlt/win
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/NetAdpUninstall.cpp
r21343 r22485 23 23 #include <stdio.h> 24 24 25 #include <devguid.h> 26 27 25 28 static VOID winNetCfgLogger (LPCWSTR szString) 26 29 { … … 30 33 static int UninstallNetAdp() 31 34 { 32 int r = 0;35 int r = 1; 33 36 VBoxNetCfgWinSetLogging(winNetCfgLogger); 34 37 … … 41 44 if(hr == S_OK) 42 45 { 43 printf("uninstalled successfully\n"); 46 hr = VBoxNetCfgWinUninstallInfs (&GUID_DEVCLASS_NET, L"sun_VBoxNetAdp"); 47 if(hr == S_OK) 48 { 49 printf("uninstalled successfully\n"); 50 } 51 else 52 { 53 printf("uninstalled successfully, but failed to remove infs\n"); 54 } 55 r = 0; 44 56 } 45 57 else … … 53 65 { 54 66 wprintf(L"Error initializing COM (0x%x)\n", hr); 55 r = 1;56 67 } 57 68 -
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/WinNetConfig.cpp
r22472 r22485 83 83 typedef bool (*ENUMERATION_CALLBACK) (LPWSTR pFileName, PVOID pContext); 84 84 85 static HRESULT vboxNetCfgWinCollectInfs(LPCWSTR pPnPId) 85 class VBoxNetCfgStringList 86 { 87 public: 88 VBoxNetCfgStringList(int aSize); 89 90 ~VBoxNetCfgStringList(); 91 92 HRESULT add(LPWSTR pStr); 93 94 int size() {return mSize;} 95 96 LPWSTR get(int i) {return maList[i];} 97 private: 98 HRESULT resize(int newSize); 99 100 LPWSTR *maList; 101 int mBufSize; 102 int mSize; 103 }; 104 105 VBoxNetCfgStringList::VBoxNetCfgStringList(int aSize) 106 { 107 maList = (LPWSTR*)CoTaskMemAlloc( sizeof(maList[0]) * aSize); 108 mBufSize = aSize; 109 mSize = 0; 110 } 111 112 VBoxNetCfgStringList::~VBoxNetCfgStringList() 113 { 114 if(!mBufSize) 115 return; 116 117 for(int i = 0; i < mSize; ++i) 118 { 119 CoTaskMemFree(maList[i]); 120 } 121 122 CoTaskMemFree(maList); 123 } 124 125 HRESULT VBoxNetCfgStringList::add(LPWSTR pStr) 126 { 127 if(mSize == mBufSize) 128 { 129 int hr = resize(mBufSize+10); 130 if(SUCCEEDED(hr)) 131 return hr; 132 } 133 size_t cStr = wcslen(pStr) + 1; 134 LPWSTR str = (LPWSTR)CoTaskMemAlloc( sizeof(maList[0][0]) * cStr); 135 memcpy(str, pStr, sizeof(maList[0][0]) * cStr); 136 maList[mSize] = str; 137 ++mSize; 138 return S_OK; 139 } 140 141 HRESULT VBoxNetCfgStringList::resize(int newSize) 142 { 143 Assert(newSize >= mSize); 144 if(newSize < mSize) 145 return E_FAIL; 146 LPWSTR* pOld = maList; 147 maList = (LPWSTR*)CoTaskMemAlloc( sizeof(maList[0]) * newSize); 148 mBufSize = newSize; 149 memcpy(maList, pOld, mSize*sizeof(maList[0])); 150 CoTaskMemFree(pOld); 151 return S_OK; 152 } 153 154 static HRESULT vboxNetCfgWinCollectInfs(const GUID * pGuid, LPCWSTR pPnPId, VBoxNetCfgStringList & list) 86 155 { 87 156 DWORD winEr = ERROR_SUCCESS; 157 int counter = 0; 88 158 HDEVINFO hDevInfo = SetupDiCreateDeviceInfoList( 89 &GUID_DEVCLASS_NETSERVICE, /* IN LPGUID ClassGuid, OPTIONAL */159 pGuid, /* IN LPGUID ClassGuid, OPTIONAL */ 90 160 NULL /*IN HWND hwndParent OPTIONAL */ 91 161 ); … … 124 194 for(WCHAR * pHwId = pDrvDetail->HardwareID; pHwId && *pHwId && pHwId < (TCHAR*)(DetailBuf + sizeof(DetailBuf)/sizeof(DetailBuf[0])) ;pHwId += _tcslen(pHwId) + 1) 125 195 { 126 //TODO: 196 if(!wcsicmp(pHwId, pPnPId)) 197 { 198 Assert(pDrvDetail->InfFileName[0]); 199 if(pDrvDetail->InfFileName) 200 { 201 list.add(pDrvDetail->InfFileName); 202 } 203 } 127 204 } 128 205 } … … 321 398 } 322 399 323 //VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinUninstallInfs (LPCWSTR pPnPId)324 //{325 // std::list<std::wstring> InfList;326 // HRESULT hr = vboxNetCfgWinCollectInfs(pPnPId, &InfList);327 //if(hr == S_OK)328 //{329 // std::list <std::wstring>::iterator it;330 // for (it = InfList.begin(); it != InfList.end(); ++it)331 //{332 // Log(L"inf : %s\n", (*it).c_str());333 //}334 //}335 //return hr;336 //}400 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinUninstallInfs (const GUID * pGuid, LPCWSTR pPnPId) 401 { 402 VBoxNetCfgStringList list(128); 403 HRESULT hr = vboxNetCfgWinCollectInfs(pGuid, pPnPId, list); 404 if(hr == S_OK) 405 { 406 int size = list.size(); 407 for (int i = 0; i < size; ++i) 408 { 409 Log(L"inf : %s\n", list.get(i)); 410 } 411 } 412 return hr; 413 } 337 414 338 415 static HRESULT vboxNetCfgWinEnumFiles(LPCWSTR pPattern, ENUMERATION_CALLBACK pCallback, PVOID pContext) … … 1555 1632 HRESULT hr = S_OK; 1556 1633 SP_REMOVEDEVICE_PARAMS rmdParams; 1557 SP_DEVINSTALL_PARAMS devParams;1558 1634 rmdParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); 1559 1635 rmdParams.ClassInstallHeader.InstallFunction = DIF_REMOVE; … … 1562 1638 if(SetupDiSetClassInstallParams(hDevInfo,pDev,&rmdParams.ClassInstallHeader,sizeof(rmdParams))) 1563 1639 { 1564 if(SetupDiCallClassInstaller(DIF_REMOVE,hDevInfo,pDev)) 1565 { 1566 /* 1567 * see if device needs reboot 1568 */ 1569 devParams.cbSize = sizeof(devParams); 1570 if(SetupDiGetDeviceInstallParams(hDevInfo,pDev,&devParams)) 1571 { 1572 if(devParams.Flags & (DI_NEEDRESTART|DI_NEEDREBOOT)) 1640 if(SetupDiSetSelectedDevice (hDevInfo, pDev)) 1641 { 1642 if(SetupDiCallClassInstaller(DIF_REMOVE,hDevInfo,pDev)) 1643 { 1644 SP_DEVINSTALL_PARAMS devParams; 1645 /* 1646 * see if device needs reboot 1647 */ 1648 devParams.cbSize = sizeof(devParams); 1649 if(SetupDiGetDeviceInstallParams(hDevInfo,pDev,&devParams)) 1650 { 1651 if(devParams.Flags & (DI_NEEDRESTART|DI_NEEDREBOOT)) 1652 { 1653 // 1654 // reboot required 1655 // 1656 hr = S_FALSE; 1657 Log(L"vboxNetCfgWinRemoveAllNetDevicesOfIdCallback: !!!REBOOT REQUIRED!!!\n", winEr); 1658 } 1659 } 1660 else 1573 1661 { 1574 1662 // 1575 // reboot required1663 // appears to have succeeded 1576 1664 // 1577 hr = S_FALSE;1578 1665 } 1579 1666 } 1580 1667 else 1581 1668 { 1582 //1583 // appears to have succeeded1584 //1669 winEr = GetLastError(); 1670 Log(L"vboxNetCfgWinRemoveAllNetDevicesOfIdCallback: SetupDiCallClassInstaller failed (0x%08X)\n", winEr); 1671 hr = HRESULT_FROM_WIN32(winEr); 1585 1672 } 1586 1673 } … … 1588 1675 { 1589 1676 winEr = GetLastError(); 1677 Log(L"vboxNetCfgWinRemoveAllNetDevicesOfIdCallback: SetupDiSetSelectedDevice failed (0x%08X)\n", winEr); 1590 1678 hr = HRESULT_FROM_WIN32(winEr); 1591 1679 } … … 1677 1765 if(!wcsnicmp(pCurId, pPnPId, cPnPId)) 1678 1766 { 1767 1679 1768 if(!callback(hDevInfo,&Dev,pContext)) 1680 1769 break;
Note:
See TracChangeset
for help on using the changeset viewer.