VirtualBox

Changeset 44114 in vbox


Ignore:
Timestamp:
Dec 13, 2012 9:21:40 AM (12 years ago)
Author:
vboxsync
Message:

VBoxService-win: Fixed SCM hangs on Windows 2000 guests.

File:
1 edited

Legend:

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

    r40158 r44114  
    2222#include <iprt/assert.h>
    2323#include <iprt/err.h>
     24#include <iprt/system.h> /* For querying OS version. */
    2425#include <VBox/VBoxGuestLib.h>
    2526#include "VBoxServiceInternal.h"
     
    133134
    134135    SERVICE_STATUS ss;
     136    RT_ZERO(ss);
     137
    135138    ss.dwServiceType              = SERVICE_WIN32_OWN_PROCESS;
    136139    ss.dwCurrentState             = dwStatus;
    137     ss.dwControlsAccepted         = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
     140    /* Don't accept controls when in start pending state. */
     141    if (ss.dwCurrentState != SERVICE_START_PENDING)
     142    {
     143        ss.dwControlsAccepted     = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
    138144#ifndef TARGET_NT4
    139     ss.dwControlsAccepted        |= SERVICE_ACCEPT_SESSIONCHANGE;
    140 #endif
     145        /* Don't use SERVICE_ACCEPT_SESSIONCHANGE on Windows 2000.
     146         * This makes SCM angry. */
     147        char szOSVersion[32];
     148        int rc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE,
     149                                     szOSVersion, sizeof(szOSVersion));
     150        if (RT_SUCCESS(rc))
     151        {
     152            if (RTStrVersionCompare(szOSVersion, "5.1") >= 0)
     153                ss.dwControlsAccepted |= SERVICE_ACCEPT_SESSIONCHANGE;
     154        }
     155        else
     156            VBoxServiceError("Error determining OS version, rc=%Rrc\n", rc);
     157#endif
     158    }
     159
    141160    ss.dwWin32ExitCode            = NO_ERROR;
    142161    ss.dwServiceSpecificExitCode  = 0; /* Not used */
     
    144163    ss.dwWaitHint                 = 3000;
    145164
    146     return SetServiceStatus(g_hWinServiceStatus, &ss);
     165    BOOL fStatusSet = SetServiceStatus(g_hWinServiceStatus, &ss);
     166    if (!fStatusSet)
     167        VBoxServiceError("Error reporting service status=%ld (controls=%x, checkpoint=%ld) to SCM: %ld\n",
     168                         dwStatus, ss.dwControlsAccepted, dwCheckPoint, GetLastError());
     169    return fStatusSet;
    147170}
    148171
     
    340363    if (RT_SUCCESS(rc))
    341364    {
     365        vboxServiceWinSetStatus(SERVICE_START_PENDING, 0);
     366
    342367        rc = VBoxServiceStartServices();
    343368        if (RT_SUCCESS(rc))
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