C# Класс PInvoke.AdvApi32

Показать файл Открыть проект

Открытые методы

Метод Описание
CreateService ( string lpBinaryPathName, string lpServiceName, string lpDisplayName, string lpDescription, string lpServiceStartName, string lpPassword ) : void

Creates a service object and adds it to service control manager database o the local computer.

CryptGetProvParam ( SafeHandle hProv, CryptGetProvParamQuery dwParam, uint dwFlags ) : byte[]

Retrieves parameters that govern the operations of a cryptographic service provider (CSP).

DeleteService ( string lpServiceName ) : void

Marks the specified service for deletion from the service control manager database on the local computer.

EnumServicesStatus ( ) : IEnumerable

Enumerates services in the specified service control manager database. The name and status of each service are provided.

GetTokenElevationType ( SafeObjectHandle TokenHandle ) : TOKEN_ELEVATION_TYPE

Get the elevation type of a token via GetTokenInformation(SafeObjectHandle, TOKEN_INFORMATION_CLASS, void*, int, out int).

QueryServiceObjectSecurity ( SafeServiceHandle hService, SECURITY_INFORMATION dwSecurityInformation ) : RawSecurityDescriptor

Retrieves a copy of the security descriptor associated with a service object. You can also use the GetNamedSecurityInfo function to retrieve a security descriptor.

SetServiceObjectSecurity ( SafeServiceHandle hService, SECURITY_INFORMATION dwSecurityInformation, RawSecurityDescriptor lpSecurityDescriptor ) : void

The SetServiceObjectSecurity function sets the security descriptor of a service object.

Приватные методы

Метод Описание
ChangeServiceConfig ( SafeServiceHandle hService, ServiceType dwServiceType, ServiceStartType dwStartType, ServiceErrorControl dwErrorControl, string lpBinaryPathName, string lpLoadOrderGroup, int lpdwTagId, string lpDependencies, string lpServiceStartName, string lpPassword, string lpDisplayName ) : bool
ChangeServiceConfig2 ( SafeServiceHandle hService, ServiceInfoLevel dwInfoLevel, void lpInfo ) : bool
CloseServiceHandle ( IntPtr hSCObject ) : bool
ControlService ( SafeServiceHandle hService, ServiceControl dwControl, SERVICE_STATUS &lpServiceStatus ) : bool
ConvertSidToStringSid ( IntPtr sid, char &sidString ) : bool
ConvertStringSidToSid ( string StringSid, void &sid ) : bool
CreateService ( SafeServiceHandle hSCManager, string lpServiceName, string lpDisplayName, ACCESS_MASK dwDesiredAccess, ServiceType dwServiceType, ServiceStartType dwStartType, ServiceErrorControl dwErrorControl, string lpBinaryPathName, string lpLoadOrderGroup, int lpdwTagId, string lpDependencies, string lpServiceStartName, string lpPassword ) : SafeServiceHandle
CryptGetProvParam ( SafeHandle hProv, CryptGetProvParamQuery dwParam, [ pbData, int &pdwDataLen, uint dwFlags ) : bool
CryptReleaseContext ( IntPtr hProv, uint dwFlags ) : bool
CryptSetProvParam ( SafeHandle hProv, CryptSetProvParamQuery dwParam, [ pbData, uint dwFlags ) : bool
DeleteService ( SafeServiceHandle hService ) : bool
DuplicateTokenEx ( SafeObjectHandle hExistingToken, ACCESS_MASK dwDesiredAccess, [ lpTokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, TOKEN_TYPE TokenType, SafeObjectHandle &phNewToken ) : bool
EnumServicesStatus ( SafeServiceHandle hSCManager, ServiceType dwServiceType, ServiceStateQuery dwServiceState, byte lpServices, int cbBufSize, int &pcbBytesNeeded, int &lpServicesReturned, int &lpResumeHandle ) : bool
GetNamedSecurityInfo ( string pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, void &ppsidOwner, void &ppsidGroup, [ ppDacl, [ ppSacl, [ ppSecurityDescriptor ) : Win32ErrorCode
GetSecurityInfo ( IntPtr handle, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, void &ppsidOwner, void &ppsidGroup, [ ppDacl, [ ppSacl, [ ppSecurityDescriptor ) : uint
GetTokenInformation ( SafeObjectHandle TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, void TokenInformation, int TokenInformationLength, int &ReturnLength ) : bool
LsaNtStatusToWinError ( NTSTATUS Status ) : Win32ErrorCode
OpenProcessToken ( IntPtr processHandle, ACCESS_MASK desiredAccess, SafeObjectHandle &tokenHandle ) : bool
OpenSCManager ( string lpMachineName, string lpDatabaseName, ACCESS_MASK dwDesiredAccess ) : SafeServiceHandle
OpenService ( SafeServiceHandle hSCManager, string lpServiceName, ACCESS_MASK dwDesiredAccess ) : SafeServiceHandle
QueryServiceObjectSecurity ( SafeServiceHandle hService, SECURITY_INFORMATION dwSecurityInformation, byte lpSecurityDescriptor, int cbBufSize, int &pcbBytesNeeded ) : bool
QueryServiceStatus ( SafeServiceHandle hService, SERVICE_STATUS &dwServiceStatus ) : bool
QueryServiceStatusEx ( SafeServiceHandle hService, SC_STATUS_TYPE InfoLevel, void lpBuffer, int cbBufSize, int &pcbBytesNeeded ) : bool
RegFlushKey ( SafeRegistryHandle hKey ) : Win32ErrorCode
RegNotifyChangeKeyValue ( SafeRegistryHandle hKey, bool bWatchSubtree, RegNotifyFilter dwNotifyFilter, SafeWaitHandle hEvent, bool fAsynchronous ) : Win32ErrorCode
RegOpenKeyEx ( SafeRegistryHandle hKey, string lpSubKey, RegOpenKeyOptions ulOptions, ACCESS_MASK samDesired, SafeRegistryHandle &phkResult ) : Win32ErrorCode
RegisterServiceCtrlHandler ( string lpServiceName, LPHANDLER_FUNCTION lpHandlerProc ) : IntPtr
RegisterServiceCtrlHandlerEx ( string lpServiceName, LPHANDLER_FUNCTION_EX lpHandlerProc, void lpContext ) : IntPtr
SetNamedSecurityInfo ( string pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, void psidOwner, void psidGroup, [ pDacl, [ pSacl ) : uint
SetSecurityInfo ( IntPtr handle, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, void psidOwner, void psidGroup, [ pDacl, [ pSacl ) : uint
SetServiceObjectSecurity ( SafeServiceHandle hService, SECURITY_INFORMATION dwSecurityInformation, byte lpSecurityDescriptor ) : bool
SetServiceStatus ( IntPtr hServiceStatus, SERVICE_STATUS &lpServiceStatus ) : bool
StartService ( SafeServiceHandle hService, int dwNumServiceArgs, string lpServiceArgVectors ) : bool

Описание методов

CreateService() публичный статический Метод

Creates a service object and adds it to service control manager database o the local computer.
If the method fails, returning the calling thread's last-error code value. or are NULL or empty string.
public static CreateService ( string lpBinaryPathName, string lpServiceName, string lpDisplayName, string lpDescription, string lpServiceStartName, string lpPassword ) : void
lpBinaryPathName string /// The fully qualified path to the service binary file. If the path contains a space, it must be quoted so that it is correctly interpreted. /// For example, "d:\\my share\\myservice.exe" should be specified as "\"d:\\my share\\myservice.exe\"". /// The path can also include arguments for an auto-start service. /// For example, "d:\\myshare\\myservice.exe arg1 arg2". /// These arguments are passed to the service entry point (typically the main function). ///
lpServiceName string /// The name of the service to install. The maximum string length is 256 characters. /// The service control manager database preserves the case of the characters, but service name comparisons are always case insensitive. /// Forward-slash (/) and backslash (\) are not valid service name characters. ///
lpDisplayName string /// The display name to be used by user interface programs to identify the service. /// This string has a maximum length of 256 characters. The name is case-preserved in the service control manager. /// Display name comparisons are always case-insensitive. ///
lpDescription string /// The description of the service. If this member is NULL, the description remains unchanged. /// If this value is an empty string (""), the current description is deleted. /// The service description must not exceed the size of a registry value of type REG_SZ. ///
lpServiceStartName string /// The name of the account under which the service should run. /// Use an account name in the form DomainName\UserName. The service process will be logged on as this user. /// If the account belongs to the built-in domain, you can specify .\UserName. ///
lpPassword string /// The password to the account name specified by the lpServiceStartName parameter. /// Specify an empty string if the account has no password or if the service runs in the LocalService, NetworkService, or LocalSystem account. /// If the account name specified by the parameter is the name of a managed service account or virtual account name, the lpPassword parameter must be NULL. ///
Результат void

CryptGetProvParam() публичный статический Метод

Retrieves parameters that govern the operations of a cryptographic service provider (CSP).
Thrown when an error occurs.
public static CryptGetProvParam ( SafeHandle hProv, CryptGetProvParamQuery dwParam, uint dwFlags ) : byte[]
hProv System.Runtime.InteropServices.SafeHandle A handle of the CSP target of the query. This handle must have been created by using the CryptAcquireContext function.
dwParam CryptGetProvParamQuery The nature of the query.
dwFlags uint /// If is , the security descriptor on the key container where the keys are stored is retrieved. /// For this case, is used to pass in the bit flags that indicate the requested security information, /// as defined in the Platform SDK. bit flags can be combined with a bitwise-OR operation. ///
Результат byte[]

DeleteService() публичный статический Метод

Marks the specified service for deletion from the service control manager database on the local computer.
If the method fails, returning the calling thread's last-error code value. is NULL or an empty string.
public static DeleteService ( string lpServiceName ) : void
lpServiceName string /// The name of the service to be opened. This is the name specified by the lpServiceName parameter of the function when the service object was created, /// not the service display name that is shown by user interface applications to identify the service. /// The maximum string length is 256 characters. The service control manager database preserves the case of the characters, /// but service name comparisons are always case insensitive. Forward-slash (/) and backslash (\) are invalid service name characters. ///
Результат void

EnumServicesStatus() публичный статический Метод

Enumerates services in the specified service control manager database. The name and status of each service are provided.
If the method fails, returning the calling thread's last-error code value.
public static EnumServicesStatus ( ) : IEnumerable
Результат IEnumerable

GetTokenElevationType() публичный статический Метод

Get the elevation type of a token via GetTokenInformation(SafeObjectHandle, TOKEN_INFORMATION_CLASS, void*, int, out int).
is NULL. If the call to fails.
public static GetTokenElevationType ( SafeObjectHandle TokenHandle ) : TOKEN_ELEVATION_TYPE
TokenHandle SafeObjectHandle /// A handle to an access token from which information is retrieved. The handle must have /// TOKEN_QUERY access. ///
Результат TOKEN_ELEVATION_TYPE

QueryServiceObjectSecurity() публичный статический Метод

Retrieves a copy of the security descriptor associated with a service object. You can also use the GetNamedSecurityInfo function to retrieve a security descriptor.
is NULL. If the call to the native method fails fails.
public static QueryServiceObjectSecurity ( SafeServiceHandle hService, SECURITY_INFORMATION dwSecurityInformation ) : RawSecurityDescriptor
hService SafeServiceHandle /// A handle to the service control manager or the service. Handles to the service control manager /// are returned by the function, and handles to a service are returned by either the /// or function. The handle must have the READ_CONTROL access /// right. ///
dwSecurityInformation SECURITY_INFORMATION /// A set of bit flags that indicate the type of security information to retrieve. This /// parameter can be a combination of the flags, with the exception that this /// function does not support the value. ///
Результат RawSecurityDescriptor

SetServiceObjectSecurity() публичный статический Метод

The SetServiceObjectSecurity function sets the security descriptor of a service object.
public static SetServiceObjectSecurity ( SafeServiceHandle hService, SECURITY_INFORMATION dwSecurityInformation, RawSecurityDescriptor lpSecurityDescriptor ) : void
hService SafeServiceHandle /// A handle to the service. This handle is returned by the or /// function. The access required for this handle depends on the security information /// specified in the parameter. ///
dwSecurityInformation SECURITY_INFORMATION /// Specifies the components of the security descriptor to set. This parameter can be a /// combination of the following values : , /// , /// , /// . Note that flags not handled by /// SetServiceObjectSecurity will be silently ignored. ///
lpSecurityDescriptor RawSecurityDescriptor The new security information.
Результат void