Author: ekohl Date: Sun Oct 24 13:48:11 2010 New Revision: 49259
URL: http://svn.reactos.org/svn/reactos?rev=49259&view=rev Log: [SERVICES] RControlService: Check the current state before sending a control request.
Modified: trunk/reactos/base/system/services/rpcserver.c
Modified: trunk/reactos/base/system/services/rpcserver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/services/rpcser... ============================================================================== --- trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] (original) +++ trunk/reactos/base/system/services/rpcserver.c [iso-8859-1] Sun Oct 24 13:48:11 2010 @@ -553,6 +553,7 @@ DWORD pcbBytesNeeded = 0; DWORD dwServicesReturned = 0; DWORD dwControlsAccepted; + DWORD dwCurrentState; HKEY hServicesKey = NULL;
DPRINT("RControlService() called\n"); @@ -655,8 +656,34 @@ else { dwControlsAccepted = lpService->Status.dwControlsAccepted; - - /* Check if the control code is acceptable */ + dwCurrentState = lpService->Status.dwCurrentState; + + /* Check the current state before sending a control request */ + switch (dwCurrentState) + { + case SERVICE_STOP_PENDING: + case SERVICE_STOPPED: + return ERROR_SERVICE_CANNOT_ACCEPT_CTRL; + + case SERVICE_START_PENDING: + switch (dwControl) + { + case SERVICE_CONTROL_STOP: + break; + + case SERVICE_CONTROL_INTERROGATE: + RtlCopyMemory(lpServiceStatus, + &lpService->Status, + sizeof(SERVICE_STATUS)); + return ERROR_SUCCESS; + + default: + return ERROR_SERVICE_CANNOT_ACCEPT_CTRL; + } + break; + } + + /* Check if the control code is acceptable to the service */ switch (dwControl) { case SERVICE_CONTROL_STOP: