OpenSCManager

From aldeid
Jump to navigation Jump to search

Description

Establishes a connection to the service control manager on the specified computer and opens the specified service control manager database.

Syntax

SC_HANDLE WINAPI OpenSCManager(
  _In_opt_  LPCTSTR lpMachineName,
  _In_opt_  LPCTSTR lpDatabaseName,
  _In_      DWORD dwDesiredAccess
);

Parameters

lpMachineName [in, optional]
The name of the target computer. If the pointer is NULL or points to an empty string, the function connects to the service control manager on the local computer.
lpDatabaseName [in, optional]
The name of the service control manager database. This parameter should be set to SERVICES_ACTIVE_DATABASE. If it is NULL, the SERVICES_ACTIVE_DATABASE database is opened by default.
dwDesiredAccess [in]
The access to the service control manager.
Before granting the requested access rights, the system checks the access token of the calling process against the discretionary access-control list of the security descriptor associated with the service control manager.
The SC_MANAGER_CONNECT access right is implicitly specified by calling this function.

Return value

If the function succeeds, the return value is a handle to the specified service control manager database.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

The following error codes can be set by the SCM. Other error codes can be set by the registry functions that are called by the SCM.

Example

.text:00401074                 push    3               ; dwDesiredAccess
.text:00401076                 push    0               ; lpDatabaseName
.text:00401078                 push    0               ; lpMachineName
.text:0040107A                 call    ds:OpenSCManagerA

Comments