Index: trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp
===================================================================
--- trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp	(revision 36487)
+++ trunk/src/VBox/HostDrivers/VBoxNetFlt/win/cfg/VBoxNetCfg.cpp	(revision 37289)
@@ -50,4 +50,5 @@
 static VOID DoLogging(LPCSTR szString, ...);
 #define Log DoLogging
+#define LogFlow(x) DoLogging x
 
 #define DbgLog
@@ -57,26 +58,24 @@
 
 static HRESULT vboxNetCfgWinINetCfgLock(IN INetCfg *pNetCfg,
-                          IN LPCWSTR pszwClientDescription,
-                          IN DWORD cmsTimeout,
-                          OUT LPWSTR *ppszwClientDescription)
+                                        IN LPCWSTR pszwClientDescription,
+                                        IN DWORD cmsTimeout,
+                                        OUT LPWSTR *ppszwClientDescription)
 {
     INetCfgLock *pLock;
     HRESULT hr = pNetCfg->QueryInterface(IID_INetCfgLock, (PVOID*)&pLock);
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": QueryInterface failed, hr (0x%x)\n", hr);
+    if (FAILED(hr))
+    {
+        LogFlow(("QueryInterface failed, hr (0x%x)\n", hr));
         return hr;
     }
 
     hr = pLock->AcquireWriteLock(cmsTimeout, pszwClientDescription, ppszwClientDescription);
-    Assert(hr == S_OK || hr == S_FALSE);
     if (hr == S_FALSE)
     {
-        Log(__FUNCTION__ ": write lock busy\n");
-    }
-    else if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": AcquireWriteLock failed hr (0x%x)\n", hr);
+        LogFlow(("Write lock busy\n"));
+    }
+    else if (FAILED(hr))
+    {
+        LogFlow(("AcquireWriteLock failed, hr (0x%x)\n", hr));
     }
 
@@ -89,17 +88,13 @@
     INetCfgLock *pLock;
     HRESULT hr = pNetCfg->QueryInterface(IID_INetCfgLock, (PVOID*)&pLock);
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": QueryInterface failed, hr (0x%x)\n", hr);
+    if (FAILED(hr))
+    {
+        LogFlow(("QueryInterface failed, hr (0x%x)\n", hr));
         return hr;
     }
 
     hr = pLock->ReleaseWriteLock();
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": ReleaseWriteLock failed hr (0x%x)\n", hr);
-    }
+    if (FAILED(hr))
+        LogFlow(("ReleaseWriteLock failed, hr (0x%x)\n", hr));
 
     pLock->Release();
@@ -108,15 +103,14 @@
 
 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinQueryINetCfg(OUT INetCfg **ppNetCfg,
-                          IN BOOL fGetWriteLock,
-                          IN LPCWSTR pszwClientDescription,
-                          IN DWORD cmsTimeout,
-                          OUT LPWSTR *ppszwClientDescription)
+                                                      IN BOOL fGetWriteLock,
+                                                      IN LPCWSTR pszwClientDescription,
+                                                      IN DWORD cmsTimeout,
+                                                      OUT LPWSTR *ppszwClientDescription)
 {
     INetCfg *pNetCfg;
     HRESULT hr = CoCreateInstance(CLSID_CNetCfg, NULL, CLSCTX_INPROC_SERVER, IID_INetCfg, (PVOID*)&pNetCfg);
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": CoCreateInstance failed, hr (0x%x)\n", hr);
+    if (FAILED(hr))
+    {
+        LogFlow(("CoCreateInstance failed, hr (0x%x)\n", hr));
         return hr;
     }
@@ -125,17 +119,15 @@
     {
         hr = vboxNetCfgWinINetCfgLock(pNetCfg, pszwClientDescription, cmsTimeout, ppszwClientDescription);
-        Assert(hr == S_OK || hr == S_FALSE);
         if (hr == S_FALSE)
         {
-            Log(__FUNCTION__ ": write lock is busy\n", hr);
+            LogFlow(("Write lock is busy\n", hr));
             hr = NETCFG_E_NO_WRITE_LOCK;
         }
     }
 
-    if (hr == S_OK)
+    if (SUCCEEDED(hr))
     {
         hr = pNetCfg->Initialize(NULL);
-        Assert(hr == S_OK);
-        if (hr == S_OK)
+        if (SUCCEEDED(hr))
         {
             *ppNetCfg = pNetCfg;
@@ -143,7 +135,5 @@
         }
         else
-        {
-            Log(__FUNCTION__ ": Initialize failed, hr (0x%x)\n", hr);
-        }
+            LogFlow(("Initialize failed, hr (0x%x)\n", hr));
     }
 
@@ -155,8 +145,7 @@
 {
     HRESULT hr = pNetCfg->Uninitialize();
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": Uninitialize failed, hr (0x%x)\n", hr);
+    if (FAILED(hr))
+    {
+        LogFlow(("Uninitialize failed, hr (0x%x)\n", hr));
         return hr;
     }
@@ -165,9 +154,6 @@
     {
         hr = vboxNetCfgWinINetCfgUnlock(pNetCfg);
-        Assert(hr == S_OK);
-        if (hr != S_OK)
-        {
-            Log(__FUNCTION__ ": vboxNetCfgWinINetCfgUnlock failed, hr (0x%x)\n", hr);
-        }
+        if (FAILED(hr))
+            LogFlow(("vboxNetCfgWinINetCfgUnlock failed, hr (0x%x)\n", hr));
     }
 
@@ -176,28 +162,28 @@
 }
 
-static HRESULT vboxNetCfgWinGetComponentByGuidEnum(IEnumNetCfgComponent *pEnumNcc, IN const GUID * pGuid, OUT INetCfgComponent ** ppNcc)
-{
-    INetCfgComponent * pNcc;
-    GUID NccGuid;
-
+static HRESULT vboxNetCfgWinGetComponentByGuidEnum(IEnumNetCfgComponent *pEnumNcc,
+                                                   IN const GUID *pGuid,
+                                                   OUT INetCfgComponent **ppNcc)
+{
     HRESULT hr = pEnumNcc->Reset();
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__": Reset failed, hr (0x%x)\n", hr);
+    if (FAILED(hr))
+    {
+        LogFlow(("Reset failed, hr (0x%x)\n", hr));
         return hr;
     }
 
+    INetCfgComponent *pNcc;
     while ((hr = pEnumNcc->Next(1, &pNcc, NULL)) == S_OK)
     {
         ULONG uComponentStatus;
         hr = pNcc->GetDeviceStatus(&uComponentStatus);
-        if (hr == S_OK)
+        if (SUCCEEDED(hr))
         {
             if (uComponentStatus == 0)
             {
+                GUID NccGuid;
                 hr = pNcc->GetInstanceGuid(&NccGuid);
-                Assert(hr == S_OK);
-                if (hr == S_OK)
+
+                if (SUCCEEDED(hr))
                 {
                     if (NccGuid == *pGuid)
@@ -209,7 +195,5 @@
                 }
                 else
-                {
-                    Log(__FUNCTION__": GetInstanceGuid failed, hr (0x%x)\n", hr);
-                }
+                    LogFlow(("GetInstanceGuid failed, hr (0x%x)\n", hr));
             }
         }
@@ -217,36 +201,30 @@
         pNcc->Release();
     }
-
-    Assert(hr == S_OK || hr == S_FALSE);
-    return hr;
-}
-
-VBOXNETCFGWIN_DECL(HRESULT)
-VBoxNetCfgWinGetComponentByGuid(IN INetCfg *pNc,
-                                IN const GUID *pguidClass,
-                                IN const GUID * pComponentGuid,
-                                OUT INetCfgComponent **ppncc)
+    return hr;
+}
+
+VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGetComponentByGuid(IN INetCfg *pNc,
+                                                            IN const GUID *pguidClass,
+                                                            IN const GUID * pComponentGuid,
+                                                            OUT INetCfgComponent **ppncc)
 {
     IEnumNetCfgComponent *pEnumNcc;
     HRESULT hr = pNc->EnumComponents(pguidClass, &pEnumNcc);
-    Assert(hr == S_OK);
-    if (hr == S_OK)
+
+    if (SUCCEEDED(hr))
     {
         hr = vboxNetCfgWinGetComponentByGuidEnum(pEnumNcc, pComponentGuid, ppncc);
-        Assert(hr == S_OK || hr == S_FALSE);
         if (hr == S_FALSE)
         {
-            Log(__FUNCTION__": component not found \n");
-        }
-        else if (hr != S_OK)
-        {
-            Log(__FUNCTION__": vboxNetCfgWinGetComponentByGuidEnum failed, hr (0x%x)\n", hr);
+            LogFlow(("Component not found\n"));
+        }
+        else if (FAILED(hr))
+        {
+            LogFlow(("vboxNetCfgWinGetComponentByGuidEnum failed, hr (0x%x)\n", hr));
         }
         pEnumNcc->Release();
     }
     else
-    {
-        Log(__FUNCTION__": EnumComponents failed, hr (0x%x)\n", hr);
-    }
+        LogFlow(("EnumComponents failed, hr (0x%x)\n", hr));
     return hr;
 }
@@ -255,36 +233,31 @@
 {
     HRESULT hr = pNetCfg->QueryNetCfgClass(pguidClass, IID_INetCfgClassSetup, (void**)ppSetup);
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": QueryNetCfgClass failed hr (0x%x)\n", hr);
-    }
+    if (FAILED(hr))
+        LogFlow(("QueryNetCfgClass failed, hr (0x%x)\n", hr));
     return hr;
 }
 
 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinInstallComponent(IN INetCfg *pNetCfg, IN LPCWSTR pszwComponentId, IN const GUID *pguidClass,
-        OUT INetCfgComponent **ppComponent)
+                                                          OUT INetCfgComponent **ppComponent)
 {
     INetCfgClassSetup *pSetup;
     HRESULT hr = vboxNetCfgWinQueryInstaller(pNetCfg, pguidClass, &pSetup);
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": vboxNetCfgWinQueryInstaller failed hr (0x%x)\n", hr);
+    if (FAILED(hr))
+    {
+        LogFlow(("vboxNetCfgWinQueryInstaller failed, hr (0x%x)\n", hr));
         return hr;
     }
 
     OBO_TOKEN Token;
-    memset(&Token, 0, sizeof (Token));
+    ZeroMemory(&Token, sizeof (Token));
     Token.Type = OBO_USER;
 
     hr = pSetup->Install(pszwComponentId, &Token,
-            0,    /* IN DWORD dwSetupFlags */
-            0,    /* IN DWORD dwUpgradeFromBuildNo */
-            NULL, /* IN LPCWSTR pszwAnswerFile */
-            NULL, /* IN LPCWSTR pszwAnswerSections */
-            ppComponent);
-    Assert(hr == S_OK);
-    if (hr == S_OK)
+                         0,    /* IN DWORD dwSetupFlags */
+                         0,    /* IN DWORD dwUpgradeFromBuildNo */
+                         NULL, /* IN LPCWSTR pszwAnswerFile */
+                         NULL, /* IN LPCWSTR pszwAnswerSections */
+                         ppComponent);
+    if (SUCCEEDED(hr))
     {
         /* ignore the apply failure */
@@ -292,12 +265,9 @@
         Assert(tmpHr == S_OK);
         if (tmpHr != S_OK)
-        {
-            Log(__FUNCTION__ ": Apply failed, hr (0x%x)\n", tmpHr);
-        }
+            LogFlow(("Apply failed, hr (0x%x)\n", tmpHr));
     }
     else
-    {
-        Log(__FUNCTION__ ": Install failed hr (0x%x)\n", hr);
-    }
+        LogFlow(("Install failed, hr (0x%x)\n", hr));
+
     pSetup->Release();
     return hr;
@@ -305,37 +275,34 @@
 
 VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinInstallInfAndComponent(IN INetCfg *pNetCfg, IN LPCWSTR pszwComponentId, IN const GUID *pguidClass,
-        IN LPCWSTR * apInfPaths, IN UINT cInfPaths,
-        OUT INetCfgComponent **ppComponent)
+                                                                IN LPCWSTR * apInfPaths, IN UINT cInfPaths,
+                                                                OUT INetCfgComponent **ppComponent)
 {
     HRESULT hr = S_OK;
     UINT i = 0;
 
+    LogFlow(("Installing %u INF files ...\n", cInfPaths));
+
     for (; i < cInfPaths; i++)
     {
+        LogFlow(("Installing INF file \"%ws\" ...\n", apInfPaths[i]));
         hr = VBoxDrvCfgInfInstall(apInfPaths[i]);
-        Assert(hr == S_OK);
-        if (hr != S_OK)
-        {
-            Log(__FUNCTION__ ": VBoxNetCfgWinInfInstall failed hr (0x%x)\n", hr);
+        if (FAILED(hr))
+        {
+            LogFlow(("VBoxNetCfgWinInfInstall failed, hr (0x%x)\n", hr));
             break;
         }
     }
 
-    if (hr == S_OK)
+    if (SUCCEEDED(hr))
     {
         hr = VBoxNetCfgWinInstallComponent(pNetCfg, pszwComponentId, pguidClass, ppComponent);
-        Assert(hr == S_OK);
-        if (hr != S_OK)
-        {
-            Log(__FUNCTION__ ": VBoxNetCfgWinInstallComponent failed hr (0x%x)\n", hr);
-        }
-    }
-
-    if (hr != S_OK)
-    {
-        for (UINT j = i-1; j != 0; j--)
-        {
+        if (FAILED(hr))
+            LogFlow(("VBoxNetCfgWinInstallComponent failed, hr (0x%x)\n", hr));
+    }
+
+    if (FAILED(hr))
+    {
+        for (UINT j = i - 1; j != 0; j--)
             VBoxDrvCfgInfUninstall(apInfPaths[j], 0);
-        }
     }
 
@@ -347,90 +314,80 @@
     GUID GuidClass;
     HRESULT hr = pComponent->GetClassGuid(&GuidClass);
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": GetClassGuid failed hr (0x%x)\n", hr);
+    if (FAILED(hr))
+    {
+        LogFlow(("GetClassGuid failed, hr (0x%x)\n", hr));
         return hr;
     }
 
-    INetCfgClassSetup *pSetup;
+    INetCfgClassSetup *pSetup = NULL;
     hr = vboxNetCfgWinQueryInstaller(pNetCfg, &GuidClass, &pSetup);
-    Assert(hr == S_OK);
-    if (hr != S_OK)
-    {
-        Log(__FUNCTION__ ": vboxNetCfgWinQueryInstaller failed hr (0x%x)\n", hr);
+    if (FAILED(hr))
+    {
+        LogFlow(("vboxNetCfgWinQueryInstaller failed, hr (0x%x)\n", hr));
         return hr;
     }
 
     OBO_TOKEN Token;
-    memset(&Token, 0, sizeof (Token));
+    ZeroMemory(&Token, sizeof(Token));
     Token.Type = OBO_USER;
 
     hr = pSetup->DeInstall(pComponent, &Token, NULL /* OUT LPWSTR *pmszwRefs */);
-    Assert(hr == S_OK);
-    if (hr == S_OK)
-    {
-        HRESULT tmpHr = pNetCfg->Apply();
-        Assert(tmpHr == S_OK);
-        if (tmpHr != S_OK)
-        {
-            Log(__FUNCTION__ ": Apply failed, hr (0x%x)\n", tmpHr);
-        }
+    if (SUCCEEDED(hr))
+    {
+        hr = pNetCfg->Apply();
+        if (FAILED(hr))
+            LogFlow(("Apply failed, hr (0x%x)\n", hr));
     }
     else
-    {
-        Log(__FUNCTION__ ": DeInstall failed hr (0x%x)\n", hr);
-    }
-    pSetup->Release();
-    return hr;
-}
-
-typedef BOOL (*VBOXNETCFGWIN_NETCFGENUM_CALLBACK) (IN INetCfg *pNc, IN INetCfgComponent *pNcc, PVOID pContext);
-
-static HRESULT vboxNetCfgWinEnumNetCfgComponents(IN INetCfg *pNc,
-        IN const GUID *pguidClass,
-        VBOXNETCFGWIN_NETCFGENUM_CALLBACK callback,
-        PVOID pContext)
+        LogFlow(("DeInstall failed, hr (0x%x)\n", hr));
+
+    if (pSetup)
+        pSetup->Release();
+    return hr;
+}
+
+typedef BOOL (*VBOXNETCFGWIN_NETCFGENUM_CALLBACK) (IN INetCfg *pNetCfg, IN INetCfgComponent *pNetCfgComponent, PVOID pContext);
+
+static HRESULT vboxNetCfgWinEnumNetCfgComponents(IN INetCfg *pNetCfg,
+                                                 IN const GUID *pguidClass,
+                                                 VBOXNETCFGWIN_NETCFGENUM_CALLBACK callback,
+                                                 PVOID pContext)
 {
     IEnumNetCfgComponent *pEnumComponent;
-    HRESULT hr = pNc->EnumComponents(pguidClass, &pEnumComponent);
-    bool bBreak = false;
-    Assert(hr == S_OK);
-    if (hr == S_OK)
-    {
-        INetCfgComponent *pNcc;
+    HRESULT hr = pNetCfg->EnumComponents(pguidClass, &pEnumComponent);
+    if (SUCCEEDED(hr))
+    {
+        INetCfgComponent *pNetCfgComponent;
         hr = pEnumComponent->Reset();
-        Assert(hr == S_OK);
         do
         {
-            hr = pEnumComponent->Next(1, &pNcc, NULL);
-            Assert(hr == S_OK || hr == S_FALSE);
-            if (hr == S_OK)
+            hr = pEnumComponent->Next(1, &pNetCfgComponent, NULL);
+            if (SUCCEEDED(hr))
             {
 //                ULONG uComponentStatus;
 //                hr = pNcc->GetDeviceStatus(&uComponentStatus);
-//                if (hr == S_OK)
-                {
-                    if (!callback(pNc, pNcc, pContext))
-                    {
-                        bBreak = true;
-                    }
-                }
-                pNcc->Release();
+//                if (SUCCEEDED(hr))
+                BOOL fResult = FALSE;
+                if (pNetCfgComponent)
+                {
+                    if (pContext)
+                        fResult = callback(pNetCfg, pNetCfgComponent, pContext);
+                    pNetCfgComponent->Release();
+                }
+
+                if (!fResult)
+                    break;
             }
             else
             {
-                if (hr ==S_FALSE)
+                if (hr == S_FALSE)
                 {
                     hr = S_OK;
                 }
                 else
-                {
-                    Log(__FUNCTION__": Next failed, hr (0x%x)\n", hr);
-                }
+                    LogFlow(("Next failed, hr (0x%x)\n", hr));
                 break;
             }
-        } while (!bBreak);
-
+        } while (true);
         pEnumComponent->Release();
     }
@@ -440,11 +397,12 @@
 static BOOL vboxNetCfgWinRemoveAllNetDevicesOfIdCallback(HDEVINFO hDevInfo, PSP_DEVINFO_DATA pDev, PVOID pContext)
 {
-    DWORD winEr;
     HRESULT hr = S_OK;
     SP_REMOVEDEVICE_PARAMS rmdParams;
+
     rmdParams.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
     rmdParams.ClassInstallHeader.InstallFunction = DIF_REMOVE;
     rmdParams.Scope = DI_REMOVEDEVICE_GLOBAL;
     rmdParams.HwProfile = 0;
+
     if (SetupDiSetClassInstallParams(hDevInfo,pDev,&rmdParams.ClassInstallHeader,sizeof(rmdParams)))
     {
@@ -460,5 +418,5 @@
                     {
                         hr = S_FALSE;
-                        Log(__FUNCTION__": !!!REBOOT REQUIRED!!!\n");
+                        Log(("!!!REBOOT REQUIRED!!!\n"));
                     }
                 }
@@ -466,21 +424,21 @@
             else
             {
-                winEr = GetLastError();
-                Log(__FUNCTION__": SetupDiCallClassInstaller failed winErr(%d)\n", winEr);
-                hr = HRESULT_FROM_WIN32(winEr);
+                DWORD dwErr = GetLastError();
+                LogFlow(("SetupDiCallClassInstaller failed with %ld\n", dwErr));
+                hr = HRESULT_FROM_WIN32(dwErr);
             }
         }
         else
         {
-            winEr = GetLastError();
-            Log(__FUNCTION__": SetupDiSetSelectedDevice failed winErr(%d)\n", winEr);
-            hr = HRESULT_FROM_WIN32(winEr);
+            DWORD dwErr = GetLastError();
+            LogFlow(("SetupDiSetSelectedDevice failed with %ld\n", dwErr));
+            hr = HRESULT_FROM_WIN32(dwErr);
         }
     }
     else
     {
-        winEr = GetLastError();
-        Log(__FUNCTION__": SetupDiSetClassInstallParams failed winErr(%d)\n", winEr);
-        hr = HRESULT_FROM_WIN32(winEr);
+        DWORD dwErr = GetLastError();
+        LogFlow(("SetupDiSetClassInstallParams failed with %ld\n", dwErr));
+        hr = HRESULT_FROM_WIN32(dwErr);
     }
 
@@ -528,5 +486,5 @@
                 if (winEr != ERROR_INSUFFICIENT_BUFFER)
                 {
-                    Log(__FUNCTION__": SetupDiGetDeviceRegistryPropertyW (1) failed winErr(%d)\n", winEr);
+                    LogFlow(("SetupDiGetDeviceRegistryPropertyW (1) failed winErr(%d)\n", winEr));
                     hr = HRESULT_FROM_WIN32(winEr);
                     break;
@@ -534,7 +492,5 @@
 
                 if (pBuffer)
-                {
                     free(pBuffer);
-                }
 
                 pBuffer = (PBYTE)malloc(cbRequired);
@@ -542,13 +498,13 @@
 
                 if (!SetupDiGetDeviceRegistryPropertyW(hDevInfo,&Dev,
-                          SPDRP_HARDWAREID, /* IN DWORD Property,*/
-                          NULL, /*OUT PDWORD PropertyRegDataType, OPTIONAL*/
-                          pBuffer, /*OUT PBYTE PropertyBuffer,*/
-                          cbBuffer, /* IN DWORD PropertyBufferSize,*/
-                          &cbRequired /*OUT PDWORD RequiredSize OPTIONAL*/
-                        ))
+                                                       SPDRP_HARDWAREID, /* IN DWORD Property,*/
+                                                       NULL, /*OUT PDWORD PropertyRegDataType, OPTIONAL*/
+                                                       pBuffer, /*OUT PBYTE PropertyBuffer,*/
+                                                       cbBuffer, /* IN DWORD PropertyBufferSize,*/
+                                                       &cbRequired /*OUT PDWORD RequiredSize OPTIONAL*/
+                                                       ))
                 {
                     winEr = GetLastError();
-                    Log(__FUNCTION__": SetupDiGetDeviceRegistryPropertyW (2) failed winErr(%d)\n", winEr);
+                    LogFlow(("SetupDiGetDeviceRegistryPropertyW (2) failed winErr(%d)\n", winEr));
                     hr = HRESULT_FROM_WIN32(winEr);
                     break;
@@ -585,5 +541,5 @@
     {
         DWORD winEr = GetLastError();
-        Log(__FUNCTION__": SetupDiGetClassDevsExW failed winErr(%d)\n", winEr);
+        LogFlow(("SetupDiGetClassDevsExW failed winErr(%d)\n", winEr));
         hr = HRESULT_FROM_WIN32(winEr);
     }
@@ -868,12 +824,10 @@
         }
         else
-        {
-            Log(__FUNCTION__": ExecQuery fail hr (0x%x)\n", hr);
-        }
+            LogFlow(("ExecQuery failed (0x%x)\n", hr));
     }
     else
     {
         DWORD winEr = GetLastError();
-        Log(__FUNCTION__": StringFromGUID2 fail winEr (%d)\n", winEr);
+        LogFlow(("StringFromGUID2 failed winEr (%d)\n", winEr));
         hr = HRESULT_FROM_WIN32( winEr );
     }
@@ -1002,7 +956,5 @@
                         {
                             if (!wcsicmp(pCurMask, pMask))
-                            {
                                 *pFound = true;
-                            }
                             break;
                         }
@@ -1076,22 +1028,14 @@
             }
             else
-            {
-                Log(__FUNCTION__": CoSetProxyBlanket failed hr (0x%x)\n", hr);
-            }
+                LogFlow(("CoSetProxyBlanket failed, hr (0x%x)\n", hr));
 
             pSvc->Release();
         }
         else
-        {
-            Log(__FUNCTION__": ConnectServer failed hr (0x%x)\n", hr);
-        }
-
+            LogFlow(("ConnectServer failed, hr (0x%x)\n", hr));
         pLoc->Release();
     }
     else
-    {
-        Log(__FUNCTION__": CoCreateInstance failed hr (0x%x)\n", hr);
-    }
-
+        LogFlow(("CoCreateInstance failed, hr (0x%x)\n", hr));
     return hr;
 }
@@ -1108,10 +1052,5 @@
     }
     else
-    {
-        DWORD winEr = GetLastError();
-        Log(__FUNCTION__": Get failed winEr (%d)\n", winEr);
-        Assert(0);
-        hr = HRESULT_FROM_WIN32(winEr);
-    }
+        LogFlow(("Get failed, hr (0x%x)\n", hr));
     return hr;
 }
@@ -1139,7 +1078,5 @@
                         pArgs[i], 0);
                     if (FAILED(hr))
-                    {
                         break;
-                    }
                 }
             }
@@ -1187,9 +1124,5 @@
     }
     else
-    {
-        DWORD dwError = GetLastError();
-        Assert(0);
-        hr = HRESULT_FROM_WIN32( dwError );
-    }
+        hr = HRESULT_FROM_WIN32(GetLastError());
 
     return hr;
@@ -1218,9 +1151,5 @@
     }
     else
-    {
-        DWORD dwError = GetLastError();
-        Assert(0);
-        hr = HRESULT_FROM_WIN32( dwError );
-    }
+        hr = HRESULT_FROM_WIN32(GetLastError());
 
     return hr;
@@ -1300,9 +1229,5 @@
     }
     else
-    {
-        DWORD winEr = GetLastError();
-        Assert(0);
-        hr = HRESULT_FROM_WIN32(winEr);
-    }
+        hr = HRESULT_FROM_WIN32(GetLastError());
 
     return hr;
@@ -1381,13 +1306,10 @@
                     }
                 }
-            }        }
+            }
+        }
         SysFreeString(ClassName);
     }
     else
-    {
-        DWORD dwError = GetLastError();
-        Assert(0);
-        hr = HRESULT_FROM_WIN32( dwError );
-    }
+        hr = HRESULT_FROM_WIN32(GetLastError());
 
     return hr;
@@ -1458,9 +1380,5 @@
     }
     else
-    {
-        DWORD dwError = GetLastError();
-        Assert(0);
-        hr = HRESULT_FROM_WIN32( dwError );
-    }
+        hr = HRESULT_FROM_WIN32(GetLastError());
 
     return hr;
@@ -1502,18 +1420,12 @@
                                 int winEr = varReturnValue.uintVal;
                                 if (winEr == 0)
-                                {
                                     hr = S_OK;
-                                }
                                 else
-                                {
                                     hr = HRESULT_FROM_WIN32( winEr );
-                                }
                             }
                         }
                     }
                     else
-                    {
                         hr = HRESULT_FROM_WIN32( winEr );
-                    }
                 }
             }
@@ -1522,9 +1434,5 @@
     }
     else
-    {
-        DWORD dwError = GetLastError();
-        Assert(0);
-        hr = HRESULT_FROM_WIN32(dwError);
-    }
+        hr = HRESULT_FROM_WIN32(GetLastError());
 
     return hr;
@@ -1536,7 +1444,5 @@
     HRESULT hr = pAdapterConfig->Get(L"DHCPEnabled", 0, &vtEnabled, 0, 0);
     if (SUCCEEDED(hr))
-    {
         *pEnabled = vtEnabled.boolVal;
-    }
     return hr;
 }
@@ -1551,11 +1457,9 @@
         ComPtr <IWbemClassObject> pAdapterConfig;
         hr = netIfWinFindAdapterClassById(pSvc, pGuid, pAdapterConfig.asOutParam());
-        if (hr == S_OK)
+        if (SUCCEEDED(hr))
         {
             hr = vboxNetCfgWinIsDhcpEnabled(pAdapterConfig, &pSettings->bDhcp);
             if (SUCCEEDED(hr))
-            {
                 hr = netIfWinGetIpSettings(pAdapterConfig, &pSettings->ip, &pSettings->mask);
-            }
         }
     }
@@ -1573,12 +1477,10 @@
             ComPtr <IWbemClassObject> pAdapterConfig;
             hr = netIfWinFindAdapterClassById(pSvc, pGuid, pAdapterConfig.asOutParam());
-            if (hr == S_OK)
+            if (SUCCEEDED(hr))
             {
                 VARIANT vtEnabled;
                 hr = pAdapterConfig->Get(L"DHCPEnabled", 0, &vtEnabled, 0, 0);
                 if (SUCCEEDED(hr))
-                {
                     *pEnabled = vtEnabled.boolVal;
-                }
             }
         }
@@ -1596,5 +1498,5 @@
             ComPtr <IWbemClassObject> pAdapterConfig;
             hr = netIfWinFindAdapterClassById(pSvc, pGuid, pAdapterConfig.asOutParam());
-            if (hr == S_OK)
+            if (SUCCEEDED(hr))
             {
                 BOOL bIsHostOnly;
@@ -1649,5 +1551,5 @@
             ComPtr <IWbemClassObject> pAdapterConfig;
             hr = netIfWinFindAdapterClassById(pSvc, pGuid, pAdapterConfig.asOutParam());
-            if (hr == S_OK)
+            if (SUCCEEDED(hr))
             {
                 BSTR ObjPath;
@@ -1697,5 +1599,5 @@
             ComPtr <IWbemClassObject> pAdapterConfig;
             hr = netIfWinFindAdapterClassById(pSvc, pGuid, pAdapterConfig.asOutParam());
-            if (hr == S_OK)
+            if (SUCCEEDED(hr))
             {
                 BOOL bIsHostOnly;
@@ -1738,5 +1640,5 @@
             ComPtr <IWbemClassObject> pAdapterConfig;
             hr = netIfWinFindAdapterClassById(pSvc, pGuid, pAdapterConfig.asOutParam());
-            if (hr == S_OK)
+            if (SUCCEEDED(hr))
             {
                 BOOL bIsHostOnly;
@@ -1902,8 +1804,8 @@
     }
     else
-    {
-        Log(__FUNCTION__": GetAdaptersAddresses err (%d)\n", dwRc);
-    }
-    free(pAddresses);
+        LogFlow(("GetAdaptersAddresses err (%d)\n", dwRc));
+
+    if (pAddresses)
+        free(pAddresses);
 
     if (dwRc != NO_ERROR)
@@ -1927,5 +1829,5 @@
     if (hr == S_OK)
     {
-        Log("NetFlt Is Installed currently\n");
+        Log("NetFlt is installed currently, uninstalling ...\n");
 
         hr = VBoxNetCfgWinUninstallComponent(pNc, pNcc);
@@ -1935,10 +1837,10 @@
     else if (hr == S_FALSE)
     {
-        Log("NetFlt Is Not Installed currently\n");
+        Log("NetFlt is not installed currently\n");
         hr = S_OK;
     }
     else
     {
-        Log("vboxNetCfgWinNetFltUninstall: FindComponent for NetFlt failed, hr (0x%x)\n", hr);
+        LogFlow(("FindComponent failed, hr (0x%x)\n", hr));
         hr = S_OK;
     }
@@ -1950,26 +1852,27 @@
 }
 
-VBOXNETCFGWIN_DECL(HRESULT)
-VBoxNetCfgWinNetFltUninstall(IN INetCfg *pNc)
+VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetFltUninstall(IN INetCfg *pNc)
 {
     return vboxNetCfgWinNetFltUninstall(pNc, 0);
 }
 
-VBOXNETCFGWIN_DECL(HRESULT)
-VBoxNetCfgWinNetFltInstall(IN INetCfg *pNc, IN LPCWSTR * apInfFullPaths, IN UINT cInfFullPaths)
+VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinNetFltInstall(IN INetCfg *pNc,
+                                                       IN LPCWSTR * apInfFullPaths, IN UINT cInfFullPaths)
 {
     HRESULT hr = vboxNetCfgWinNetFltUninstall(pNc, SUOI_FORCEDELETE);
-
-    hr = VBoxNetCfgWinInstallInfAndComponent(pNc, VBOXNETCFGWIN_NETFLT_ID,
-                                     &GUID_DEVCLASS_NETSERVICE,
-                                     apInfFullPaths,
-                                     cInfFullPaths,
-                                     NULL);
-
+    if (SUCCEEDED(hr))
+    {
+        Log("NetFlt will be installed ...\n");
+        hr = VBoxNetCfgWinInstallInfAndComponent(pNc, VBOXNETCFGWIN_NETFLT_ID,
+                                                 &GUID_DEVCLASS_NETSERVICE,
+                                                 apInfFullPaths,
+                                                 cInfFullPaths,
+                                                 NULL);
+    }
     return hr;
 }
 
 #define VBOX_CONNECTION_NAME L"VirtualBox Host-Only Network"
-VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGenHostonlyConnectionName (PCWSTR DevName, WCHAR *pBuf, PULONG pcbBuf)
+VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinGenHostonlyConnectionName(PCWSTR DevName, WCHAR *pBuf, PULONG pcbBuf)
 {
     const WCHAR * pSuffix = wcsrchr( DevName, L'#' );
@@ -1999,124 +1902,95 @@
 }
 
-static BOOL vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority (IN INetCfg *pNc, IN INetCfgComponent *pNcc, PVOID pContext)
-{
-    INetCfgComponentBindings *pNccb = NULL;
-    IEnumNetCfgBindingPath  *pEnumNccbp;
+static BOOL vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority(IN INetCfg *pNc, IN INetCfgComponent *pNcc, PVOID pContext)
+{
+    INetCfgComponentBindings *pNetCfgBindings;
     GUID *pGuid = (GUID*)pContext;
-    HRESULT hr;
-    bool bFound = false;
 
     /* Get component's binding. */
-    hr = pNcc->QueryInterface(IID_INetCfgComponentBindings, (PVOID*)&pNccb);
-    Assert(hr == S_OK);
-    if ( hr == S_OK )
+    HRESULT hr = pNcc->QueryInterface(IID_INetCfgComponentBindings, (PVOID*)&pNetCfgBindings);
+    if (SUCCEEDED(hr))
     {
         /* Get binding path enumerator reference. */
-        hr = pNccb->EnumBindingPaths(EBP_BELOW, &pEnumNccbp);
-        Assert(hr == S_OK);
-        if (hr == S_OK)
-        {
-            INetCfgBindingPath *pNccbp;
-            hr = pEnumNccbp->Reset();
-            Assert(hr == S_OK);
+        IEnumNetCfgBindingPath *pEnumNetCfgBindPath;
+        hr = pNetCfgBindings->EnumBindingPaths(EBP_BELOW, &pEnumNetCfgBindPath);
+        if (SUCCEEDED(hr))
+        {
+            bool bFoundIface = false;
+            hr = pEnumNetCfgBindPath->Reset();
             do
             {
-                hr = pEnumNccbp->Next(1, &pNccbp, NULL);
-                Assert(hr == S_OK || hr == S_FALSE);
+                INetCfgBindingPath *pNetCfgBindPath;
+                hr = pEnumNetCfgBindPath->Next(1, &pNetCfgBindPath, NULL);
                 if (hr == S_OK)
                 {
-//                   if (pNccbp->IsEnabled() == S_OK)
+                    IEnumNetCfgBindingInterface *pEnumNetCfgBindIface;
+                    hr = pNetCfgBindPath->EnumBindingInterfaces(&pEnumNetCfgBindIface);
+                    if (hr == S_OK)
                     {
-                        IEnumNetCfgBindingInterface *pEnumNcbi;
-                        hr = pNccbp->EnumBindingInterfaces(&pEnumNcbi);
-                        Assert(hr == S_OK);
-                        if (hr == S_OK)
+                        pEnumNetCfgBindIface->Reset();
+                        do
                         {
-                            INetCfgBindingInterface *pNcbi;
-                            hr = pEnumNcbi->Reset();
-                            Assert(hr == S_OK);
-                            do
+                            INetCfgBindingInterface *pNetCfgBindIfce;
+                            hr = pEnumNetCfgBindIface->Next(1, &pNetCfgBindIfce, NULL);
+                            if (hr == S_OK)
                             {
-                                hr = pEnumNcbi->Next(1, &pNcbi, NULL);
-                                Assert(hr == S_OK || hr == S_FALSE);
+                                INetCfgComponent *pNetCfgCompo;
+                                hr = pNetCfgBindIfce->GetLowerComponent(&pNetCfgCompo);
                                 if (hr == S_OK)
                                 {
-                                    INetCfgComponent * pNccBoud;
-                                    hr = pNcbi->GetLowerComponent(&pNccBoud);
-                                    Assert(hr == S_OK);
+                                    ULONG uComponentStatus;
+                                    hr = pNetCfgCompo->GetDeviceStatus(&uComponentStatus);
                                     if (hr == S_OK)
                                     {
-                                        ULONG uComponentStatus;
-                                        hr = pNccBoud->GetDeviceStatus(&uComponentStatus);
-                                        if (hr == S_OK)
+                                        GUID guid;
+                                        hr = pNetCfgCompo->GetInstanceGuid(&guid);
+                                        if (   hr == S_OK
+                                            && guid == *pGuid)
                                         {
-//                                            if (uComponentStatus == 0)
-                                            {
-                                                GUID guid;
-                                                hr = pNccBoud->GetInstanceGuid(&guid);
-                                                if (guid == *pGuid)
-                                                {
-                                                    hr = pNccb->MoveAfter(pNccbp, NULL);
-                                                    Assert(hr == S_OK);
-                                                    bFound = true;
-                                                }
-                                            }
+                                            hr = pNetCfgBindings->MoveAfter(pNetCfgBindPath, NULL);
+                                            if (FAILED(hr))
+                                                LogFlow(("Unable to move interface, hr (0x%x)\n", hr));
+                                            bFoundIface = true;
                                         }
-                                        pNccBoud->Release();
                                     }
-                                    pNcbi->Release();
+                                    pNetCfgCompo->Release();
                                 }
                                 else
-                                {
-                                    if (hr == S_FALSE)
-                                    {
-                                        hr = S_OK;
-                                    }
-                                    else
-                                    {
-                                        Log(__FUNCTION__": Next failed, hr (0x%x)\n", hr);
-                                    }
-                                    break;
-                                }
-                            } while (!bFound);
-                            pEnumNcbi->Release();
-                        }
-                        else
-                        {
-                            Log(__FUNCTION__": EnumBindingInterfaces failed, hr (0x%x)\n", hr);
-                        }
-                    }
-
-                    pNccbp->Release();
-                }
-                else
-                {
-                    if (hr = S_FALSE)
-                    {
-                        hr = S_OK;
+                                    LogFlow(("GetLowerComponent failed, hr (0x%x)\n", hr));
+                                pNetCfgBindIfce->Release();
+                            }
+                            else
+                            {
+                                if (hr == S_FALSE) /* No more binding interfaces? */
+                                    hr = S_OK;
+                                else
+                                    LogFlow(("Next binding interface failed, hr (0x%x)\n", hr));
+                                break;
+                            }
+                        } while (!bFoundIface);
+                        pEnumNetCfgBindIface->Release();
                     }
                     else
-                    {
-                        Log(__FUNCTION__": Next failed, hr (0x%x)\n", hr);
-                    }
+                        LogFlow(("EnumBindingInterfaces failed, hr (0x%x)\n", hr));
+                    pNetCfgBindPath->Release();
+                }
+                else
+                {
+                    if (hr = S_FALSE) /* No more binding paths? */
+                        hr = S_OK;
+                    else
+                        LogFlow(("Next bind path failed, hr (0x%x)\n", hr));
                     break;
                 }
-            } while (!bFound);
-
-            pEnumNccbp->Release();
+            } while (!bFoundIface);
+            pEnumNetCfgBindPath->Release();
         }
         else
-        {
-            Log(__FUNCTION__": EnumBindingPaths failed, hr (0x%x)\n", hr);
-        }
-
-        pNccb->Release();
+            LogFlow(("EnumBindingPaths failed, hr (0x%x)\n", hr));
+        pNetCfgBindings->Release();
     }
     else
-    {
-        Log(__FUNCTION__": QueryInterface for IID_INetCfgComponentBindings failed, hr (0x%x)\n", hr);
-    }
-
-    return true;
+        LogFlow(("QueryInterface for IID_INetCfgComponentBindings failed, hr (0x%x)\n", hr));
+    return TRUE;
 }
 
@@ -2257,10 +2131,8 @@
         hrc = E_FAIL; \
         Log strAndArgs; \
-        Assert(0); \
         break; \
     } else do {} while (0)
 
-
-VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRemoveHostOnlyNetworkInterface (IN const GUID *pGUID, OUT BSTR *pErrMsg)
+VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinRemoveHostOnlyNetworkInterface(IN const GUID *pGUID, OUT BSTR *pErrMsg)
 {
     HRESULT hrc = S_OK;
@@ -2467,6 +2339,6 @@
 }
 
-VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface (IN LPCWSTR pInfPath, IN bool bIsInfPathFile,
-        OUT GUID *pGuid, OUT BSTR *lppszName, OUT BSTR *pErrMsg)
+VBOXNETCFGWIN_DECL(HRESULT) VBoxNetCfgWinCreateHostOnlyNetworkInterface(IN LPCWSTR pInfPath, IN bool bIsInfPathFile,
+                                                                        OUT GUID *pGuid, OUT BSTR *lppszName, OUT BSTR *pErrMsg)
 {
     HRESULT hrc = S_OK;
@@ -2484,5 +2356,4 @@
     do
     {
-        BOOL ok;
         GUID netGuid;
         SP_DRVINFO_DATA DriverInfoData;
@@ -2508,5 +2379,5 @@
 
         /* create an empty device info set associated with the net class GUID */
-        hDeviceInfo = SetupDiCreateDeviceInfoList (&netGuid, NULL);
+        hDeviceInfo = SetupDiCreateDeviceInfoList(&netGuid, NULL);
         if (hDeviceInfo == INVALID_HANDLE_VALUE)
             SetErrBreak (("SetupDiCreateDeviceInfoList failed (0x%08X)",
@@ -2514,6 +2385,6 @@
 
         /* get the class name from GUID */
-        ok = SetupDiClassNameFromGuid (&netGuid, className, MAX_PATH, NULL);
-        if (!ok)
+        BOOL fResult = SetupDiClassNameFromGuid (&netGuid, className, MAX_PATH, NULL);
+        if (!fResult)
             SetErrBreak (("SetupDiClassNameFromGuid failed (0x%08X)",
                           GetLastError()));
@@ -2521,7 +2392,7 @@
         /* create a device info element and add the new device instance
          * key to registry */
-        ok = SetupDiCreateDeviceInfo (hDeviceInfo, className, &netGuid, NULL, NULL,
+        fResult = SetupDiCreateDeviceInfo (hDeviceInfo, className, &netGuid, NULL, NULL,
                                      DICD_GENERATE_ID, &DeviceInfoData);
-        if (!ok)
+        if (!fResult)
             SetErrBreak (("SetupDiCreateDeviceInfo failed (0x%08X)",
                           GetLastError()));
@@ -2529,6 +2400,6 @@
         /* select the newly created device info to be the currently
            selected member */
-        ok = SetupDiSetSelectedDevice (hDeviceInfo, &DeviceInfoData);
-        if (!ok)
+        fResult = SetupDiSetSelectedDevice (hDeviceInfo, &DeviceInfoData);
+        if (!fResult)
             SetErrBreak (("SetupDiSetSelectedDevice failed (0x%08X)",
                           GetLastError()));
@@ -2538,7 +2409,7 @@
             /* get the device install parameters and disable filecopy */
             DeviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
-            ok = SetupDiGetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
+            fResult = SetupDiGetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
                                                 &DeviceInstallParams);
-            if (ok)
+            if (fResult)
             {
                 memset(DeviceInstallParams.DriverPath, 0, sizeof(DeviceInstallParams.DriverPath));
@@ -2553,11 +2424,10 @@
                     }
 
-                    ok = SetupDiSetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
-                                                        &DeviceInstallParams);
-                    if (!ok)
+                    fResult = SetupDiSetDeviceInstallParams(hDeviceInfo, &DeviceInfoData,
+                                                       &DeviceInstallParams);
+                    if (!fResult)
                     {
                         DWORD winEr = GetLastError();
-                        Log("SetupDiSetDeviceInstallParams: SetupDiSetDeviceInstallParams failed, winEr (%d)\n", winEr);
-                        Assert(0);
+                        LogFlow(("SetupDiSetDeviceInstallParams failed, winEr (%d)\n", winEr));
                         break;
                     }
@@ -2565,6 +2435,5 @@
                 else
                 {
-                    Log("SetupDiSetDeviceInstallParams: inf path is too long\n");
-                    Assert(0);
+                    LogFlow(("SetupDiSetDeviceInstallParams faileed: INF path is too long\n"));
                     break;
                 }
@@ -2573,14 +2442,12 @@
             {
                 DWORD winEr = GetLastError();
-                Assert(0);
-                Log("VBoxNetCfgWinCreateHostOnlyNetworkInterface: SetupDiGetDeviceInstallParams failed, winEr (%d)\n", winEr);
-            }
-
+                LogFlow(("SetupDiGetDeviceInstallParams failed, winEr (%d)\n", winEr));
+            }
         }
 
         /* build a list of class drivers */
-        ok = SetupDiBuildDriverInfoList (hDeviceInfo, &DeviceInfoData,
-                                        SPDIT_CLASSDRIVER);
-        if (!ok)
+        fResult = SetupDiBuildDriverInfoList (hDeviceInfo, &DeviceInfoData,
+                                              SPDIT_CLASSDRIVER);
+        if (!fResult)
             SetErrBreak (("SetupDiBuildDriverInfoList failed (0x%08X)",
                           GetLastError()));
@@ -2647,18 +2514,17 @@
 
         if (!found)
-            SetErrBreak (("Could not find Host Interface Networking driver! "
-                              "Please reinstall"));
+            SetErrBreak(("Could not find Host Interface Networking driver! Please reinstall"));
 
         /* set the loopback driver to be the currently selected */
-        ok = SetupDiSetSelectedDriver (hDeviceInfo, &DeviceInfoData,
+        fResult = SetupDiSetSelectedDriver (hDeviceInfo, &DeviceInfoData,
                                        &DriverInfoData);
-        if (!ok)
-            SetErrBreak (("SetupDiSetSelectedDriver failed (0x%08X)",
-                          GetLastError()));
+        if (!fResult)
+            SetErrBreak(("SetupDiSetSelectedDriver failed (0x%08X)",
+                         GetLastError()));
 
         /* register the phantom device to prepare for install */
-        ok = SetupDiCallClassInstaller (DIF_REGISTERDEVICE, hDeviceInfo,
-                                        &DeviceInfoData);
-        if (!ok)
+        fResult = SetupDiCallClassInstaller (DIF_REGISTERDEVICE, hDeviceInfo,
+                                             &DeviceInfoData);
+        if (!fResult)
         {
             DWORD err = GetLastError();
@@ -2671,7 +2537,7 @@
 
         /* ask the installer if we can install the device */
-        ok = SetupDiCallClassInstaller (DIF_ALLOW_INSTALL, hDeviceInfo,
-                                        &DeviceInfoData);
-        if (!ok)
+        fResult = SetupDiCallClassInstaller (DIF_ALLOW_INSTALL, hDeviceInfo,
+                                             &DeviceInfoData);
+        if (!fResult)
         {
             if (GetLastError() != ERROR_DI_DO_DEFAULT)
@@ -2683,7 +2549,7 @@
         /* get the device install parameters and disable filecopy */
         DeviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
-        ok = SetupDiGetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
-                                            &DeviceInstallParams);
-        if (ok)
+        fResult = SetupDiGetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
+                                                 &DeviceInstallParams);
+        if (fResult)
         {
             pQueueCallbackContext = SetupInitDefaultQueueCallback(NULL);
@@ -2692,19 +2558,17 @@
                 DeviceInstallParams.InstallMsgHandlerContext = pQueueCallbackContext;
                 DeviceInstallParams.InstallMsgHandler = (PSP_FILE_CALLBACK)vboxNetCfgWinPspFileCallback;
-                ok = SetupDiSetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
+                fResult = SetupDiSetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
                                                     &DeviceInstallParams);
-                if (!ok)
+                if (!fResult)
                 {
                     DWORD winEr = GetLastError();
-                    Assert(0);
-                    Log("SetupDiSetDeviceInstallParams: SetupDiSetDeviceInstallParams failed, winEr (%d)\n", winEr);
-                }
-                Assert(ok);
+                    LogFlow(("SetupDiSetDeviceInstallParams failed, winEr (%d)\n", winEr));
+                }
+                Assert(fResult);
             }
             else
             {
                 DWORD winEr = GetLastError();
-                Assert(0);
-                Log("VBoxNetCfgWinCreateHostOnlyNetworkInterface: SetupInitDefaultQueueCallback failed, winEr (%d)\n", winEr);
+                LogFlow(("SetupInitDefaultQueueCallback failed, winEr (%d)\n", winEr));
             }
         }
@@ -2712,25 +2576,23 @@
         {
             DWORD winEr = GetLastError();
-            Assert(0);
-            Log("VBoxNetCfgWinCreateHostOnlyNetworkInterface: SetupDiGetDeviceInstallParams failed, winEr (%d)\n", winEr);
+            LogFlow(("SetupDiGetDeviceInstallParams failed, winEr (%d)\n", winEr));
         }
 
         /* install the files first */
-        ok = SetupDiCallClassInstaller (DIF_INSTALLDEVICEFILES, hDeviceInfo,
+        fResult = SetupDiCallClassInstaller (DIF_INSTALLDEVICEFILES, hDeviceInfo,
                                         &DeviceInfoData);
-        if (!ok)
+        if (!fResult)
             SetErrBreak (("SetupDiCallClassInstaller (DIF_INSTALLDEVICEFILES) failed (0x%08X)",
                           GetLastError()));
-
         /* get the device install parameters and disable filecopy */
         DeviceInstallParams.cbSize = sizeof(SP_DEVINSTALL_PARAMS);
-        ok = SetupDiGetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
+        fResult = SetupDiGetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
                                             &DeviceInstallParams);
-        if (ok)
+        if (fResult)
         {
             DeviceInstallParams.Flags |= DI_NOFILECOPY;
-            ok = SetupDiSetDeviceInstallParams (hDeviceInfo, &DeviceInfoData,
-                                                &DeviceInstallParams);
-            if (!ok)
+            fResult = SetupDiSetDeviceInstallParams(hDeviceInfo, &DeviceInfoData,
+                                                    &DeviceInstallParams);
+            if (!fResult)
                 SetErrBreak (("SetupDiSetDeviceInstallParams failed (0x%08X)",
                               GetLastError()));
@@ -2740,9 +2602,8 @@
          * Register any device-specific co-installers for this device,
          */
-
-        ok = SetupDiCallClassInstaller (DIF_REGISTER_COINSTALLERS,
-                                        hDeviceInfo,
-                                        &DeviceInfoData);
-        if (!ok)
+        fResult = SetupDiCallClassInstaller(DIF_REGISTER_COINSTALLERS,
+                                            hDeviceInfo,
+                                            &DeviceInfoData);
+        if (!fResult)
             SetErrBreak (("SetupDiCallClassInstaller (DIF_REGISTER_COINSTALLERS) failed (0x%08X)",
                           GetLastError()));
@@ -2752,25 +2613,25 @@
          * and then do the real install
          */
-        ok = SetupDiCallClassInstaller (DIF_INSTALLINTERFACES,
-                                        hDeviceInfo,
-                                        &DeviceInfoData);
-        if (!ok)
+        fResult = SetupDiCallClassInstaller(DIF_INSTALLINTERFACES,
+                                            hDeviceInfo,
+                                            &DeviceInfoData);
+        if (!fResult)
             SetErrBreak (("SetupDiCallClassInstaller (DIF_INSTALLINTERFACES) failed (0x%08X)",
                           GetLastError()));
 
-        ok = SetupDiCallClassInstaller (DIF_INSTALLDEVICE,
-                                        hDeviceInfo,
-                                        &DeviceInfoData);
-        if (!ok)
+        fResult = SetupDiCallClassInstaller(DIF_INSTALLDEVICE,
+                                            hDeviceInfo,
+                                            &DeviceInfoData);
+        if (!fResult)
             SetErrBreak (("SetupDiCallClassInstaller (DIF_INSTALLDEVICE) failed (0x%08X)",
                           GetLastError()));
 
         /* Figure out NetCfgInstanceId */
-        hkey = SetupDiOpenDevRegKey (hDeviceInfo,
-                                     &DeviceInfoData,
-                                     DICS_FLAG_GLOBAL,
-                                     0,
-                                     DIREG_DRV,
-                                     KEY_READ);
+        hkey = SetupDiOpenDevRegKey(hDeviceInfo,
+                                    &DeviceInfoData,
+                                    DICS_FLAG_GLOBAL,
+                                    0,
+                                    DIREG_DRV,
+                                    KEY_READ);
         if (hkey == INVALID_HANDLE_VALUE)
             SetErrBreak (("SetupDiOpenDevRegKey failed (0x%08X)",
@@ -2785,10 +2646,9 @@
 
         if (!SetupDiGetDeviceRegistryPropertyW(hDeviceInfo, &DeviceInfoData,
-                SPDRP_FRIENDLYNAME , /* IN DWORD Property,*/
-                  NULL, /*OUT PDWORD PropertyRegDataType, OPTIONAL*/
-                  (PBYTE)DevName, /*OUT PBYTE PropertyBuffer,*/
-                  sizeof(DevName), /* IN DWORD PropertyBufferSize,*/
-                  NULL /*OUT PDWORD RequiredSize OPTIONAL*/
-                ))
+                                               SPDRP_FRIENDLYNAME , /* IN DWORD Property,*/
+                                               NULL, /*OUT PDWORD PropertyRegDataType, OPTIONAL*/
+                                               (PBYTE)DevName, /*OUT PBYTE PropertyBuffer,*/
+                                               sizeof(DevName), /* IN DWORD PropertyBufferSize,*/
+                                               NULL /*OUT PDWORD RequiredSize OPTIONAL*/))
         {
             int err = GetLastError();
@@ -2819,7 +2679,5 @@
      */
     if (pQueueCallbackContext)
-    {
         SetupTermDefaultQueueCallback(pQueueCallbackContext);
-    }
 
     if (hDeviceInfo != INVALID_HANDLE_VALUE)
@@ -2827,12 +2685,12 @@
         /* an error has occurred, but the device is registered, we must remove it */
         if (ret != 0 && registered)
-            SetupDiCallClassInstaller (DIF_REMOVE, hDeviceInfo, &DeviceInfoData);
-
-        found = SetupDiDeleteDeviceInfo (hDeviceInfo, &DeviceInfoData);
+            SetupDiCallClassInstaller(DIF_REMOVE, hDeviceInfo, &DeviceInfoData);
+
+        found = SetupDiDeleteDeviceInfo(hDeviceInfo, &DeviceInfoData);
 
         /* destroy the driver info list */
         if (destroyList)
-            SetupDiDestroyDriverInfoList (hDeviceInfo, &DeviceInfoData,
-                                          SPDIT_CLASSDRIVER);
+            SetupDiDestroyDriverInfoList(hDeviceInfo, &DeviceInfoData,
+                                         SPDIT_CLASSDRIVER);
         /* clean up the device info set */
         SetupDiDestroyDeviceInfoList (hDeviceInfo);
@@ -2845,80 +2703,69 @@
         ULONG cbName = sizeof(ConnectoinName);
 
-        HRESULT hr = VBoxNetCfgWinGenHostonlyConnectionName (DevName, ConnectoinName, &cbName);
+        HRESULT hr = VBoxNetCfgWinGenHostonlyConnectionName(DevName, ConnectoinName, &cbName);
+        if (SUCCEEDED(hr))
+            hr = VBoxNetCfgWinRenameConnection(pWCfgGuidString, ConnectoinName);
+
+        if (lppszName)
+        {
+            *lppszName = ::SysAllocString((const OLECHAR *) DevName);
+            if (!*lppszName)
+            {
+                LogFlow(("SysAllocString failed\n"));
+                hrc = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
+            }
+        }
+
+        if (pGuid)
+        {
+            hrc = CLSIDFromString(pWCfgGuidString, (LPCLSID)pGuid);
+            if (FAILED(hrc))
+                LogFlow(("CLSIDFromString failed, hrc (0x%x)\n", hrc));
+        }
+
+        INetCfg *pNetCfg = NULL;
+        LPWSTR lpszApp = NULL;
+        hr = VBoxNetCfgWinQueryINetCfg(&pNetCfg, TRUE, L"VirtualBox Host-Only Creation",
+                                       30 * 1000, /* on Vista we often get 6to4svc.dll holding the lock, wait for 30 sec.  */
+                                       /* TODO: special handling for 6to4svc.dll ???, i.e. several retrieves */
+                                       &lpszApp);
         if (hr == S_OK)
         {
-            hr = VBoxNetCfgWinRenameConnection (pWCfgGuidString, ConnectoinName);
-        }
-
-        if (lppszName)
-        {
-            *lppszName = ::SysAllocString ((const OLECHAR *) DevName);
-            if (!*lppszName)
-            {
-                Log("VBoxNetCfgWinCreateHostOnlyNetworkInterface: SysAllocString failed\n");
-                Assert(0);
-                hrc = HRESULT_FROM_WIN32(ERROR_NOT_ENOUGH_MEMORY);
-            }
-        }
-
-        if (pGuid)
-        {
-            hrc = CLSIDFromString(pWCfgGuidString, (LPCLSID)pGuid);
-            if (hrc != S_OK)
-            {
-                Log("VBoxNetCfgWinCreateHostOnlyNetworkInterface: CLSIDFromString failed, hrc (0x%x)\n", hrc);
-                Assert(0);
-            }
-        }
-
-        INetCfg *pNc;
-        LPWSTR lpszApp = NULL;
-
-        hr = VBoxNetCfgWinQueryINetCfg(&pNc, TRUE, L"VirtualBox Host-Only Creation",
-                           30000, /* on Vista we often get 6to4svc.dll holding the lock, wait for 30 sec,  */
-                                  /* TODO: special handling for 6to4svc.dll ???, i.e. several retrieves */
-                           &lpszApp);
-        Assert(hr == S_OK);
-        if (hr == S_OK)
-        {
-            hr = vboxNetCfgWinEnumNetCfgComponents(pNc,
-                    &GUID_DEVCLASS_NETSERVICE,
-                    vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority,
-                    pGuid);
-            Assert(hr == S_OK);
-
-            hr = vboxNetCfgWinEnumNetCfgComponents(pNc,
-                    &GUID_DEVCLASS_NETTRANS,
-                    vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority,
-                    pGuid);
-            Assert(hr == S_OK);
-
-            hr = vboxNetCfgWinEnumNetCfgComponents(pNc,
-                    &GUID_DEVCLASS_NETCLIENT,
-                    vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority,
-                    pGuid);
-            Assert(hr == S_OK);
-
-            if (hr == S_OK)
-            {
-                hr = pNc->Apply();
-                Assert(hr == S_OK);
-            }
-
-            VBoxNetCfgWinReleaseINetCfg(pNc, TRUE);
+            hr = vboxNetCfgWinEnumNetCfgComponents(pNetCfg,
+                                                   &GUID_DEVCLASS_NETSERVICE,
+                                                   vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority,
+                                                   pGuid);
+            if (SUCCEEDED(hr))
+            {
+                hr = vboxNetCfgWinEnumNetCfgComponents(pNetCfg,
+                                                       &GUID_DEVCLASS_NETTRANS,
+                                                       vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority,
+                                                       pGuid);
+                if (SUCCEEDED(hr))
+                    hr = vboxNetCfgWinEnumNetCfgComponents(pNetCfg,
+                                                           &GUID_DEVCLASS_NETCLIENT,
+                                                           vboxNetCfgWinAdjustHostOnlyNetworkInterfacePriority,
+                                                           pGuid);
+            }
+
+            if (SUCCEEDED(hr))
+            {
+                hr = pNetCfg->Apply();
+            }
+            else
+                LogFlow(("Enumeration failed, hr 0x%x\n", hr));
+            VBoxNetCfgWinReleaseINetCfg(pNetCfg, TRUE);
         }
         else if (hr == NETCFG_E_NO_WRITE_LOCK && lpszApp)
         {
-            Log("VBoxNetCfgWinCreateHostOnlyNetworkInterface: app %S is holding the lock, failed\n", lpszApp);
+            LogFlow(("Application %ws is holding the lock, failed\n", lpszApp));
             CoTaskMemFree(lpszApp);
         }
         else
-        {
-            Log("VBoxNetCfgWinCreateHostOnlyNetworkInterface: VBoxNetCfgWinQueryINetCfg failed, hr 0x%x\n", hr);
-        }
-    }
-
+            LogFlow(("VBoxNetCfgWinQueryINetCfg failed, hr 0x%x\n", hr));
+    }
     return hrc;
 }
 
 #undef SetErrBreak
+
