VirtualBox

Ignore:
Timestamp:
Aug 24, 2022 9:56:54 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
153295
Message:

Add/NT/Inst,Add/NT/VBoxTray,Add/VBoxService: Cleaned up VBoxGuestInstallHelper.cpp (tested) and the VBoxTray IPC interface (not tested). The motivation for the former was to make it compile in no-CRT mode, the latter was buggy code. The IPC interface is not backwards compatible, this is intentional to avoid buggy code. bugref:10261

File:
1 edited

Legend:

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

    r96407 r96451  
    5858#include "../../WINNT/VBoxTray/VBoxTrayMsg.h" /* For IPC. */
    5959
    60 static uint32_t s_uDebugGuestPropClientID = 0;
    61 static uint32_t s_uDebugIter = 0;
    62 /** Whether to skip the logged-in user detection over RDP or not.
    63  *  See notes in this section why we might want to skip this. */
    64 static bool s_fSkipRDPDetection = false;
    65 
    6660
    6761/*********************************************************************************************************************************
     
    117111*   Global Variables                                                                                                             *
    118112*********************************************************************************************************************************/
     113static uint32_t s_uDebugGuestPropClientID = 0;
     114static uint32_t s_uDebugIter = 0;
     115/** Whether to skip the logged-in user detection over RDP or not.
     116 *  See notes in this section why we might want to skip this. */
     117static bool s_fSkipRDPDetection = false;
     118
    119119static RTONCE                                   g_vgsvcWinVmInitOnce = RTONCE_INITIALIZER;
    120120
     
    984984            {
    985985                /* .uMagic      = */ VBOXTRAY_IPC_HDR_MAGIC,
    986                 /* .uHdrVersion = */ 0,
    987                 /* .uMsgType    = */ VBOXTRAYIPCMSGTYPE_USERLASTINPUT,
    988                 /* .cbMsgData   = */ 0 /* No msg */
     986                /* .uVersion    = */ VBOXTRAY_IPC_HDR_VERSION,
     987                /* .enmMsgType  = */ VBOXTRAYIPCMSGTYPE_USER_LAST_INPUT,
     988                /* .cbPayload   = */ 0 /* No payload */
    989989            };
    990990
    991991            rc = RTLocalIpcSessionWrite(hSession, &ipcHdr, sizeof(ipcHdr));
    992 
    993992            if (RT_SUCCESS(rc))
    994993            {
    995                 VBOXTRAYIPCRES_USERLASTINPUT ipcRes;
    996                 rc = RTLocalIpcSessionRead(hSession, &ipcRes, sizeof(ipcRes), NULL /* Exact read */);
     994                VBOXTRAYIPCREPLY_USER_LAST_INPUT_T ipcReply;
     995                rc = RTLocalIpcSessionRead(hSession, &ipcReply, sizeof(ipcReply), NULL /* Exact read */);
    997996                if (   RT_SUCCESS(rc)
    998997                    /* If uLastInput is set to UINT32_MAX VBoxTray was not able to retrieve the
    999998                     * user's last input time. This might happen when running on Windows NT4 or older. */
    1000                     && ipcRes.uLastInput != UINT32_MAX)
     999                    && ipcReply.cSecSinceLastInput != UINT32_MAX)
    10011000                {
    1002                     userState = (ipcRes.uLastInput * 1000) < g_uVMInfoUserIdleThresholdMS
     1001                    userState = ipcReply.cSecSinceLastInput * 1000 < g_uVMInfoUserIdleThresholdMS
    10031002                              ? VBoxGuestUserState_InUse
    10041003                              : VBoxGuestUserState_Idle;
     
    10141013                    fReportToHost = rc == VINF_SUCCESS;
    10151014                    VGSvcVerbose(4, "User '%s' (domain '%s') is idle for %RU32, fReportToHost=%RTbool\n",
    1016                                  pszUser, pszDomain ? pszDomain : "<None>", ipcRes.uLastInput, fReportToHost);
     1015                                 pszUser, pszDomain ? pszDomain : "<None>", ipcReply.cSecSinceLastInput, fReportToHost);
    10171016
    10181017#if 0 /* Do we want to write the idle time as well? */
    10191018                        /* Also write the user's current idle time, if there is any. */
    10201019                        if (userState == VBoxGuestUserState_Idle)
    1021                             rc = vgsvcUserUpdateF(pCache, pszUser, pszDomain, "IdleTimeMs", "%RU32", ipcRes.uLastInputMs);
     1020                            rc = vgsvcUserUpdateF(pCache, pszUser, pszDomain, "IdleTimeMs", "%RU32", ipcReply.cSecSinceLastInput);
    10221021                        else
    10231022                            rc = vgsvcUserUpdateF(pCache, pszUser, pszDomain, "IdleTimeMs", NULL /* Delete property */);
     
    10271026                }
    10281027#ifdef DEBUG
    1029                 else if (RT_SUCCESS(rc) && ipcRes.uLastInput == UINT32_MAX)
     1028                else if (RT_SUCCESS(rc) && ipcReply.cSecSinceLastInput == UINT32_MAX)
    10301029                    VGSvcVerbose(4, "Last input for user '%s' is not supported, skipping\n", pszUser, rc);
    10311030#endif
Note: See TracChangeset for help on using the changeset viewer.

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