Index: trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp	(revision 63098)
+++ trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDispIf.cpp	(revision 63099)
@@ -24,18 +24,21 @@
 #include <malloc.h>
 
+/*********************************************************************************************************************************
+*   Defined Constants And Macros                                                                                                 *
+*********************************************************************************************************************************/
 #ifdef DEBUG_misha
-#define WARN(_m) do { \
+# define WARN(_m) do { \
             Assert(0); \
             Log(_m); \
         } while (0)
-#define WARN_FUNC(_m) do { \
+# define WARN_FUNC(_m) do { \
             Assert(0); \
             LogFunc(_m); \
         } while (0)
 #else
-#define WARN(_m) do { \
+# define WARN(_m) do { \
             Log(_m); \
         } while (0)
-#define WARN_FUNC(_m) do { \
+# define WARN_FUNC(_m) do { \
             LogFunc(_m); \
         } while (0)
@@ -52,4 +55,8 @@
 #endif
 
+
+/*********************************************************************************************************************************
+*   Structures and Typedefs                                                                                                      *
+*********************************************************************************************************************************/
 typedef struct VBOXDISPIF_OP
 {
@@ -59,9 +66,4 @@
     VBOXDISPKMT_CONTEXT Context;
 } VBOXDISPIF_OP;
-
-static DWORD vboxDispIfWddmResizeDisplay(PCVBOXDISPIF const pIf, UINT Id, BOOL fEnable, DISPLAY_DEVICE * paDisplayDevices, DEVMODE *paDeviceMode, UINT devModes);
-static DWORD vboxDispIfResizePerform(PCVBOXDISPIF const pIf, UINT iChangedMode, BOOL fEnable, BOOL fExtDispSup, DISPLAY_DEVICE *paDisplayDevices, DEVMODE *paDeviceModes, UINT cDevModes);
-static DWORD vboxDispIfWddmEnableDisplaysTryingTopology(PCVBOXDISPIF const pIf, UINT cIds, UINT *pIds, BOOL fEnable);
-static DWORD vboxDispIfResizeStartedWDDMOp(VBOXDISPIF_OP *pOp);
 
 /*
@@ -89,4 +91,16 @@
 } VBOXDISPIF_WDDM_DISPCFG;
 
+
+/*********************************************************************************************************************************
+*   Internal Functions                                                                                                           *
+*********************************************************************************************************************************/
+static DWORD vboxDispIfWddmResizeDisplay(PCVBOXDISPIF const pIf, UINT Id, BOOL fEnable, DISPLAY_DEVICE * paDisplayDevices,
+                                         DEVMODE *paDeviceModes, UINT devModes);
+static DWORD vboxDispIfResizePerform(PCVBOXDISPIF const pIf, UINT iChangedMode, BOOL fEnable, BOOL fExtDispSup,
+                                     DISPLAY_DEVICE *paDisplayDevices, DEVMODE *paDeviceModes, UINT cDevModes);
+static DWORD vboxDispIfWddmEnableDisplaysTryingTopology(PCVBOXDISPIF const pIf, UINT cIds, UINT *pIds, BOOL fEnable);
+static DWORD vboxDispIfResizeStartedWDDMOp(VBOXDISPIF_OP *pOp);
+
+
 static DWORD vboxDispIfWddmDcCreate(VBOXDISPIF_WDDM_DISPCFG *pCfg, UINT32 fFlags)
 {
@@ -217,10 +231,11 @@
 }
 
+#define VBOX_WDDM_DC_SEARCH_PATH_ANY (~(UINT)0)
 static int vboxDispIfWddmDcSearchPath(VBOXDISPIF_WDDM_DISPCFG *pCfg, UINT srcId, UINT trgId)
 {
     for (UINT iter = 0; iter < pCfg->cPathInfoArray; ++iter)
     {
-        if ((srcId == ~0UL || pCfg->pPathInfoArray[iter].sourceInfo.id == srcId)
-                && (trgId == ~0UL || pCfg->pPathInfoArray[iter].targetInfo.id == trgId))
+        if (   (srcId == VBOX_WDDM_DC_SEARCH_PATH_ANY || pCfg->pPathInfoArray[iter].sourceInfo.id == srcId)
+            && (trgId == VBOX_WDDM_DC_SEARCH_PATH_ANY || pCfg->pPathInfoArray[iter].targetInfo.id == trgId))
         {
             return (int)iter;
@@ -284,6 +299,4 @@
 static DWORD vboxDispIfWddmDcSettingsUpdate(VBOXDISPIF_WDDM_DISPCFG *pCfg, int idx, DEVMODE *pDeviceMode, BOOL fInvalidateSrcMode, BOOL fEnable)
 {
-    UINT Id = pCfg->pPathInfoArray[idx].sourceInfo.id;
-
     if (fInvalidateSrcMode)
         pCfg->pPathInfoArray[idx].sourceInfo.modeInfoIdx = DISPLAYCONFIG_PATH_MODE_IDX_INVALID;
@@ -445,5 +458,5 @@
         if (idx < 0)
         {
-            idx = vboxDispIfWddmDcSearchPath(pCfg, -1, i);
+            idx = vboxDispIfWddmDcSearchPath(pCfg, VBOX_WDDM_DC_SEARCH_PATH_ANY, i);
             if (idx >= 0)
             {
@@ -472,5 +485,5 @@
             {
                 WARN(("VBoxTray:(WDDM) %d %d path not supported\n", i, i));
-                idx = vboxDispIfWddmDcSearchPath(pCfg, -1, i);
+                idx = vboxDispIfWddmDcSearchPath(pCfg, VBOX_WDDM_DC_SEARCH_PATH_ANY, i);
                 if (idx < 0)
                 {
@@ -605,4 +618,5 @@
 static DWORD vboxDispIfEscapeXPDM(PCVBOXDISPIF pIf, PVBOXDISPIFESCAPE pEscape, int cbData, int iDirection)
 {
+    RT_NOREF(pIf);
     HDC  hdc = GetDC(HWND_DESKTOP);
     VOID *pvData = cbData ? VBOXDISPIFESCAPE_DATA(pEscape, VOID) : NULL;
@@ -615,5 +629,5 @@
     if (iRet > 0)
         return VINF_SUCCESS;
-    else if (iRet == 0)
+    if (iRet == 0)
         return ERROR_NOT_SUPPORTED;
     /* else */
@@ -990,6 +1004,5 @@
         if (!RegisterClassEx(&wc))
         {
-            DWORD winErr = GetLastError();
-            WARN_FUNC(("RegisterClass failed, winErr(%d)\n", winErr));
+            WARN_FUNC(("RegisterClass failed, winErr(%d)\n", GetLastError()));
             hr = E_FAIL;
         }
@@ -1014,6 +1027,5 @@
         else
         {
-            DWORD winErr = GetLastError();
-            WARN_FUNC(("CreateWindowEx failed, winErr(%d)\n", winErr));
+            WARN_FUNC(("CreateWindowEx failed, winErr(%d)\n", GetLastError()));
             hr = E_FAIL;
         }
@@ -1044,6 +1056,6 @@
 {
     PVBOXRR pMon = &g_VBoxRr;
-    HRESULT tmpHr = vboxRrWndDestroy(pMon->hWnd);
-    Assert(tmpHr == S_OK);
+    HRESULT hrTmp = vboxRrWndDestroy(pMon->hWnd);
+    Assert(hrTmp == S_OK); NOREF(hrTmp);
 
     HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
@@ -1078,6 +1090,6 @@
         DWORD winErr = GetLastError();
         WARN_FUNC(("SetEvent failed, winErr = (%d)", winErr));
-        HRESULT tmpHr = HRESULT_FROM_WIN32(winErr);
-        Assert(tmpHr != S_OK);
+        HRESULT hrTmp = HRESULT_FROM_WIN32(winErr);
+        Assert(hrTmp != S_OK); NOREF(hrTmp);
     }
 
@@ -1133,4 +1145,5 @@
 static DWORD WINAPI vboxRrRunnerThread(void *pvUser)
 {
+    RT_NOREF(pvUser);
     HRESULT hr = vboxRrWndInit();
     Assert(hr == S_OK);
@@ -1238,9 +1251,8 @@
 static DWORD vboxDispIfWddmInit(PCVBOXDISPIF pIf)
 {
+    RT_NOREF(pIf);
     HRESULT hr = VBoxRrInit();
     if (SUCCEEDED(hr))
-    {
         return ERROR_SUCCESS;
-    }
     WARN(("VBoxTray: VBoxRrInit failed hr 0x%x\n", hr));
     return hr;
@@ -1249,4 +1261,5 @@
 static void vboxDispIfWddmTerm(PCVBOXDISPIF pIf)
 {
+    RT_NOREF(pIf);
     VBoxRrTerm();
 }
@@ -1365,4 +1378,5 @@
 DWORD vboxDispIfCancelPendingResizeWDDM(PCVBOXDISPIF const pIf)
 {
+    RT_NOREF(pIf);
     Log(("VBoxTray: cancelling pending resize\n"));
     VBoxRrRetryStop();
@@ -1512,4 +1526,5 @@
 static DWORD vboxDispIfWddmEnableDisplays(PCVBOXDISPIF const pIf, UINT cIds, UINT *pIds, BOOL fEnabled, BOOL fSetTopology, DEVMODE *pDeviceMode)
 {
+    RT_NOREF(pIf);
     VBOXDISPIF_WDDM_DISPCFG DispCfg;
 
@@ -1580,5 +1595,5 @@
         UINT Id = pChangeIds[i];
         /* re-query paths */
-        iPath = vboxDispIfWddmDcSearchPath(&DispCfg, -1, Id);
+        iPath = vboxDispIfWddmDcSearchPath(&DispCfg, VBOX_WDDM_DC_SEARCH_PATH_ANY, Id);
         if (iPath < 0)
         {
@@ -1663,6 +1678,8 @@
 }
 
-static DWORD vboxDispIfWddmResizeDisplay(PCVBOXDISPIF const pIf, UINT Id, BOOL fEnable, DISPLAY_DEVICE * paDisplayDevices, DEVMODE *paDeviceMode, UINT devModes)
-{
+static DWORD vboxDispIfWddmResizeDisplay(PCVBOXDISPIF const pIf, UINT Id, BOOL fEnable, DISPLAY_DEVICE *paDisplayDevices,
+                                         DEVMODE *paDeviceModes, UINT devModes)
+{
+    RT_NOREF(paDisplayDevices, devModes);
     VBOXDISPIF_WDDM_DISPCFG DispCfg;
     DWORD winEr;
@@ -1730,5 +1747,5 @@
     Assert(fEnable);
 
-    winEr = vboxDispIfWddmDcSettingsUpdate(&DispCfg, iPath, &paDeviceMode[Id], FALSE, fEnable);
+    winEr = vboxDispIfWddmDcSettingsUpdate(&DispCfg, iPath, &paDeviceModes[Id], FALSE, fEnable);
     if (winEr != ERROR_SUCCESS)
     {
@@ -1977,4 +1994,5 @@
 static DWORD vboxDispIfSwitchToXPDM_NT4(PVBOXDISPIF pIf)
 {
+    RT_NOREF(pIf);
     return NO_ERROR;
 }
@@ -2099,8 +2117,11 @@
 static DWORD vboxDispIfSeamlessCreateWDDM(PCVBOXDISPIF const pIf, VBOXDISPIF_SEAMLESS *pSeamless, HANDLE hEvent)
 {
+    RT_NOREF(hEvent);
     HRESULT hr = vboxDispKmtOpenAdapter(&pIf->modeData.wddm.KmtCallbacks, &pSeamless->modeData.wddm.Adapter);
     if (SUCCEEDED(hr))
     {
-#ifdef VBOX_DISPIF_WITH_OPCONTEXT
+#ifndef VBOX_DISPIF_WITH_OPCONTEXT
+        return ERROR_SUCCESS;
+#else
         hr = vboxDispKmtCreateDevice(&pSeamless->modeData.wddm.Adapter, &pSeamless->modeData.wddm.Device);
         if (SUCCEEDED(hr))
@@ -2109,9 +2130,6 @@
                     0, 0, hEvent, 0ULL);
             if (SUCCEEDED(hr))
-#endif
                 return ERROR_SUCCESS;
-#ifdef VBOX_DISPIF_WITH_OPCONTEXT
-            else
-                WARN(("VBoxTray: vboxDispKmtCreateContext failed hr 0x%x", hr));
+            WARN(("VBoxTray: vboxDispKmtCreateContext failed hr 0x%x", hr));
 
             vboxDispKmtDestroyDevice(&pSeamless->modeData.wddm.Device);
@@ -2121,5 +2139,5 @@
 
         vboxDispKmtCloseAdapter(&pSeamless->modeData.wddm.Adapter);
-#endif
+#endif /* VBOX_DISPIF_WITH_OPCONTEXT */
     }
 
Index: trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp	(revision 63098)
+++ trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp	(revision 63099)
@@ -67,5 +67,5 @@
 static void vboxStTerm(void);
 /* @returns true on "IsActiveConsole" state change */
-static BOOL vboxStHandleEvent(WPARAM EventID, LPARAM SessionID);
+static BOOL vboxStHandleEvent(WPARAM EventID);
 static BOOL vboxStIsActiveConsole();
 static BOOL vboxStCheckTimer(WPARAM wEvent);
@@ -169,5 +169,5 @@
 
 /* The global message table. */
-static VBOXGLOBALMESSAGE s_vboxGlobalMessageTable[] =
+static VBOXGLOBALMESSAGE g_vboxGlobalMessageTable[] =
 {
     /* Windows specific stuff. */
@@ -195,4 +195,5 @@
 static int vboxTrayGlMsgTaskbarCreated(WPARAM wParam, LPARAM lParam)
 {
+    RT_NOREF(wParam, lParam);
     return vboxTrayCreateTrayIcon();
 }
@@ -981,4 +982,6 @@
 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
 {
+    RT_NOREF(hPrevInstance, lpCmdLine, nCmdShow);
+
     /* Note: Do not use a global namespace ("Global\\") for mutex name here,
      * will blow up NT4 compatibility! */
@@ -1099,5 +1102,5 @@
             LogFunc(("Tool window created\n"));
 
-            int rc = vboxTrayRegisterGlobalMessages(&s_vboxGlobalMessageTable[0]);
+            int rc = vboxTrayRegisterGlobalMessages(&g_vboxGlobalMessageTable[0]);
             if (RT_FAILURE(rc))
                 LogFunc(("Error registering global window messages, rc=%Rrc\n", rc));
@@ -1191,5 +1194,5 @@
         {
             BOOL fOldAllowedState = VBoxConsoleIsAllowed();
-            if (vboxStHandleEvent(wParam, lParam))
+            if (vboxStHandleEvent(wParam))
             {
                 if (!VBoxConsoleIsAllowed() != !fOldAllowedState)
@@ -1202,5 +1205,5 @@
         {
             /* Handle all globally registered window messages. */
-            if (vboxTrayHandleGlobalMessages(&s_vboxGlobalMessageTable[0], uMsg,
+            if (vboxTrayHandleGlobalMessages(&g_vboxGlobalMessageTable[0], uMsg,
                                              wParam, lParam))
             {
@@ -1344,6 +1347,5 @@
         if (!gVBoxSt.pfnWTSUnRegisterSessionNotification(gVBoxSt.hWTSAPIWnd))
         {
-            DWORD dwErr = GetLastError();
-            LogFlowFunc(("WTSAPI32 load failed, error = %08X\n", dwErr));
+            LogFlowFunc(("WTSAPI32 load failed, error = %08X\n", GetLastError()));
         }
     }
@@ -1387,6 +1389,5 @@
     else
     {
-        DWORD dwErr = GetLastError();
-        LogFlowFunc(("timer WTSRegisterSessionNotification failed, error = %08X\n", dwErr));
+        LogFlowFunc(("timer WTSRegisterSessionNotification failed, error = %08X\n", GetLastError()));
         Assert(gVBoxSt.fIsConsole == TRUE);
         Assert(gVBoxSt.enmConnectState == WTSActive);
@@ -1397,6 +1398,7 @@
 
 
-static BOOL vboxStHandleEvent(WPARAM wEvent, LPARAM SessionID)
-{
+static BOOL vboxStHandleEvent(WPARAM wEvent)
+{
+    RT_NOREF(wEvent);
     LogFlowFunc(("WTS Event: %s\n", vboxStDbgGetString(wEvent)));
     BOOL fOldIsActiveConsole = vboxStIsActiveConsole();
@@ -1407,5 +1409,5 @@
 }
 
-static BOOL vboxStIsActiveConsole()
+static BOOL vboxStIsActiveConsole(void)
 {
     return (gVBoxSt.enmConnectState == WTSActive && gVBoxSt.fIsConsole);
@@ -1455,5 +1457,5 @@
     else
     {
-        DWORD dwErr = GetLastError();
+//        DWORD dwErr = GetLastError();
 //        LogFlowFunc(("pfnOpenInputDesktop for Seamless failed, last error = %08X\n", dwErr));
     }
@@ -1537,8 +1539,5 @@
                         fRc = gVBoxDt.pfnVBoxHookInstallActiveDesktopTracker(hModHook);
                         if (!fRc)
-                        {
-                            DWORD dwErr = GetLastError();
-                            LogFlowFunc(("pfnVBoxHookInstallActiveDesktopTracker failed, last error = %08X\n", dwErr));
-                        }
+                            LogFlowFunc(("pfnVBoxHookInstallActiveDesktopTracker failed, last error = %08X\n", GetLastError()));
                     }
 
@@ -1683,4 +1682,5 @@
 static DECLCALLBACK(void) vboxCapsOnEnableSeamless(struct VBOXCAPS *pConsole, struct VBOXCAPS_ENTRY *pCap, BOOL fEnabled)
 {
+    RT_NOREF(pConsole, pCap);
     if (fEnabled)
     {
