VirtualBox

Ignore:
Timestamp:
Feb 16, 2012 5:06:35 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
76311
Message:

VBoxService/users-win: Added session change detection, more fun with logged-in user detection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxService/VBoxService-win.cpp

    r36338 r40158  
    136136    ss.dwCurrentState             = dwStatus;
    137137    ss.dwControlsAccepted         = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
     138#ifndef TARGET_NT4
     139    ss.dwControlsAccepted        |= SERVICE_ACCEPT_SESSIONCHANGE;
     140#endif
    138141    ss.dwWin32ExitCode            = NO_ERROR;
    139142    ss.dwServiceSpecificExitCode  = 0; /* Not used */
     
    379382
    380383
     384#ifndef TARGET_NT4
     385static const char* vboxServiceWTSStateToString(DWORD dwEvent)
     386{
     387    switch (dwEvent)
     388    {
     389        case WTS_CONSOLE_CONNECT:
     390            return "A session was connected to the console terminal";
     391
     392        case WTS_CONSOLE_DISCONNECT:
     393            return "A session was disconnected from the console terminal";
     394
     395        case WTS_REMOTE_CONNECT:
     396            return "A session connected to the remote terminal";
     397
     398        case WTS_REMOTE_DISCONNECT:
     399            return "A session was disconnected from the remote terminal";
     400
     401        case WTS_SESSION_LOGON:
     402            return "A user has logged on to a session";
     403
     404        case WTS_SESSION_LOGOFF:
     405            return "A user has logged off the session";
     406
     407        case WTS_SESSION_LOCK:
     408            return "A session has been locked";
     409
     410        case WTS_SESSION_UNLOCK:
     411            return "A session has been unlocked";
     412
     413        case WTS_SESSION_REMOTE_CONTROL:
     414            return "A session has changed its remote controlled status";
     415#if 0
     416        case WTS_SESSION_CREATE:
     417            return "A session has been created";
     418
     419        case WTS_SESSION_TERMINATE:
     420            return "The session has been terminated";
     421#endif
     422        default:
     423            break;
     424    }
     425
     426    return "Uknonwn state";
     427}
     428#endif /* !TARGET_NT4 */
     429
     430
    381431#ifdef TARGET_NT4
    382432static VOID WINAPI vboxServiceWinCtrlHandler(DWORD dwControl)
     
    417467        }
    418468
    419         case SERVICE_CONTROL_SESSIONCHANGE:     /* Only Win XP and up. */
    420 #ifndef TARGET_NT4
    421 # if 0
    422             switch (dwEventType)
    423             {
    424                 case WTS_SESSION_LOGON:
    425                     VBoxServiceVerbose(2, "A user has logged on to the session.\n");
    426                     break;
    427 
    428                 case WTS_SESSION_LOGOFF:
    429                     VBoxServiceVerbose(2, "A user has logged off from the session.\n");
    430                     break;
    431                 default:
    432                     break;
    433             }
    434 # endif
    435 #endif /* !TARGET_NT4 */
     469# ifndef TARGET_NT4
     470        case SERVICE_CONTROL_SESSIONCHANGE: /* Only Windows 2000 and up. */
     471        {
     472            AssertPtr(lpEventData);
     473            PWTSSESSION_NOTIFICATION pNotify = (PWTSSESSION_NOTIFICATION)lpEventData;
     474            Assert(pNotify->cbSize == sizeof(WTSSESSION_NOTIFICATION));
     475
     476            VBoxServiceVerbose(1, "Control handler: %s (Session=%ld, Event=%#x)\n",
     477                               vboxServiceWTSStateToString(dwEventType),
     478                               pNotify->dwSessionId, dwEventType);
     479
     480            /* Handle all events, regardless of dwEventType. */
     481            int rc2 = VBoxServiceVMInfoSignal();
     482            AssertRC(rc2);
    436483            break;
     484        }
     485# endif /* !TARGET_NT4 */
    437486
    438487        default:
    439             VBoxServiceVerbose(1, "Service control function not implemented: %#x\n", dwControl);
     488            VBoxServiceVerbose(1, "Control handler: Function not implemented: %#x\n", dwControl);
    440489            rcRet = ERROR_CALL_NOT_IMPLEMENTED;
    441490            break;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette