Changeset 48641 in vbox
- Timestamp:
- Sep 23, 2013 4:08:45 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp
r46593 r48641 397 397 } 398 398 399 /* 400 * Forward declarations of functions used in vboxNetCfgWinRemoveAllNetDevicesOfIdCallback. 401 */ 402 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGenHostonlyConnectionName(PCWSTR DevName, WCHAR *pBuf, PULONG pcbBuf); 403 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRenameConnection (LPWSTR pGuid, PCWSTR NewName); 404 399 405 static BOOL vboxNetCfgWinRemoveAllNetDevicesOfIdCallback(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext) 400 406 { 401 407 HRESULT hr = S_OK; 402 408 SP_REMOVEDEVICE_PARAMS rmdParams; 409 WCHAR pWCfgGuidString[50] = {L''}; 403 410 404 411 rmdParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER); … … 411 418 if (SetupDiSetSelectedDevice (hDevInfo, pDev)) 412 419 { 420 /* Figure out NetCfgInstanceId */ 421 HKEY hkey = SetupDiOpenDevRegKey(hDevInfo, 422 pDev, 423 DICS_FLAG_GLOBAL, 424 0, 425 DIREG_DRV, 426 KEY_READ); 427 if (hkey == INVALID_HANDLE_VALUE) 428 NonStandardLogFlow(("SetupDiOpenDevRegKey failed (0x%08X)", GetLastError())); 429 else 430 { 431 DWORD cbSize = sizeof(pWCfgGuidString); 432 DWORD dwValueType; 433 DWORD ret = RegQueryValueExW (hkey, L"NetCfgInstanceId", NULL, 434 &dwValueType, (LPBYTE) pWCfgGuidString, &cbSize); 435 if (ret == ERROR_SUCCESS) 436 { 437 /* Figure out device name */ 438 WCHAR DevName[256], TempName[256]; 439 ULONG cbName = sizeof(TempName); 440 if (SetupDiGetDeviceRegistryPropertyW(hDevInfo, pDev, 441 SPDRP_FRIENDLYNAME , /* IN DWORD Property,*/ 442 NULL, /*OUT PDWORD PropertyRegDataType, OPTIONAL*/ 443 (PBYTE)DevName, /*OUT PBYTE PropertyBuffer,*/ 444 sizeof(DevName), /* IN DWORD PropertyBufferSize,*/ 445 NULL /*OUT PDWORD RequiredSize OPTIONAL*/)) 446 { 447 /* 448 * Rename the connection before removing the device. This will 449 * hopefully prevent an error when we will be attempting 450 * to rename a newly created connection (see @bugref{6740}). 451 */ 452 HRESULT hr_tmp = VBoxNetCfgWinGenHostonlyConnectionName(DevName, TempName, &cbName); 453 wcscat_s(TempName, sizeof(TempName), L" removed"); 454 if (SUCCEEDED(hr)) 455 hr_tmp = VBoxNetCfgWinRenameConnection(pWCfgGuidString, TempName); 456 //NonStandardLogFlow(("VBoxNetCfgWinRenameConnection(%S,%S) => 0x%x\n", pWCfgGuidString, TempName, hr_tmp)); 457 } 458 else 459 { 460 NonStandardLogFlow(("Failed to get 'friendly name' property for %S\n", pWCfgGuidString)); 461 } 462 } 463 else 464 { 465 NonStandardLogFlow(("RegQueryValueExW(L\"NetCfgInstanceId\") failed with %d\n", ret)); 466 } 467 468 RegCloseKey (hkey); 469 } 470 413 471 if (SetupDiCallClassInstaller(DIF_REMOVE,hDevInfo,pDev)) 414 472 {
Note:
See TracChangeset
for help on using the changeset viewer.