Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp	(revision 38086)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo-win.cpp	(revision 38087)
@@ -256,9 +256,9 @@
 bool VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs)
 {
-    AssertPtr(pSession);
-
-    if (!cProcs) /* To be on the safe side. */
+    if (!pSession)
+    {
+        VBoxServiceVerbose(1, "VMInfo/Users: Session became invalid while enumerating!\n");
         return false;
-    AssertPtr(paProcs);
+    }
 
     PSECURITY_LOGON_SESSION_DATA pSessionData = NULL;
@@ -266,8 +266,7 @@
     if (rcNt != STATUS_SUCCESS)
     {
-        VBoxServiceError("Could not get logon session data! rcNt=%#x", rcNt);
+        VBoxServiceError("VMInfo/Users: Could not get logon session data! rcNt=%#x", rcNt);
         return false;
     }
-    AssertPtrReturn(pSessionData, false);
 
     /*
@@ -276,4 +275,5 @@
      * session <-> process LUIDs.
      */
+    uint32_t cNumProcs = 0;
     for (DWORD i = 0; i < cProcs; i++)
     {
@@ -284,12 +284,15 @@
             && paProcs[i].luid.LowPart  == pSessionData->LogonId.LowPart)
         {
-            VBoxServiceVerbose(3, "Users: Session %ld:%ld has active processes\n",
-                               pSessionData->LogonId.HighPart, pSessionData->LogonId.LowPart);
-            LsaFreeReturnBuffer(pSessionData);
-            return true;
-        }
-    }
+            cNumProcs++;
+            if (g_cVerbosity < 4) /* We want a bit more info on high verbosity. */
+                break;
+        }
+    }
+
+    VBoxServiceVerbose(3, "VMInfo/Users: Session %u has %u processes\n",
+                       pSessionData->Session, cNumProcs);
+
     LsaFreeReturnBuffer(pSessionData);
-    return false;
+    return cNumProcs ? true : false;
 }
 
@@ -324,15 +327,15 @@
  *
  * @returns true if logged in, false if not (or error).
- * @param   a_pUserInfo     Where to return the user information.
- * @param   a_pSession      The session to check.
- */
-bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER a_pUserInfo, PLUID a_pSession)
-{
-    AssertPtr(a_pUserInfo);
-    if (!a_pSession)
+ * @param   pUserInfo           Where to return the user information.
+ * @param   pSession            The session to check.
+ */
+bool VBoxServiceVMInfoWinIsLoggedIn(PVBOXSERVICEVMINFOUSER pUserInfo, PLUID pSession)
+{
+    AssertPtr(pUserInfo);
+    if (!pSession)
         return false;
 
     PSECURITY_LOGON_SESSION_DATA pSessionData = NULL;
-    NTSTATUS rcNt = LsaGetLogonSessionData(a_pSession, &pSessionData);
+    NTSTATUS rcNt = LsaGetLogonSessionData(pSession, &pSessionData);
     if (rcNt != STATUS_SUCCESS)
     {
@@ -373,9 +376,9 @@
          * Copy out relevant data.
          */
-        VBoxServiceVMInfoWinSafeCopy(a_pUserInfo->wszUser, sizeof(a_pUserInfo->wszUser),
+        VBoxServiceVMInfoWinSafeCopy(pUserInfo->wszUser, sizeof(pUserInfo->wszUser),
                                      &pSessionData->UserName, "User name");
-        VBoxServiceVMInfoWinSafeCopy(a_pUserInfo->wszAuthenticationPackage, sizeof(a_pUserInfo->wszAuthenticationPackage),
+        VBoxServiceVMInfoWinSafeCopy(pUserInfo->wszAuthenticationPackage, sizeof(pUserInfo->wszAuthenticationPackage),
                                      &pSessionData->AuthenticationPackage, "Authentication pkg name");
-        VBoxServiceVMInfoWinSafeCopy(a_pUserInfo->wszLogonDomain, sizeof(a_pUserInfo->wszLogonDomain),
+        VBoxServiceVMInfoWinSafeCopy(pUserInfo->wszLogonDomain, sizeof(pUserInfo->wszLogonDomain),
                                      &pSessionData->LogonDomain, "Logon domain name");
 
@@ -401,6 +404,6 @@
              */
             if (dwErr != ERROR_NONE_MAPPED)
-                VBoxServiceError("VMInfo/Users: Failed looking up account info for user '%ls': %ld!\n",
-                                 a_pUserInfo->wszUser, dwErr);
+                VBoxServiceError("VMInfo/Users: Failed looking up account info for user=%ls, error=$ld!\n",
+                                 pUserInfo->wszUser, dwErr);
         }
         else
@@ -409,7 +412,7 @@
             {
                 VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, Session=%ld, LUID=%ld,%ld, AuthPkg=%ls, Domain=%ls\n",
-                                   a_pUserInfo->wszUser, pSessionData->Session, pSessionData->LogonId.HighPart,
-                                   pSessionData->LogonId.LowPart, a_pUserInfo->wszAuthenticationPackage,
-                                   a_pUserInfo->wszLogonDomain);
+                                   pUserInfo->wszUser, pSessionData->Session, pSessionData->LogonId.HighPart,
+                                   pSessionData->LogonId.LowPart, pUserInfo->wszAuthenticationPackage,
+                                   pUserInfo->wszLogonDomain);
 
                 /* Detect RDP sessions as well. */
@@ -425,6 +428,6 @@
                     if (cbRet)
                         iState = *pBuffer;
-                    VBoxServiceVerbose(3, "VMInfo/Users:  Account User=%ls, WTSConnectState=%d\n",
-                                       a_pUserInfo->wszUser, iState);
+                    VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, WTSConnectState=%d\n",
+                                       pUserInfo->wszUser, iState);
                     if (    iState == WTSActive           /* User logged on to WinStation. */
                          || iState == WTSShadow           /* Shadowing another WinStation. */
@@ -433,6 +436,6 @@
                         /** @todo On Vista and W2K, always "old" user name are still
                          *        there. Filter out the old one! */
-                        VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls is logged in via TCS/RDP. State=%d\n",
-                                           a_pUserInfo->wszUser, iState);
+                        VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls using TCS/RDP, state=%d\n",
+                                           pUserInfo->wszUser, iState);
                         fFoundUser = true;
                     }
@@ -442,16 +445,30 @@
                 else
                 {
-                    VBoxServiceVerbose(3, "VMInfo/Users:  Account User=%ls, WTSConnectState returned %ld\n",
-                                       a_pUserInfo->wszUser, GetLastError());
-
-                    /*
-                     * Terminal services don't run (for example in W2K,
-                     * nothing to worry about ...).  ... or is on the Vista
-                     * fast user switching page!
-                     */
+                    DWORD dwLastErr = GetLastError();
+                    switch (dwLastErr)
+                    {
+                        /*
+                         * Terminal services don't run (for example in W2K,
+                         * nothing to worry about ...).  ... or is on the Vista
+                         * fast user switching page!
+                         */
+                        case ERROR_CTX_WINSTATION_NOT_FOUND:
+                            VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, no WinSta found\n",
+                                               pUserInfo->wszUser);
+                            break;
+
+                        default:
+                            VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls, error=%ld\n",
+                                               pUserInfo->wszUser, dwLastErr);
+                            break;
+                    }
+
                     fFoundUser = true;
                 }
             }
         }
+
+        VBoxServiceVerbose(3, "VMInfo/Users: Account User=%ls %s logged in\n",
+                           pUserInfo->wszUser, fFoundUser ? "is" : "is not");
     }
 
@@ -493,5 +510,5 @@
         return RTErrConvertFromWin32(rcWin);
     }
-    VBoxServiceVerbose(3, "VMInfo/Users: Found %ld users\n", cSession);
+    VBoxServiceVerbose(3, "VMInfo/Users: Found %ld sessions\n", cSession);
 
     PVBOXSERVICEVMINFOPROC  paProcs;
Index: /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp	(revision 38086)
+++ /trunk/src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp	(revision 38087)
@@ -262,6 +262,6 @@
            && RT_SUCCESS(rc))
     {
-        VBoxServiceVerbose(4, "VMInfo: Found logged in user \"%s\"\n", ut_user->ut_user);
-
+        VBoxServiceVerbose(4, "VMInfo/Users: Found logged in user \"%s\"\n",
+                           ut_user->ut_user);
         if (cUsersInList > cListSize)
         {
@@ -322,5 +322,5 @@
         cUsersInList = 0;
 
-    VBoxServiceVerbose(4, "VMInfo: cUsersInList: %u, pszUserList: %s, rc=%Rrc\n",
+    VBoxServiceVerbose(4, "VMInfo/Users: cUsersInList: %u, pszUserList: %s, rc=%Rrc\n",
                        cUsersInList, pszUserList ? pszUserList : "<NULL>", rc);
 
@@ -764,5 +764,5 @@
         if (idNewSession != g_idVMInfoSession)
         {
-            VBoxServiceVerbose(3, "VMInfo: The VM session ID changed, flushing all properties.\n");
+            VBoxServiceVerbose(3, "VMInfo: The VM session ID changed, flushing all properties\n");
             vboxserviceVMInfoWriteFixedProperties();
             VBoxServicePropCacheFlush(&g_VMInfoPropCache);
