3.1.4 Message Processing Events and Sequencing Rules

All Service Control Manager Remote Protocol operations begin with the client connection to the remote SCM and the client request to open the SCM database. After this database is opened, an RPC context handle is associated with this opened database, and this handle is returned to the client. The client can then perform operations on this database; for example, enumerate a list of existing services, open existing services, or install new services using this handle.

To operate on a service, the client MUST first request that the service be opened. After this service is opened, an RPC context handle is associated with this opened service and this handle is returned to the client. The client can then perform operations on the service; for example, change configuration, start, or stop.

When opening the database or a service, the server MUST open it with the access rights requested by the client if the client has sufficient permissions for the requested operation.

Note that the server SHOULD not open if the client does not have sufficient access rights for the requested operation. Similarly, the server MUST fail specific operations if the database or the service was not opened with sufficient access rights.

The access rights are represented as a bit field, and in addition to the standard access rights, as specified in ACCESS_MASK of [MS-DTYP], the Service Control Manager Remote Protocol MUST support the following access rights.

Value

Meaning

SERVICE_ALL_ACCESS

0x000F01FF

In addition to all access rights in this table, SERVICE_ALL_ACCESS includes Delete (DE), Read Control (RC), Write DACL (WD), and Write Owner (WO) access, as specified in ACCESS_MASK (section 2.4.3) of [MS-DTYP].

SERVICE_CHANGE_CONFIG

0x00000002

Required to change the configuration of a service.

SERVICE_ENUMERATE_DEPENDENTS

0x00000008

Required to enumerate the services installed on the server.

SERVICE_INTERROGATE

0x00000080

Required to request immediate status from the service.

SERVICE_PAUSE_CONTINUE

0x00000040

Required to pause or continue the service.

SERVICE_QUERY_CONFIG

0x00000001

Required to query the service configuration.

SERVICE_QUERY_STATUS

0x00000004

Required to request the service status.

SERVICE_START

0x00000010

Required to start the service.

SERVICE_STOP

0x00000020

Required to stop the service.

SERVICE_USER_DEFINED_CONTROL

0x00000100

Required to specify a user-defined control code.

SERVICE_SET_STATUS

0x00008000

Required for a service to set its status.

Specific access types for Service Control Manager object:

Value

Meaning

SC_MANAGER_LOCK

0x00000008

Required to lock the SCM database.

SC_MANAGER_CREATE_SERVICE

0x00000002

Required for a service to be created.

SC_MANAGER_ENUMERATE_SERVICE

0x00000004

Required to enumerate a service.

SC_MANAGER_CONNECT

0x00000001

Required to connect to the SCM.

SC_MANAGER_QUERY_LOCK_STATUS

0x00000010

Required to query the lock status of the SCM database.

SC_MANAGER_MODIFY_BOOT_CONFIG

0x0020

Required to call the RNotifyBootConfigStatus method.

The remainder of this section describes the server behavior for the RPC methods supported by the Service Control Manager Remote Protocol. The protocol clients can invoke the RPC methods specified in this section in any order after a Service Control Manager Remote Protocol session is established with the server. The outcome of the calls depends on the parameters passed to each of those calls. Clients and servers SHOULD<32> support multiplexed connections, as specified in [MS-RPCE] section 3.3.1.5.8.

Methods in RPC Opnum Order

Method

Description

RCloseServiceHandle

Closes handles to the SCM and any other associated services.

Opnum: 0

RControlService

Receives a control code for a specific service handle, as specified by the client.

Opnum: 1

RDeleteService

Marks the specified service for deletion from the SCM database.

Opnum: 2

RLockServiceDatabase

Acquires a lock on a service database.

Opnum: 3

RQueryServiceObjectSecurity

Returns a copy of the security descriptor associated with a service.

Opnum: 4

RSetServiceObjectSecurity

Sets the security descriptor associated with a service.

Opnum: 5

RQueryServiceStatus

Returns the current status of the specified service.

Opnum: 6

RSetServiceStatus

Updates the SCM status information for the calling service.

Opnum: 7

RUnlockServiceDatabase

Releases a lock on a service database.

Opnum: 8

RNotifyBootConfigStatus

Reports the boot status to the SCM.

Opnum: 9

Opnum10NotUsedOnWire

Reserved for local use.

Opnum: 10

RChangeServiceConfigW

Changes the configuration parameters of a service.

Opnum: 11

RCreateServiceW

Creates a service and adds it to the specified SCM database.

Opnum: 12

REnumDependentServicesW

Returns the name and status of each service that depends on the specified service.

Opnum: 13

REnumServicesStatusW

Enumerates services in the specified SCM database.

Opnum: 14

ROpenSCManagerW

Establishes a connection to the SCM on the specified computer and opens the specified SCM database.

Opnum: 15

ROpenServiceW

Opens a handle to an existing service.

Opnum: 16

RQueryServiceConfigW

Returns the configuration parameters of the specified service.

Opnum: 17

RQueryServiceLockStatusW

Returns the lock status of the specified SCM database.

Opnum: 18

RStartServiceW

Starts a specified service.

Opnum: 19

RGetServiceDisplayNameW

Returns the display name of the specified service.

Opnum: 20

RGetServiceKeyNameW

Returns the key name of the specified service.

Opnum: 21

Opnum22NotUsedOnWire

Reserved for local use.

Opnum: 22

RChangeServiceConfigA

Changes the configuration parameters of a service.

Opnum: 23

RCreateServiceA

Creates a service object and adds it to the specified SCM database.

Opnum: 24

REnumDependentServicesA

Returns the name and status of each service that depends on the specified service.

Opnum: 25

REnumServicesStatusA

Enumerates services in the specified SCM database.

Opnum: 26

ROpenSCManagerA

Opens a connection to the SCM from the client and opens the specified SCM database.

Opnum: 27

ROpenServiceA

Opens a handle to an existing service.

Opnum: 28

RQueryServiceConfigA

Returns the configuration parameters of the specified service.

Opnum: 29

RQueryServiceLockStatusA

Returns the lock status of the specified SCM database.

Opnum: 30

RStartServiceA

Starts a specified service.

Opnum: 31

RGetServiceDisplayNameA

Returns the display name of the specified service.

Opnum: 32

RGetServiceKeyNameA

Returns the key name of the specified service.

Opnum: 33

Opnum34NotUsedOnWire

Reserved for local use.

Opnum: 34

REnumServiceGroupW

Returns the members of a service group.

Opnum: 35

RChangeServiceConfig2A

Changes the optional configuration parameters of a service.

Opnum: 36

RChangeServiceConfig2W

Changes the optional configuration parameters of a service.

Opnum: 37

RQueryServiceConfig2A

Returns the optional configuration parameters of the specified service.

Opnum: 38

RQueryServiceConfig2W

Returns the optional configuration parameters of the specified service.

Opnum: 39

RQueryServiceStatusEx

Returns the current status of the specified service, based on the specified information level.

Opnum: 40

REnumServicesStatusExA

Enumerates services in the specified SCM database, based on the specified information level.

Opnum: 41

REnumServicesStatusExW

Enumerates services in the specified SCM database, based on the specified information level.

Opnum: 42

Opnum43NotUsedOnWire

Reserved for local use.

Opnum: 43

RCreateServiceWOW64A

Creates a 32-bit service in a 64-bit memory frame with the path to the file image automatically adjusted to point to the "%windir%\syswow64" area of the system drive. This method accepts ANSI strings, converting them to Unicode strings where required.

Opnum: 44

RCreateServiceWOW64W

Creates a 32-bit service in a 64-bit memory frame with the path to the file image automatically adjusted to point to the "%windir%\syswow64" area of the system drive. This method directly supports Unicode string values.

Opnum: 45

Opnum46NotUsedOnWire

Reserved for local use.

Opnum: 46

RNotifyServiceStatusChange

Allows the client to receive a notification when the specified service is created or deleted or when its status changes.

Opnum: 47

RGetNotifyResults

Returns notification information whenever the specified status change occurs on a specified service.

Opnum: 48

RCloseNotifyHandle

Unregisters the client from receiving future notifications from the server for specified status changes on a specified service.

Opnum: 49

RControlServiceExA

Receives a control code for a specific service.

Opnum: 50

RControlServiceExW

Receives a control code for a specific service.

Opnum: 51

Opnum52NotUsedOnWire

Reserved for local use.

Opnum: 52

Opnum53NotUsedOnWire

Reserved for local use.

Opnum: 53

Opnum54NotUsedOnWire

Reserved for local use.

Opnum: 54

Opnum55NotUsedOnWire

Reserved for local use.

Opnum: 55

RQueryServiceConfigEx

Returns the optional configuration parameters of the specified service.<33>

Opnum: 56

Opnum57NotUsedOnWire

Reserved for local use.

Opnum: 57

Opnum58NotUsedOnWire

Reserved for local use.

Opnum: 58

Opnum59NotUsedOnWire

Reserved for local use.

Opnum: 59

RCreateWowService

The RCreateWowService method creates a service whose binary is compiled for a specified computer architecture. The path to the file image is automatically adjusted to point to the correct WoW-redirected location. This method directly supports Unicode string values.

Opnum: 60

Opnum61NotUsedOnWire

Reserved for local use.

Opnum: 61

Opnum62NotUsedOnWire

Reserved for local use.

Opnum: 62

Opnum63NotUsedOnWire

Reserved for local use.

Opnum: 63

ROpenSCManager2

Establishes a connection to the SCM on the specified computer and opens the specified SCM database.

Opnum: 64

All methods MUST NOT throw exceptions.

Note that gaps in the opnum numbering sequence represent opnums that MUST NOT<34> be used over the wire.