Changeset 25385 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/win/WinNetConfig.cpp
- Timestamp:
- Dec 15, 2009 9:43:23 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/win/WinNetConfig.cpp
r24280 r25385 2306 2306 } 2307 2307 2308 static BOOL vboxNetCfgWinListUpperBindings (IN INetCfg *pNc, IN INetCfgComponent *pNcc, PVOID pContext) 2309 { 2310 INetCfgComponentBindings *pNccb = NULL; 2311 IEnumNetCfgBindingPath *pEnumNccbp; 2312 GUID *pGuid = (GUID*)pContext; 2313 HRESULT hr; 2314 LPWSTR pszwCompDisplayName; 2315 2316 hr = pNcc->GetDisplayName(&pszwCompDisplayName); 2317 Assert(hr == S_OK); 2318 if ( hr == S_OK ) 2319 { 2320 Log(L" enumerating bindings for component (%s)\n", pszwCompDisplayName); 2321 /* Get component's binding. */ 2322 hr = pNcc->QueryInterface( IID_INetCfgComponentBindings, 2323 (PVOID *)&pNccb ); 2324 Assert(hr == S_OK); 2325 if ( hr == S_OK ) 2326 { 2327 /* Get binding path enumerator reference. */ 2328 hr = pNccb->EnumBindingPaths(EBP_ABOVE, &pEnumNccbp); 2329 Assert(hr == S_OK); 2330 if(hr == S_OK) 2331 { 2332 INetCfgBindingPath *pNccbp; 2333 hr = pEnumNccbp->Reset(); 2334 Assert(hr == S_OK); 2335 do 2336 { 2337 hr = VBoxNetCfgWinGetNextBindingPath(pEnumNccbp, &pNccbp); 2338 Assert(hr == S_OK || hr == S_FALSE); 2339 if(hr == S_OK) 2340 { 2341 LPWSTR pszwPathToken; 2342 hr = pNccbp->GetPathToken(&pszwPathToken); 2343 Assert(hr == S_OK); 2344 if(hr == S_OK) 2345 { 2346 Log(L" enumerating bp (%s), enabled(0x%x)\n", pszwPathToken, pNccbp->IsEnabled()); 2347 IEnumNetCfgBindingInterface *pEnumNcbi; 2348 hr = VBoxNetCfgWinGetBindingInterfaceEnum(pNccbp, &pEnumNcbi); 2349 Assert(hr == S_OK); 2350 if ( hr == S_OK ) 2351 { 2352 INetCfgBindingInterface *pNcbi; 2353 hr = pEnumNcbi->Reset(); 2354 Assert(hr == S_OK); 2355 do 2356 { 2357 hr = VBoxNetCfgWinGetNextBindingInterface(pEnumNcbi, &pNcbi); 2358 Assert(hr == S_OK || hr == S_FALSE); 2359 if(hr == S_OK) 2360 { 2361 LPWSTR pszwInterfaceName; 2362 hr = pNcbi->GetName(&pszwInterfaceName); 2363 if(hr == S_OK) 2364 { 2365 Log(L" enumerating bi (%s)\n", pszwInterfaceName); 2366 INetCfgComponent * pNccBoud; 2367 hr = pNcbi->GetUpperComponent(&pNccBoud); 2368 Assert(hr == S_OK); 2369 if(hr == S_OK) 2370 { 2371 LPWSTR pszwDisplayName; 2372 hr = pNccBoud->GetDisplayName(&pszwDisplayName); 2373 Assert(hr == S_OK); 2374 if(hr == S_OK) 2375 { 2376 Log(L" name (%s)\n", pszwDisplayName); 2377 CoTaskMemFree(pszwDisplayName); 2378 } 2379 else 2380 { 2381 Log(L" ERROR getting name (0x%x)\n", hr); 2382 } 2383 2384 VBoxNetCfgWinReleaseRef(pNccBoud); 2385 } 2386 VBoxNetCfgWinReleaseRef(pNcbi); 2387 } 2388 else 2389 { 2390 Log(L" ERROR getting bi name (0x%x)\n", hr); 2391 } 2392 } 2393 else 2394 { 2395 if(hr == S_FALSE) 2396 { 2397 hr = S_OK; 2398 break; 2399 } 2400 else 2401 { 2402 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: VBoxNetCfgWinGetNextBindingInterface failed, hr (0x%x)\n", hr); 2403 } 2404 break; 2405 } 2406 } while(true); 2407 VBoxNetCfgWinReleaseRef(pEnumNcbi); 2408 } 2409 else 2410 { 2411 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: VBoxNetCfgWinGetBindingInterfaceEnum failed, hr (0x%x)\n", hr); 2412 } 2413 CoTaskMemFree(pszwPathToken); 2414 } 2415 else 2416 { 2417 Log(L" ERROR getting bp name (0x%x)\n", hr); 2418 } 2419 2420 VBoxNetCfgWinReleaseRef(pNccbp); 2421 } 2422 else 2423 { 2424 if(hr = S_FALSE) 2425 { 2426 hr = S_OK; 2427 break; 2428 } 2429 else 2430 { 2431 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: VBoxNetCfgWinGetNextBindingPath failed, hr (0x%x)\n", hr); 2432 } 2433 break; 2434 } 2435 } while(true); 2436 2437 VBoxNetCfgWinReleaseRef(pEnumNccbp); 2438 } 2439 else 2440 { 2441 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: EnumBindingPaths failed, hr (0x%x)\n", hr); 2442 } 2443 2444 VBoxNetCfgWinReleaseRef( pNccb ); 2445 } 2446 else 2447 { 2448 Log(L"vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority: QueryInterface for IID_INetCfgComponentBindings failed, hr (0x%x)\n", hr); 2449 } 2450 2451 CoTaskMemFree(pszwCompDisplayName); 2452 } 2453 else 2454 { 2455 Log(L" ERROR getting component name (0x%x)\n", hr); 2456 } 2457 2458 return true; 2459 } 2460 2308 2461 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface (LPCWSTR pInfPath, bool bIsInfPathFile, /* <- input params */ 2309 2462 GUID *pGuid, BSTR *lppszName, BSTR *pErrMsg) /* <- output params */ … … 2767 2920 2768 2921 #undef SetErrBreak 2922 2923 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinEnumUpperBindings () 2924 { 2925 INetCfg *pNc; 2926 LPWSTR lpszApp = NULL; 2927 HRESULT hr = VBoxNetCfgWinQueryINetCfgEx( FALSE, 2928 L"VirtualBox Host-Only Creation", 2929 30000, /* on Vista we often get 6to4svc.dll holding the lock, wait for 30 sec, */ 2930 &pNc, /* TODO: special handling for 6to4svc.dll ???, i.e. several retrieves */ 2931 &lpszApp ); 2932 Assert(hr == S_OK); 2933 if(hr == S_OK) 2934 { 2935 Log(L"Enumerating Net\n"); 2936 hr = vboxNetCfgWinEnumNetCfgComponents(pNc, 2937 &GUID_DEVCLASS_NET, 2938 vboxNetCfgWinListUpperBindings, 2939 NULL); 2940 Assert(hr == S_OK); 2941 2942 Log(L"Enumerating NetService\n"); 2943 hr = vboxNetCfgWinEnumNetCfgComponents(pNc, 2944 &GUID_DEVCLASS_NETSERVICE, 2945 vboxNetCfgWinListUpperBindings, 2946 NULL); 2947 Assert(hr == S_OK); 2948 2949 Log(L"Enumerating NetTrans\n"); 2950 hr = vboxNetCfgWinEnumNetCfgComponents(pNc, 2951 &GUID_DEVCLASS_NETTRANS, 2952 vboxNetCfgWinListUpperBindings, 2953 NULL); 2954 Assert(hr == S_OK); 2955 2956 Log(L"Enumerating NetClient\n"); 2957 hr = vboxNetCfgWinEnumNetCfgComponents(pNc, 2958 &GUID_DEVCLASS_NETCLIENT, 2959 vboxNetCfgWinListUpperBindings, 2960 NULL); 2961 Assert(hr == S_OK); 2962 2963 if(hr == S_OK) 2964 { 2965 hr = pNc->Apply(); 2966 Assert(hr == S_OK); 2967 } 2968 2969 VBoxNetCfgWinReleaseINetCfg(pNc, FALSE); 2970 } 2971 else if(hr == NETCFG_E_NO_WRITE_LOCK && lpszApp) 2972 { 2973 Log(L"VBoxNetCfgWinCreateHostOnlyNetworkInterface: app %s is holding the lock, failed\n", lpszApp); 2974 CoTaskMemFree(lpszApp); 2975 } 2976 else 2977 { 2978 Log(L"VBoxNetCfgWinCreateHostOnlyNetworkInterface: VBoxNetCfgWinQueryINetCfgEx failed, hr 0x%x\n", hr); 2979 } 2980 2981 return hr; 2982 } 2983 2769 2984 2770 2985 #define VBOX_CONNECTION_NAME L"VirtualBox Host-Only Network"
Note:
See TracChangeset
for help on using the changeset viewer.