VirtualBox

Ignore:
Timestamp:
May 28, 2021 1:44:11 PM (4 years ago)
Author:
vboxsync
Message:

VBoxAutostart: bugref:9341, bugref:8161: Advertise that we accept
SERVICE_CONTROL_SHUTDOWN and stop the service when we get it. This
releases the references that keep VBoxSVC alive - and/or stuck around,
depending on how you view it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxAutostart/VBoxAutostart-win.cpp

    r89322 r89359  
    257257DECLHIDDEN(void) autostartSvcOsLogStr(const char *pszMsg, AUTOSTARTLOGTYPE enmLogType)
    258258{
     259    /* write it to the release log too */
     260    LogRel(("%s", pszMsg));
     261
    259262    HANDLE hEventLog = RegisterEventSourceA(NULL /* local computer */, "VBoxAutostartSvc");
    260263    AssertReturnVoid(hEventLog != NULL);
     
    295298    AssertMsg(fRc, ("%u\n", GetLastError())); NOREF(fRc);
    296299    DeregisterEventSource(hEventLog);
    297 
    298     /* write it to the release log too */
    299     LogRel(("%s", pszMsg));
    300300}
    301301
     
    704704            break;
    705705        default:
    706             SvcStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
     706            SvcStatus.dwControlsAccepted
     707                = SERVICE_ACCEPT_STOP
     708                | SERVICE_ACCEPT_SHUTDOWN;
    707709            break;
    708710    }
     
    738740autostartSvcWinServiceCtrlHandlerEx(DWORD dwControl, DWORD dwEventType, LPVOID pvEventData, LPVOID pvContext) RT_NOTHROW_DEF
    739741{
     742    RT_NOREF(dwEventType);
     743    RT_NOREF(pvEventData);
     744    RT_NOREF(pvContext);
     745
    740746    LogFlow(("autostartSvcWinServiceCtrlHandlerEx: dwControl=%#x dwEventType=%#x pvEventData=%p\n",
    741747             dwControl, dwEventType, pvEventData));
     
    754760         * Request to stop the service.
    755761         */
     762        case SERVICE_CONTROL_SHUTDOWN:
    756763        case SERVICE_CONTROL_STOP:
    757764        {
     765            if (dwControl == SERVICE_CONTROL_SHUTDOWN)
     766                LogRel(("SERVICE_CONTROL_SHUTDOWN\n"));
     767            else
     768                LogRel(("SERVICE_CONTROL_STOP\n"));
     769
    758770            /*
    759771             * Check if the real services can be stopped and then tell them to stop.
    760772             */
    761773            autostartSvcWinSetServiceStatus(SERVICE_STOP_PENDING, 3000, NO_ERROR);
     774
    762775            /*
    763776             * Notify the main thread that we're done, it will wait for the
     
    772785        }
    773786
    774         case SERVICE_CONTROL_PAUSE:
    775         case SERVICE_CONTROL_CONTINUE:
    776         case SERVICE_CONTROL_SHUTDOWN:
    777         case SERVICE_CONTROL_PARAMCHANGE:
    778         case SERVICE_CONTROL_NETBINDADD:
    779         case SERVICE_CONTROL_NETBINDREMOVE:
    780         case SERVICE_CONTROL_NETBINDENABLE:
    781         case SERVICE_CONTROL_NETBINDDISABLE:
    782         case SERVICE_CONTROL_DEVICEEVENT:
    783         case SERVICE_CONTROL_HARDWAREPROFILECHANGE:
    784         case SERVICE_CONTROL_POWEREVENT:
    785         case SERVICE_CONTROL_SESSIONCHANGE:
    786 #ifdef SERVICE_CONTROL_PRESHUTDOWN /* vista */
    787         case SERVICE_CONTROL_PRESHUTDOWN:
    788 #endif
    789787        default:
     788            /*
     789             * We only expect to receive controls we explicitly listed
     790             * in SERVICE_STATUS::dwControlsAccepted.  Logged in hex
     791             * b/c WinSvc.h defines them in hex
     792             */
     793            LogRel(("Unexpected service control message 0x%RX64\n",
     794                    (uint64_t)dwControl));
    790795            return ERROR_CALL_NOT_IMPLEMENTED;
    791796    }
    792797
    793     NOREF(dwEventType);
    794     NOREF(pvEventData);
    795     NOREF(pvContext);
    796798    /* not reached */
    797799}
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