3.1.1 Abstract Data Model

Services are programs that execute on a machine whose life cycle and execution properties are governed by the rules defined by the SCM. The state diagram that models these rules follows.

State Diagram in which life cycle and execution properties are governed by the rules defined in SCM

Figure 1: State Diagram in which life cycle and execution properties are governed by the rules defined in SCM

From state

To state

Cause

SERVICE_STOPPED

SERVICE_RUNNING

  • The client calls the StartService function to start the service. For more information, see [MSDN-STARTSERVICE].

  • The server started the service at system start.

SERVICE_STOPPED

SERVICE_START_PENDING

  • The client calls the StartService function to start the service. For more information, see [MSDN-STARTSERVICE].

  • The service asks the server to change its service status to SERVICE_START_PENDING status using the SetServiceStatus function if it requires more time to initialize before it can handle requests. For more information, see [MSDN-SetSvcStatus].

SERVICE_START_PENDING

SERVICE_RUNNING

  • The service asks the server to set its service status to SERVICE_RUNNING using the SetServiceStatus function when it is ready to handle requests. For more information, see [MSDN-SetSvcStatus].

SERVICE_START_PENDING

SERVICE_STOP_PENDING

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_STOP_PENDING using the SetServiceStatus function when it receives a stop request during initialization and requires time to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_START_PENDING

SERVICE_STOPPED

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_STOPPED using the SetServiceStatus function if it receives a stop request during initialization and is ready to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_STOP_PENDING

SERVICE_STOPPED

  • The service asks the server to set its service status to SERVICE_STOPPED using the SetServiceStatus function when it is ready to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_RUNNING

SERVICE_PAUSED

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_PAUSE to pause the service. The server sets the service's status to SERVICE_PAUSED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_PAUSED using the SetServiceStatus function if it is ready to pause. Otherwise, the service asks the server to set its service status to SERVICE_PAUSE_PENDING. For more information, see [MSDN-SetSvcStatus].

SERVICE_RUNNING

SERVICE_PAUSE_PENDING

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_PAUSE to pause the service. The server sets the service's status to SERVICE_PAUSED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_PAUSE_PENDING using the SetServiceStatus function if it receives a pause request and requires more time to pause. For more information, see [MSDN-SetSvcStatus].

SERVICE_RUNNING

SERVICE_STOPPED

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_STOPPED using the SetServiceStatus function if it receives a stop request and is ready to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_RUNNING

SERVICE_STOP_PENDING

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its status to SERVICE_STOP_PENDING using the SetServiceStatus function if it receives a stop request and requires more time to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_PAUSE_PENDING

SERVICE_PAUSED

  • The service asks the server to set its service status to SERVICE_PAUSED using the SetServiceStatus function if it is ready to pause. For more information, see [MSDN-SetSvcStatus].

SERVICE_PAUSE_PENDING

SERVICE_STOP_PENDING

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_STOP_PENDING using the SetServiceStatus function if it receives a stop request while it is preparing to pause and requires more time to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_PAUSE_PENDING

SERVICE_STOPPED

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_STOPPED using the SetServiceStatus function when it is ready to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_PAUSED

SERVICE_RUNNING

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_CONTINUE to resume a paused service. The server sets the service's status to SERVICE_RUNNING. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_CONTINUE_PENDING using the SetServiceStatus function. For more information, see [MSDN-SetSvcStatus].

SERVICE_PAUSED

SERVICE_CONTINUE_PENDING

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_CONTINUE to resume a paused service. The server sets the service's status to SERVICE_RUNNING. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_CONTINUE_PENDING using the SetServiceStatus function if it receives a continue request while it is paused and requires more time to resume. For more information, see [MSDN-SetSvcStatus].

SERVICE_PAUSED

SERVICE_STOP_PENDING

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_STOP_PENDING using the SetServiceStatus function if it receives a stop request while it is paused and requires more time to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_PAUSED

SERVICE_STOPPED

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_STOPPED using the SetServiceStatus function if it receives a stop request while it is paused and is ready to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_CONTINUE_PENDING

SERVICE_RUNNING

  • The service asks the server to set its service status to SERVICE_RUNNING using the SetServiceStatus function if it is ready to resume. For more information, see [MSDN-SetSvcStatus].

SERVICE_CONTINUE_PENDING

SERVICE_STOP_PENDING

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_STOP_PENDING using the SetServiceStatus function if it receives a stop request while it is resuming and requires more time to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

SERVICE_CONTINUE_PENDING

SERVICE_STOPPED

  • A client calls the ControlService or ControlServiceEx functions with SERVICE_CONTROL_STOP to stop the service. The server sets the service's status to SERVICE_STOPPED. For more information, see [MSDN-CtrlSvc] and [MSDN-CtrlSvcEx].

  • The service asks the server to set its service status to SERVICE_STOPPED using the SetServiceStatus function if it receives a stop request while it is resuming and is ready to stop. For more information, see [MSDN-SetSvcStatus].

  • The server stops a service at system shutdown.

The Service Control Manager Remote Protocol is used to manage these services on a remote machine by operating on the SCM on that machine.

The Service Control Manager maintains the following ADM elements.

Value

Meaning

SCM database

A collection of service records.

SecurityDescriptor

A security descriptor, as specified in [MS-AZOD] section 1.1.1.3, that is used to control an access to the SCM database.

GroupList

An ordered list of strings that services can specify as a ServiceGroup.

BootAccepted

A flag indicating whether a successful call to RNotifyBootConfigStatus has already been made to the server.

This element is not accessible via any method and is internal to the protocol implementation.

The SCM database is used by the Service Control Manager to add, modify, or configure services. Updates to the database are atomic. In the database there is a unique record, known as the service record, used to represent each installed service. A unique service name is used as the key for each service record.

The Service Record maintains the following ADM elements.

Value

Meaning

ServiceName

A unique name for the service.

  • Used as the key for the service record in the SCM database.

  • The string has a maximum length of SC_MAX_NAME_LENGTH.

  • Null and empty strings are not permitted.

  • The string is null terminated.

  • The forward slash, back slash, comma, and space characters are illegal in service names.

  • The case of the characters is preserved in the SCM database; however, service name comparisons are always case insensitive.

DisplayName

Service display name.

  • ANSI and Unicode character sets are supported.

  • This string has a maximum length of SC_MAX_NAME_LENGTH.

  • Null and empty strings are permitted. When not null, the string has to be null terminated.

The name is case-preserved in the Service Control Manager. Display name comparisons are always case-insensitive.

Can specify a localized string using the following format:<29>

  • @[path\]dllname,-strID

  • The string with identifier strID is loaded from dllname; the path is optional.

The DisplayName cannot match any other DisplayName or another ServiceName. The DisplayName can match the ServiceName if it they both refer to the same service.

Description

Description of the service.

  • ANSI and Unicode character sets are supported.

  • This string has a maximum length of 8192 characters.

  • Null and empty strings are permitted. When not null, the string has to be null terminated.

DependOnService

Service that starts before this service.

  • ANSI and Unicode character sets are supported.

  • This string has a maximum length of the size of SC_MAX_DEPEND_SIZE.

  • Null and empty strings are permitted. When not null, the string has to be double null terminated.

  • Multiple service names are separated by a null.

  • Direct or indirect circular dependencies on the same service are not allowed.

ErrorControl

Severity of the error if this service fails to start during startup. For the supported values, see dwErrorControl in section 3.1.4.11.

FailureActions

Actions that the service controller takes on each failure of the service.

These actions are queried and set using SERVICE_FAILURE_ACTIONSA (section 2.2.39) and SERVICE_FAILURE_ACTIONSW (section 2.2.40) via the RQueryServiceConfig2A (section 3.1.4.36), RQueryServiceConfig2W (section 3.1.4.37), RChangeServiceConfig2A (section 3.1.4.34), and RChangeServiceConfig2W (section 3.1.4.35) server methods.

ServiceGroup

Name of the service group the service belongs to for the purposes of load ordering. Each service can optionally specify only one group name.

ImagePath

Full qualified path to the service binary file.

ObjectName

If the service is a user-mode program, the name of the account under which the service executes. If the service is a driver, the name of the driver object that IO manager creates for the driver in the ObjectManager namespace.

Password

Password associated with the account specified in ObjectName.

RequiredPrivileges

Required privileges for the service. Privileges determine the type of system operations that can be performed. The privilege constants are detailed in [MS-LSAD] Privilege Data Model (section 3.1.1.2.1).

ServiceSidType

Type of service security identifier (SID).

FailureActionsOnNonCrashFailures

Failure action setting of a service that determines when FailureActions are to be executed.

DependOnGroup

Service groups that MUST be started before this service.

Start

Defines when to start the service.

Type

Type of service.

TriggerInfo

Trigger setting of the service.<30>

PreferredNode

Preferred node setting of the service.<31>

Tag

A number that is unique within the Group. Refer to the definition of Group as defined previously in this table.

For driver services that have SERVICE_BOOT_START or SERVICE_SYSTEM_START start types [see dwStartType in RChangeServiceConfigW (section 3.1.4.11), RCreateServiceW (section 3.1.4.12), RChangeServiceConfigA (section 3.1.4.22), RCreateServiceA (section 3.1.4.23), and RCreateServiceWOW64A (section 3.1.4.41)], the server starts each service based on its Tag's position within the Group.

SecurityDescriptor

A security descriptor, as specified in [MS-AZOD] section 1.1.1.3, that describes the client access rights for changing service configuration.

ServiceStatus

The server maintains a SERVICE_STATUS (section 2.2.47) to keep track of the service runtime information.

HandleCount

Counter for the number of RPC context handles currently created for this service record.

This element is not accessible via any method and is internal to the protocol implementation.

Deleted

The flag that is set when the service record has been marked for deletion.

This element is not accessible via any method and is internal to the protocol implementation.