public interface Advapi32 extends StdCallLibrary
StdCallLibrary.StdCallCallback
Library.Handler
Modifier and Type | Field and Description |
---|---|
static Advapi32 |
INSTANCE |
static int |
LOGON_NETCREDENTIALS_ONLY
LOGON_NETCREDENTIALS_ONLY: 0x00000002
Log on, but use the specified credentials on the network only. |
static int |
LOGON_WITH_PROFILE
LOGON_WITH_PROFILE: 0x00000001
Log on, then load the user profile in the HKEY_USERS registry key. |
static int |
MAX_KEY_LENGTH |
static int |
MAX_VALUE_NAME |
static int |
RRF_RT_ANY |
static int |
RRF_RT_DWORD |
static int |
RRF_RT_QWORD |
static int |
RRF_RT_REG_BINARY |
static int |
RRF_RT_REG_DWORD |
static int |
RRF_RT_REG_EXPAND_SZ |
static int |
RRF_RT_REG_MULTI_SZ |
static int |
RRF_RT_REG_NONE |
static int |
RRF_RT_REG_QWORD |
static int |
RRF_RT_REG_SZ |
FUNCTION_MAPPER, STDCALL_CONVENTION
OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_TYPE_MAPPER
Modifier and Type | Method and Description |
---|---|
boolean |
AccessCheck(Pointer pSecurityDescriptor,
WinNT.HANDLE ClientToken,
WinDef.DWORD DesiredAccess,
WinNT.GENERIC_MAPPING GenericMapping,
WinNT.PRIVILEGE_SET PrivilegeSet,
WinDef.DWORDByReference PrivilegeSetLength,
WinDef.DWORDByReference GrantedAccess,
WinDef.BOOLByReference AccessStatus)
Check if the if the security descriptor grants access to the given client token.
|
boolean |
AddAccessAllowedAce(WinNT.ACL pAcl,
int dwAceRevision,
int AccessMask,
WinNT.PSID pSid)
The AddAce function adds one or more access control entries (ACEs) to a specified access control list (ACL).
|
boolean |
AddAccessAllowedAceEx(WinNT.ACL pAcl,
int dwAceRevision,
int AceFlags,
int AccessMask,
WinNT.PSID pSid)
The AddAce function adds one or more access control entries (ACEs) to a specified access control list (ACL).
|
boolean |
AddAce(WinNT.ACL pAcl,
int dwAceRevision,
int dwStartingAceIndex,
Pointer pAceList,
int nAceListLength)
The AddAce function adds one or more access control entries (ACEs) to a specified access control list (ACL).
|
boolean |
AdjustTokenPrivileges(WinNT.HANDLE TokenHandle,
boolean DisableAllPrivileges,
WinNT.TOKEN_PRIVILEGES NewState,
int BufferLength,
WinNT.TOKEN_PRIVILEGES PreviousState,
IntByReference ReturnLength)
The AdjustTokenPrivileges function enables or disables privileges in the
specified access token.
|
boolean |
BackupEventLog(WinNT.HANDLE hEventLog,
java.lang.String lpBackupFileName)
Saves the specified event log to a backup file.
|
boolean |
ChangeServiceConfig2(Winsvc.SC_HANDLE hService,
int dwInfoLevel,
Winsvc.ChangeServiceConfig2Info lpInfo)
Changes the optional configuration parameters of a service.
|
boolean |
ClearEventLog(WinNT.HANDLE hEventLog,
java.lang.String lpBackupFileName)
Clears the specified event log, and optionally saves the current copy of
the log to a backup file.
|
void |
CloseEncryptedFileRaw(Pointer pvContext)
Closes an encrypted file after a backup or restore operation, and frees
associated system resources.
|
boolean |
CloseEventLog(WinNT.HANDLE hEventLog)
Closes the specified event log.
|
boolean |
CloseServiceHandle(Winsvc.SC_HANDLE hSCObject)
Closes a handle to a service control manager or service object.
|
boolean |
ControlService(Winsvc.SC_HANDLE hService,
int dwControl,
Winsvc.SERVICE_STATUS lpServiceStatus)
Sends a control code to a service.
|
boolean |
ConvertSidToStringSid(WinNT.PSID Sid,
PointerByReference StringSid)
Convert a security identifier (SID) to a string format suitable for
display, storage, or transmission.
|
boolean |
ConvertStringSidToSid(java.lang.String StringSid,
WinNT.PSIDByReference Sid)
Convert a string-format security identifier (SID) into a valid,
functional SID.
|
boolean |
CreateProcessAsUser(WinNT.HANDLE hToken,
java.lang.String lpApplicationName,
java.lang.String lpCommandLine,
WinBase.SECURITY_ATTRIBUTES lpProcessAttributes,
WinBase.SECURITY_ATTRIBUTES lpThreadAttributes,
boolean bInheritHandles,
int dwCreationFlags,
java.lang.String lpEnvironment,
java.lang.String lpCurrentDirectory,
WinBase.STARTUPINFO lpStartupInfo,
WinBase.PROCESS_INFORMATION lpProcessInformation)
Creates a new process and its primary thread.
|
boolean |
CreateProcessWithLogonW(java.lang.String lpUsername,
java.lang.String lpDomain,
java.lang.String lpPassword,
int dwLogonFlags,
java.lang.String lpApplicationName,
java.lang.String lpCommandLine,
int dwCreationFlags,
Pointer lpEnvironment,
java.lang.String lpCurrentDirectory,
WinBase.STARTUPINFO lpStartupInfo,
WinBase.PROCESS_INFORMATION lpProcessInfo)
BOOL WINAPI CreateProcessWithLogonW(
_In_ LPCWSTR lpUsername,
_In_opt_ LPCWSTR lpDomain,
_In_ LPCWSTR lpPassword,
_In_ DWORD dwLogonFlags,
_In_opt_ LPCWSTR lpApplicationName,
_Inout_opt_ LPWSTR lpCommandLine,
_In_ DWORD dwCreationFlags,
_In_opt_ LPVOID lpEnvironment,
_In_opt_ LPCWSTR lpCurrentDirectory,
_In_ LPSTARTUPINFOW lpStartupInfo,
_Out_ LPPROCESS_INFORMATION lpProcessInfo
);
|
Winsvc.SC_HANDLE |
CreateService(Winsvc.SC_HANDLE hSCManager,
java.lang.String lpServiceName,
java.lang.String lpDisplayName,
int dwDesiredAccess,
int dwServiceType,
int dwStartType,
int dwErrorControl,
java.lang.String lpBinaryPathName,
java.lang.String lpLoadOrderGroup,
IntByReference lpdwTagId,
java.lang.String lpDependencies,
java.lang.String lpServiceStartName,
java.lang.String lpPassword)
Creates a service object and adds it to the specified service control
manager database.
|
boolean |
CreateWellKnownSid(int wellKnownSidType,
WinNT.PSID domainSid,
WinNT.PSID pSid,
IntByReference cbSid)
The CreateWellKnownSid function creates a SID for predefined aliases.
|
boolean |
DecryptFile(java.lang.String lpFileName,
WinDef.DWORD dwReserved)
Decrypts an encrypted file or directory.
|
boolean |
DeleteService(Winsvc.SC_HANDLE hService)
Marks the specified service for deletion from the service control manager database.
|
boolean |
DeregisterEventSource(WinNT.HANDLE hEventLog)
Closes the specified event log.
|
boolean |
DuplicateToken(WinNT.HANDLE ExistingTokenHandle,
int ImpersonationLevel,
WinNT.HANDLEByReference DuplicateTokenHandle)
The DuplicateToken function creates a new access token that duplicates
one already in existence.
|
boolean |
DuplicateTokenEx(WinNT.HANDLE hExistingToken,
int dwDesiredAccess,
WinBase.SECURITY_ATTRIBUTES lpTokenAttributes,
int ImpersonationLevel,
int TokenType,
WinNT.HANDLEByReference phNewToken)
The DuplicateTokenEx function creates a new access token that duplicates
an existing token.
|
boolean |
EncryptFile(java.lang.String lpFileName)
Encrypts a file or directory.
|
boolean |
EncryptionDisable(java.lang.String DirPath,
boolean Disable)
Disables or enables encryption of the specified directory and the files in
it.
|
boolean |
EnumDependentServices(Winsvc.SC_HANDLE hService,
int dwServiceState,
Pointer lpService,
int cbBufSize,
IntByReference pcbBytesNeeded,
IntByReference lpServicesReturned)
Retrieves the name and status of each service that depends on the
specified service; that is, the specified service must be running before
the dependent services can run.
|
boolean |
EnumServicesStatusEx(Winsvc.SC_HANDLE hSCManager,
int InfoLevel,
int dwServiceType,
int dwServiceState,
Pointer lpServices,
int cbBufSize,
IntByReference pcbBytesNeeded,
IntByReference lpServicesReturned,
IntByReference lpResumeHandle,
java.lang.String pszGroupName)
Enumerates services in the specified service control manager database.
|
boolean |
EqualSid(WinNT.PSID pSid1,
WinNT.PSID pSid2)
he EqualSid function tests two security identifier (SID) values for equality.
|
boolean |
FileEncryptionStatus(java.lang.String lpFileName,
WinDef.DWORDByReference lpStatus)
Retrieves the encryption status of the specified file.
|
boolean |
GetAce(WinNT.ACL pAcl,
int dwAceIndex,
PointerByReference pAce)
The GetAce function obtains a pointer to an access control entry (ACE) in an access
control list (ACL).
|
boolean |
GetFileSecurity(java.lang.String lpFileName,
int RequestedInformation,
Pointer pointer,
int nLength,
IntByReference lpnLengthNeeded)
The function obtains specified information about the security of a file
or directory.
|
int |
GetLengthSid(WinNT.PSID pSid)
Returns the length, in bytes, of a valid security identifier (SID).
|
int |
GetNamedSecurityInfo(java.lang.String pObjectName,
int ObjectType,
int SecurityInfo,
PointerByReference ppsidOwner,
PointerByReference ppsidGroup,
PointerByReference ppDacl,
PointerByReference ppSacl,
PointerByReference ppSecurityDescriptor)
The GetNamedSecurityInfo function retrieves a copy of the security
descriptor for an object specified by name
|
boolean |
GetNumberOfEventLogRecords(WinNT.HANDLE hEventLog,
IntByReference NumberOfRecords)
Retrieves the number of records in the specified event log.
|
boolean |
GetOldestEventLogRecord(WinNT.HANDLE hEventLog,
IntByReference OldestRecord)
The GetOldestEventLogRecord function retrieves the absolute record number
of the oldest record in the specified event log.
|
boolean |
GetSecurityDescriptorControl(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor,
ShortByReference pControl,
IntByReference lpdwRevision)
The GetSecurityDescriptorControl function retrieves a security descriptor control and revision information.
|
boolean |
GetSecurityDescriptorDacl(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor,
WinDef.BOOLByReference bDaclPresent,
WinNT.PACLByReference pDacl,
WinDef.BOOLByReference bDaclDefaulted)
The GetSecurityDescriptorDacl function retrieves a pointer to the discretionary access control list (DACL) in
a specified security descriptor.
|
boolean |
GetSecurityDescriptorGroup(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor,
WinNT.PSIDByReference pGroup,
WinDef.BOOLByReference lpbGroupDefaulted)
The GetSecurityDescriptorGroup function retrieves the primary group information from a security descriptor.
|
int |
GetSecurityDescriptorLength(Pointer ppSecurityDescriptor)
The GetSecurityDescriptorLength function returns the length, in bytes, of a structurally
valid security descriptor.
|
boolean |
GetSecurityDescriptorOwner(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor,
WinNT.PSIDByReference pOwner,
WinDef.BOOLByReference lpbOwnerDefaulted)
The GetSecurityDescriptorOwner function retrieves the owner information from a security descriptor.
|
int |
GetSecurityInfo(WinNT.HANDLE handle,
int ObjectType,
int SecurityInfo,
PointerByReference ppsidOwner,
PointerByReference ppsidGroup,
PointerByReference ppDacl,
PointerByReference ppSacl,
PointerByReference ppSecurityDescriptor)
The GetSecurityInfo function retrieves a copy of the security descriptor for an object specified by a handle.
|
boolean |
GetTokenInformation(WinNT.HANDLE tokenHandle,
int tokenInformationClass,
Structure tokenInformation,
int tokenInformationLength,
IntByReference returnLength)
Retrieves a specified type of information about an access token.
|
boolean |
GetUserNameW(char[] buffer,
IntByReference len)
Retrieves the name of the user associated with the current thread.
|
boolean |
ImpersonateLoggedOnUser(WinNT.HANDLE hToken)
The ImpersonateLoggedOnUser function lets the calling thread impersonate
the security context of a logged-on user.
|
boolean |
ImpersonateSelf(int ImpersonationLevel)
The ImpersonateSelf function obtains an access token that impersonates
the security context of the calling process.
|
boolean |
InitializeAcl(WinNT.ACL pAcl,
int nAclLength,
int dwAclRevision)
The InitializeAcl function initializes a new ACL structure.
|
boolean |
InitializeSecurityDescriptor(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor,
int dwRevision)
The InitializeSecurityDescriptor function initializes a new security descriptor.
|
boolean |
IsValidAcl(Pointer pAcl)
The IsValidAcl function validates an access control list (ACL).
|
boolean |
IsValidSecurityDescriptor(Pointer ppSecurityDescriptor)
The IsValidSecurityDescriptor function determines whether the components of a security descriptor are valid.
|
boolean |
IsValidSid(WinNT.PSID pSid)
The IsValidSid function validates a security identifier (SID) by
verifying that the revision number is within a known range, and that the
number of subauthorities is less than the maximum.
|
boolean |
IsWellKnownSid(WinNT.PSID pSid,
int wellKnownSidType)
Compares a SID to a well known SID and returns TRUE if they match.
|
boolean |
LogonUser(java.lang.String lpszUsername,
java.lang.String lpszDomain,
java.lang.String lpszPassword,
int logonType,
int logonProvider,
WinNT.HANDLEByReference phToken)
The LogonUser function attempts to log a user on to the local computer.
|
boolean |
LookupAccountName(java.lang.String lpSystemName,
java.lang.String lpAccountName,
WinNT.PSID Sid,
IntByReference cbSid,
char[] ReferencedDomainName,
IntByReference cchReferencedDomainName,
PointerByReference peUse)
Accepts the name of a system and anaccount as input and retrieves a
security identifier (SID) for the account and the name of the domain on
which the account was found.
|
boolean |
LookupAccountSid(java.lang.String lpSystemName,
WinNT.PSID Sid,
char[] lpName,
IntByReference cchName,
char[] ReferencedDomainName,
IntByReference cchReferencedDomainName,
PointerByReference peUse)
Retrieves the name of the account for this SID and the name of the first
domain on which this SID is found.
|
boolean |
LookupPrivilegeName(java.lang.String lpSystemName,
WinNT.LUID lpLuid,
char[] lpName,
IntByReference cchName)
The LookupPrivilegeName function retrieves the name that corresponds to
the privilege represented on a specific system by a specified locally
unique identifier (LUID).
|
boolean |
LookupPrivilegeValue(java.lang.String lpSystemName,
java.lang.String lpName,
WinNT.LUID lpLuid)
The LookupPrivilegeValue function retrieves the locally unique identifier
(LUID) used on a specified system to locally represent the specified
privilege name.
|
boolean |
MakeAbsoluteSD(WinNT.SECURITY_DESCRIPTOR_RELATIVE pSelfRelativeSD,
WinNT.SECURITY_DESCRIPTOR pAbsoluteSD,
IntByReference lpdwAbsoluteSDSize,
WinNT.ACL pDacl,
IntByReference lpdwDaclSize,
WinNT.ACL pSacl,
IntByReference lpdwSaclSize,
WinNT.PSID pOwner,
IntByReference lpdwOwnerSize,
WinNT.PSID pPrimaryGroup,
IntByReference lpdwPrimaryGroupSize)
The MakeAbsoluteSD function creates a security descriptor in absolute format by using a
security descriptor in self-relative format as a template.
|
boolean |
MakeSelfRelativeSD(WinNT.SECURITY_DESCRIPTOR pAbsoluteSD,
WinNT.SECURITY_DESCRIPTOR_RELATIVE pSelfRelativeSD,
IntByReference lpdwBufferLength)
A pointer to a SECURITY_DESCRIPTOR structure in absolute format.
|
void |
MapGenericMask(WinDef.DWORDByReference AccessMask,
WinNT.GENERIC_MAPPING GenericMapping)
Applies the given mapping of generic access rights to the given access mask.
|
WinNT.HANDLE |
OpenBackupEventLog(java.lang.String lpUNCServerName,
java.lang.String lpFileName)
Opens a handle to a backup event log created by the BackupEventLog
function.
|
int |
OpenEncryptedFileRaw(java.lang.String lpFileName,
WinDef.ULONG ulFlags,
PointerByReference pvContext)
Opens an encrypted file in order to backup (export) or restore (import) the
file.
|
WinNT.HANDLE |
OpenEventLog(java.lang.String lpUNCServerName,
java.lang.String lpSourceName)
Opens a handle to the specified event log.
|
boolean |
OpenProcessToken(WinNT.HANDLE ProcessHandle,
int DesiredAccess,
WinNT.HANDLEByReference TokenHandle)
The OpenProcessToken function opens the access token associated with a
process.
|
Winsvc.SC_HANDLE |
OpenSCManager(java.lang.String lpMachineName,
java.lang.String lpDatabaseName,
int dwDesiredAccess)
Establishes a connection to the service control manager on the specified
computer and opens the specified service control manager database.
|
Winsvc.SC_HANDLE |
OpenService(Winsvc.SC_HANDLE hSCManager,
java.lang.String lpServiceName,
int dwDesiredAccess)
Opens an existing service.
|
boolean |
OpenThreadToken(WinNT.HANDLE ThreadHandle,
int DesiredAccess,
boolean OpenAsSelf,
WinNT.HANDLEByReference TokenHandle)
The OpenThreadToken function opens the access token associated with a
thread.
|
boolean |
QueryServiceConfig2(Winsvc.SC_HANDLE hService,
int dwInfoLevel,
Pointer lpBuffer,
int cbBufSize,
IntByReference pcbBytesNeeded)
Retrieves the optional configuration parameters of the specified service.
|
boolean |
QueryServiceStatus(Winsvc.SC_HANDLE hService,
Winsvc.SERVICE_STATUS lpServiceStatus)
Retrieves the current status of the specified service based on the
specified information level.
|
boolean |
QueryServiceStatusEx(Winsvc.SC_HANDLE hService,
int InfoLevel,
Winsvc.SERVICE_STATUS_PROCESS lpBuffer,
int cbBufSize,
IntByReference pcbBytesNeeded)
Retrieves the current status of the specified service based on the
specified information level.
|
int |
ReadEncryptedFileRaw(WinBase.FE_EXPORT_FUNC pfExportCallback,
Pointer pvCallbackContext,
Pointer pvContext)
Backs up (export) encrypted files.
|
boolean |
ReadEventLog(WinNT.HANDLE hEventLog,
int dwReadFlags,
int dwRecordOffset,
Pointer lpBuffer,
int nNumberOfBytesToRead,
IntByReference pnBytesRead,
IntByReference pnMinNumberOfBytesNeeded)
Reads the specified number of entries from the specified event log.
|
int |
RegCloseKey(WinReg.HKEY hKey)
The RegCloseKey function releases a handle to the specified registry key.
|
int |
RegConnectRegistry(java.lang.String lpMachineName,
WinReg.HKEY hKey,
WinReg.HKEYByReference phkResult)
Establishes a connection to a predefined registry key on another
computer.
|
int |
RegCreateKeyEx(WinReg.HKEY hKey,
java.lang.String lpSubKey,
int Reserved,
java.lang.String lpClass,
int dwOptions,
int samDesired,
WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes,
WinReg.HKEYByReference phkResult,
IntByReference lpdwDisposition) |
int |
RegDeleteKey(WinReg.HKEY hKey,
java.lang.String name) |
int |
RegDeleteValue(WinReg.HKEY hKey,
java.lang.String lpValueName)
The RegDeleteValue function removes a named value from the specified
registry key.
|
int |
RegEnumKeyEx(WinReg.HKEY hKey,
int dwIndex,
char[] lpName,
IntByReference lpcName,
IntByReference reserved,
char[] lpClass,
IntByReference lpcClass,
WinBase.FILETIME lpftLastWriteTime)
The RegEnumKeyEx function enumerates subkeys of the specified open
registry key.
|
int |
RegEnumValue(WinReg.HKEY hKey,
int dwIndex,
char[] lpValueName,
IntByReference lpcchValueName,
IntByReference reserved,
IntByReference lpType,
byte[] lpData,
IntByReference lpcbData)
|
int |
RegEnumValue(WinReg.HKEY hKey,
int dwIndex,
char[] lpValueName,
IntByReference lpcchValueName,
IntByReference reserved,
IntByReference lpType,
Pointer lpData,
IntByReference lpcbData)
The RegEnumValue function enumerates the values for the specified open
registry key.
|
int |
RegGetValue(WinReg.HKEY hkey,
java.lang.String lpSubKey,
java.lang.String lpValue,
int dwFlags,
IntByReference pdwType,
byte[] pvData,
IntByReference pcbData)
|
int |
RegGetValue(WinReg.HKEY hkey,
java.lang.String lpSubKey,
java.lang.String lpValue,
int dwFlags,
IntByReference pdwType,
Pointer pvData,
IntByReference pcbData)
Retrieves the type and data for the specified registry value.
|
WinNT.HANDLE |
RegisterEventSource(java.lang.String lpUNCServerName,
java.lang.String lpSourceName)
Retrieves a registered handle to the specified event log.
|
Winsvc.SERVICE_STATUS_HANDLE |
RegisterServiceCtrlHandler(java.lang.String lpServiceName,
Library.Handler lpHandlerProc)
Registers a function to handle service control requests.
|
Winsvc.SERVICE_STATUS_HANDLE |
RegisterServiceCtrlHandlerEx(java.lang.String lpServiceName,
Winsvc.HandlerEx lpHandlerProc,
Pointer lpContext)
Registers a function to handle extended service control requests.
|
int |
RegOpenKeyEx(WinReg.HKEY hKey,
java.lang.String lpSubKey,
int ulOptions,
int samDesired,
WinReg.HKEYByReference phkResult)
The RegOpenKeyEx function opens the specified registry key.
|
int |
RegQueryInfoKey(WinReg.HKEY hKey,
char[] lpClass,
IntByReference lpcClass,
IntByReference lpReserved,
IntByReference lpcSubKeys,
IntByReference lpcMaxSubKeyLen,
IntByReference lpcMaxClassLen,
IntByReference lpcValues,
IntByReference lpcMaxValueNameLen,
IntByReference lpcMaxValueLen,
IntByReference lpcbSecurityDescriptor,
WinBase.FILETIME lpftLastWriteTime)
The RegQueryInfoKey function retrieves information about the specified
registry key.
|
int |
RegQueryValueEx(WinReg.HKEY hKey,
java.lang.String lpValueName,
int lpReserved,
IntByReference lpType,
byte[] lpData,
IntByReference lpcbData) |
int |
RegQueryValueEx(WinReg.HKEY hKey,
java.lang.String lpValueName,
int lpReserved,
IntByReference lpType,
char[] lpData,
IntByReference lpcbData)
The RegQueryValueEx function retrieves the type and data for a specified
value name associated with an open registry key.
|
int |
RegQueryValueEx(WinReg.HKEY hKey,
java.lang.String lpValueName,
int lpReserved,
IntByReference lpType,
IntByReference lpData,
IntByReference lpcbData) |
int |
RegQueryValueEx(WinReg.HKEY hKey,
java.lang.String lpValueName,
int lpReserved,
IntByReference lpType,
LongByReference lpData,
IntByReference lpcbData) |
int |
RegQueryValueEx(WinReg.HKEY hKey,
java.lang.String lpValueName,
int lpReserved,
IntByReference lpType,
Pointer lpData,
IntByReference lpcbData) |
int |
RegSetValueEx(WinReg.HKEY hKey,
java.lang.String lpValueName,
int Reserved,
int dwType,
byte[] lpData,
int cbData)
|
int |
RegSetValueEx(WinReg.HKEY hKey,
java.lang.String lpValueName,
int Reserved,
int dwType,
char[] lpData,
int cbData)
|
int |
RegSetValueEx(WinReg.HKEY hKey,
java.lang.String lpValueName,
int Reserved,
int dwType,
Pointer lpData,
int cbData)
The RegSetValueEx function sets the data and type of a specified value
under a registry key.
|
boolean |
ReportEvent(WinNT.HANDLE hEventLog,
int wType,
int wCategory,
int dwEventID,
WinNT.PSID lpUserSid,
int wNumStrings,
int dwDataSize,
java.lang.String[] lpStrings,
Pointer lpRawData)
Writes an entry at the end of the specified event log.
|
boolean |
RevertToSelf()
The RevertToSelf function terminates the impersonation of a client
application.
|
boolean |
SetFileSecurity(java.lang.String lpFileName,
int SecurityInformation,
Pointer pSecurityDescriptor)
The SetFileSecurity function sets the security of a file or directory object.
|
int |
SetNamedSecurityInfo(java.lang.String pObjectName,
int ObjectType,
int SecurityInfo,
Pointer ppsidOwner,
Pointer ppsidGroup,
Pointer ppDacl,
Pointer ppSacl)
The SetNamedSecurityInfo function sets specified security information in
the security descriptor of a specified object.
|
boolean |
SetSecurityDescriptorControl(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor,
short ControlBitsOfInterest,
short ControlBitsToSet)
The SetSecurityDescriptorControl function sets the control bits of a security descriptor.
|
boolean |
SetSecurityDescriptorDacl(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor,
boolean bDaclPresent,
WinNT.ACL pDacl,
boolean bDaclDefaulted)
The SetSecurityDescriptorDacl function sets information in a discretionary access control list (DACL).
|
boolean |
SetSecurityDescriptorGroup(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor,
WinNT.PSID pGroup,
boolean bGroupDefaulted)
The SetSecurityDescriptorGroup function sets the primary group information of an absolute-format security descriptor, replacing
any primary group information already present in the security descriptor.
|
boolean |
SetSecurityDescriptorOwner(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor,
WinNT.PSID pOwner,
boolean bOwnerDefaulted)
The SetSecurityDescriptorOwner function sets the owner information of an absolute-format security descriptor.
|
int |
SetSecurityInfo(WinNT.HANDLE handle,
int ObjectType,
int SecurityInfo,
Pointer ppsidOwner,
Pointer ppsidGroup,
Pointer ppDacl,
Pointer ppSacl)
The SetSecurityInfo function sets specified security information in
the security descriptor of a specified object.
|
boolean |
SetServiceStatus(Winsvc.SERVICE_STATUS_HANDLE hServiceStatus,
Winsvc.SERVICE_STATUS lpServiceStatus)
Updates the service control manager's status information for the calling
service.
|
boolean |
SetThreadToken(WinNT.HANDLEByReference ThreadHandle,
WinNT.HANDLE TokenHandle)
The SetThreadToken function assigns an impersonation token to a thread.
|
boolean |
StartService(Winsvc.SC_HANDLE hService,
int dwNumServiceArgs,
java.lang.String[] lpServiceArgVectors)
Starts a service.
|
boolean |
StartServiceCtrlDispatcher(Winsvc.SERVICE_TABLE_ENTRY[] lpServiceTable)
Connects the main thread of a service process to the service control
manager, which causes the thread to be the service control dispatcher
thread for the calling process.
|
int |
WriteEncryptedFileRaw(WinBase.FE_IMPORT_FUNC pfImportCallback,
Pointer pvCallbackContext,
Pointer pvContext)
Restores (import) encrypted files.
|
static final Advapi32 INSTANCE
static final int MAX_KEY_LENGTH
static final int MAX_VALUE_NAME
static final int RRF_RT_ANY
static final int RRF_RT_DWORD
static final int RRF_RT_QWORD
static final int RRF_RT_REG_BINARY
static final int RRF_RT_REG_DWORD
static final int RRF_RT_REG_EXPAND_SZ
static final int RRF_RT_REG_MULTI_SZ
static final int RRF_RT_REG_NONE
static final int RRF_RT_REG_QWORD
static final int RRF_RT_REG_SZ
static final int LOGON_WITH_PROFILE
static final int LOGON_NETCREDENTIALS_ONLY
boolean GetUserNameW(char[] buffer, IntByReference len)
buffer
- Buffer to receive the user's logon name.len
- On input, the size of the buffer, on output the number of
characters copied into the buffer, including the terminating
null character.boolean LookupAccountName(java.lang.String lpSystemName, java.lang.String lpAccountName, WinNT.PSID Sid, IntByReference cbSid, char[] ReferencedDomainName, IntByReference cchReferencedDomainName, PointerByReference peUse)
lpSystemName
- Specifies the name of the system.lpAccountName
- Specifies the account name.Sid
- Receives the SID structure that corresponds to the account
name pointed to by the lpAccountName parameter.cbSid
- On input, this value specifies the size, in bytes, of the Sid
buffer. If the function fails because the buffer is too small
or if cbSid is zero, this variable receives the required
buffer size.ReferencedDomainName
- Receives the name of the domain where the account name is
found.cchReferencedDomainName
- On input, this value specifies the size, in TCHARs, of the
ReferencedDomainName buffer. If the function fails because the
buffer is too small, this variable receives the required
buffer size, including the terminating null character.peUse
- SID_NAME_USE enumerated type that indicates the type of the
account when the function returns.boolean LookupAccountSid(java.lang.String lpSystemName, WinNT.PSID Sid, char[] lpName, IntByReference cchName, char[] ReferencedDomainName, IntByReference cchReferencedDomainName, PointerByReference peUse)
lpSystemName
- Specifies the target computer.Sid
- The SID to look up.lpName
- Buffer that receives a null-terminated string that contains
the account name that corresponds to the lpSid parameter.cchName
- On input, specifies the size, in TCHARs, of the lpName buffer.
If the function fails because the buffer is too small or if
cchName is zero, cchName receives the required buffer size,
including the terminating null character.ReferencedDomainName
- Pointer to a buffer that receives a null-terminated string
that contains the name of the domain where the account name
was found.cchReferencedDomainName
- On input, specifies the size, in TCHARs, of the
lpReferencedDomainName buffer. If the function fails because
the buffer is too small or if cchReferencedDomainName is zero,
cchReferencedDomainName receives the required buffer size,
including the terminating null character.peUse
- Pointer to a variable that receives a SID_NAME_USE value that
indicates the type of the account.boolean ConvertSidToStringSid(WinNT.PSID Sid, PointerByReference StringSid)
Sid
- The SID structure to be converted.StringSid
- Pointer to a variable that receives a pointer to a
null-terminated SID string. To free the returned buffer, call
the LocalFree function.true
if the function was successful - call GetLastError()
to check failure reasonboolean ConvertStringSidToSid(java.lang.String StringSid, WinNT.PSIDByReference Sid)
StringSid
- The string-format SID to convert.Sid
- Receives a pointer to the converted SID. To free the returned buffer, call
the LocalFree function.true
if the function was successful - call GetLastError()
to check failure reasonint GetLengthSid(WinNT.PSID pSid)
pSid
- A pointer to the SID structure whose length is returned.boolean IsValidSid(WinNT.PSID pSid)
pSid
- Pointer to the SID structure to validate. This parameter
cannot be NULL.boolean EqualSid(WinNT.PSID pSid1, WinNT.PSID pSid2)
pSid1
- A pointer to the first SID structure to compare. This structure is assumed to be valid.pSid2
- A pointer to the second SID structure to compare. This structure is assumed to be valid.boolean IsWellKnownSid(WinNT.PSID pSid, int wellKnownSidType)
pSid
- SID to test.wellKnownSidType
- Member of the WELL_KNOWN_SID_TYPE enumeration to compare with
the SID at pSid.boolean CreateWellKnownSid(int wellKnownSidType, WinNT.PSID domainSid, WinNT.PSID pSid, IntByReference cbSid)
wellKnownSidType
- Member of the WELL_KNOWN_SID_TYPE enumeration that specifies
what the SID will identify.domainSid
- Pointer to a SID that identifies the domain control to use
when creating the SID. Pass NULL to use the local computer.pSid
- Pointer to memory where CreateWellKnownSid will store the new
SID.cbSid
- Pointer to a DWORD that contains the number of bytes available
at pSid. The CreateWellKnownSid function stores the number of
bytes actually used at this location.boolean InitializeSecurityDescriptor(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor, int dwRevision)
pSecurityDescriptor
- A pointer to a SECURITY_DESCRIPTOR structure that the function initializes.dwRevision
- The revision level to assign to the security descriptor. This parameter
must be SECURITY_DESCRIPTOR_REVISION.boolean GetSecurityDescriptorControl(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor, ShortByReference pControl, IntByReference lpdwRevision)
pSecurityDescriptor
- A pointer to a SECURITY_DESCRIPTOR structure whose control and revision
information the function retrieves.pControl
- A pointer to a SECURITY_DESCRIPTOR_CONTROL structure that receives the security descriptor's
control information.lpdwRevision
- A pointer to a variable that receives the security descriptor's revision value.
This value is always set, even when GetSecurityDescriptorControl returns an error.boolean SetSecurityDescriptorControl(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor, short ControlBitsOfInterest, short ControlBitsToSet)
pSecurityDescriptor
- A pointer to a SECURITY_DESCRIPTOR structure whose control and revision information are set.ControlBitsOfInterest
- A SECURITY_DESCRIPTOR_CONTROL mask that indicates the control bits to set.ControlBitsToSet
- SECURITY_DESCRIPTOR_CONTROL mask that indicates the new values for the control bits specified by the ControlBitsOfInterest mask.boolean GetSecurityDescriptorOwner(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor, WinNT.PSIDByReference pOwner, WinDef.BOOLByReference lpbOwnerDefaulted)
pSecurityDescriptor
- A pointer to a SECURITY_DESCRIPTOR structure whose owner information the function retrieves.pOwner
- A pointer to a pointer to a security identifier (SID) that identifies the owner when the function returns.
If the security descriptor does not contain an owner, the function sets the pointer pointed to by pOwner
to NULL and ignores the remaining output parameter, lpbOwnerDefaulted. If the security descriptor contains an owner,
the function sets the pointer pointed to by pOwner to the address of the security descriptor's owner SID
and provides a valid value for the variable pointed to by lpbOwnerDefaulted.lpbOwnerDefaulted
- A pointer to a flag that is set to the value of the SE_OWNER_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL
structure when the function returns. If the value stored in the variable pointed to by the pOwner parameter is
NULL, no value is set.boolean SetSecurityDescriptorOwner(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor, WinNT.PSID pOwner, boolean bOwnerDefaulted)
pSecurityDescriptor
- A pointer to the SECURITY_DESCRIPTOR structure whose owner is set by this function. The function replaces any existing
owner with the new owner.pOwner
- A pointer to a SID structure for the security descriptor's new primary owner. The SID structure is referenced by, not
copied into, the security descriptor. If this parameter is NULL, the function clears the security descriptor's owner
information. This marks the security descriptor as having no owner.bOwnerDefaulted
- Indicates whether the owner information is derived from a default mechanism. If this value is TRUE, it is default information.
The function stores this value as the SE_OWNER_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure. If this parameter
is zero, the SE_OWNER_DEFAULTED flag is cleared.boolean GetSecurityDescriptorGroup(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor, WinNT.PSIDByReference pGroup, WinDef.BOOLByReference lpbGroupDefaulted)
pSecurityDescriptor
- A pointer to a SECURITY_DESCRIPTOR structure whose primary group information the function retrieves.pGroup
- A pointer to a pointer to a security identifier (SID) that identifies the primary group when the function
returns. If the security descriptor does not contain a primary group, the function sets the pointer
pointed to by pGroup to NULL and ignores the remaining output parameter, lpbGroupDefaulted. If the
security descriptor contains a primary group, the function sets the pointer pointed to by pGroup to the
address of the security descriptor's group SID and provides a valid value for the variable pointed to
by lpbGroupDefaulted.lpbGroupDefaulted
- A pointer to a flag that is set to the value of the SE_GROUP_DEFAULTED flag in the
SECURITY_DESCRIPTOR_CONTROL structure when the function returns. If the value stored in the variable
pointed to by the pGroup parameter is NULL, no value is set.boolean SetSecurityDescriptorGroup(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor, WinNT.PSID pGroup, boolean bGroupDefaulted)
pSecurityDescriptor
- A pointer to the SECURITY_DESCRIPTOR structure whose primary group is set by this function. The function replaces
any existing primary group with the new primary group.pGroup
- A pointer to a SID structure for the security descriptor's new primary group. The SID structure is referenced by, not copied
into, the security descriptor. If this parameter is NULL, the function clears the security descriptor's primary group
information. This marks the security descriptor as having no primary group.bGroupDefaulted
- Indicates whether the primary group information was derived from a default mechanism. If this value is TRUE, it is default
information, and the function stores this value as the SE_GROUP_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
If this parameter is zero, the SE_GROUP_DEFAULTED flag is cleared.boolean GetSecurityDescriptorDacl(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor, WinDef.BOOLByReference bDaclPresent, WinNT.PACLByReference pDacl, WinDef.BOOLByReference bDaclDefaulted)
pSecurityDescriptor
- A pointer to the SECURITY_DESCRIPTOR structure that contains the DACL. The function retrieves a pointer to it.bDaclPresent
- A pointer to a value that indicates the presence of a DACL in the specified security descriptor. If
lpbDaclPresent is TRUE, the security descriptor contains a DACL, and the remaining output parameters in this
function receive valid values. If lpbDaclPresent is FALSE, the security descriptor does not contain a DACL,
and the remaining output parameters do not receive valid values. A value of TRUE for lpbDaclPresent does not
mean that pDacl is not NULL. That is, lpbDaclPresent can be TRUE while pDacl is NULL, meaning that a NULL
DACL is in effect. A NULL DACL implicitly allows all access to an object and is not the same as an empty DACL.
An empty DACL permits no access to an object. For information about creating a proper DACL, see Creating a DACL.pDacl
- A pointer to a pointer to an access control list (ACL). If a DACL exists, the function sets the pointer pointed
to by pDacl to the address of the security descriptor's DACL. If a DACL does not exist, no value is stored.
If the function stores a NULL value in the pointer pointed to by pDacl, the security descriptor has a NULL DACL.
A NULL DACL implicitly allows all access to an object.
If an application expects a non-NULL DACL but encounters a NULL DACL, the application should fail securely and
not allow access.bDaclDefaulted
- A pointer to a flag set to the value of the SE_DACL_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure
if a DACL exists for the security descriptor. If this flag is TRUE, the DACL was retrieved by a default mechanism;
if FALSE, the DACL was explicitly specified by a user.boolean SetSecurityDescriptorDacl(WinNT.SECURITY_DESCRIPTOR pSecurityDescriptor, boolean bDaclPresent, WinNT.ACL pDacl, boolean bDaclDefaulted)
pSecurityDescriptor
- A pointer to the SECURITY_DESCRIPTOR structure to which the function adds the DACL. This
security descriptor must be in absolute format, meaning that its members must be pointers
to other structures, rather than offsets to contiguous data.bDaclPresent
- A flag that indicates the presence of a DACL in the security descriptor. If this parameter
is TRUE, the function sets the SE_DACL_PRESENT flag in the SECURITY_DESCRIPTOR_CONTROL
structure and uses the values in the pDacl and bDaclDefaulted parameters. If this parameter
is FALSE, the function clears the SE_DACL_PRESENT flag, and pDacl and bDaclDefaulted are ignored.pDacl
- A pointer to an ACL structure that specifies the DACL for the security descriptor. If this
parameter is NULL, a NULL DACL is assigned to the security descriptor, which allows all access
to the object. The DACL is referenced by, not copied into, the security descriptor.bDaclDefaulted
- A flag that indicates the source of the DACL. If this flag is TRUE, the DACL has been retrieved
by some default mechanism. If FALSE, the DACL has been explicitly specified by a user. The function
stores this value in the SE_DACL_DEFAULTED flag of the SECURITY_DESCRIPTOR_CONTROL structure. If
this parameter is not specified, the SE_DACL_DEFAULTED flag is cleared.boolean InitializeAcl(WinNT.ACL pAcl, int nAclLength, int dwAclRevision)
pAcl
- A pointer to an ACL structure to be initialized by this function.
Allocate memory for pAcl before calling this function.nAclLength
- The length, in bytes, of the buffer pointed to by the pAcl parameter. This value
must be large enough to contain the ACL header and all of the access control
entries (ACEs) to be stored in the ACL. In addition, this value must be
DWORD-aligned. For more information about calculating the size of an ACL,
see Remarks.dwAclRevision
- The revision level of the ACL structure being created. This value can be ACL_REVISION
or ACL_REVISION_DS. Use ACL_REVISION_DS if the access control list (ACL) supports
object-specific ACEs.boolean AddAce(WinNT.ACL pAcl, int dwAceRevision, int dwStartingAceIndex, Pointer pAceList, int nAceListLength)
pAcl
- A pointer to an ACL. This function adds an ACE to this ACL.dwAceRevision
- Specifies the revision level of the ACL being modified. This value can be ACL_REVISION or
ACL_REVISION_DS. Use ACL_REVISION_DS if the ACL contains object-specific ACEs. This value
must be compatible with the AceType field of all ACEs in pAceList. Otherwise, the function
will fail and set the last error to ERROR_INVALID_PARAMETER.dwStartingAceIndex
- Specifies the position in the ACL's list of ACEs at which to add new ACEs. A value of zero
inserts the ACEs at the beginning of the list. A value of MAXDWORD appends the ACEs to the end
of the list.pAceList
- A pointer to a list of one or more ACEs to be added to the specified ACL. The ACEs in the list
must be stored contiguously.nAceListLength
- Specifies the size, in bytes, of the input buffer pointed to by the pAceList parameter.boolean AddAccessAllowedAce(WinNT.ACL pAcl, int dwAceRevision, int AccessMask, WinNT.PSID pSid)
pAcl
- A pointer to an ACL. This function adds an access-allowed ACE to the end of this ACL.
The ACE is in the form of an ACCESS_ALLOWED_ACE structure.dwAceRevision
- Specifies the revision level of the ACL being modified. This value can be ACL_REVISION or
ACL_REVISION_DS. Use ACL_REVISION_DS if the ACL contains object-specific ACEs.AccessMask
- Specifies the mask of access rights to be granted to the specified SID.pSid
- A pointer to the SID representing a user, group, or logon account being granted access.boolean AddAccessAllowedAceEx(WinNT.ACL pAcl, int dwAceRevision, int AceFlags, int AccessMask, WinNT.PSID pSid)
pAcl
- A pointer to an ACL. This function adds an access-allowed ACE to the end of this ACL.
The ACE is in the form of an ACCESS_ALLOWED_ACE structure.dwAceRevision
- Specifies the revision level of the ACL being modified. This value can be ACL_REVISION or
ACL_REVISION_DS. Use ACL_REVISION_DS if the ACL contains object-specific ACEs.AceFlags
- A set of bit flags that control ACE inheritance. The function sets these flags in the AceFlags
member of the ACE_HEADER structure of the new ACE. This parameter can be a combination
of the following values: CONTAINER_INHERIT_ACE, INHERIT_ONLY_ACE, INHERITED_ACE,
NO_PROPAGATE_INHERIT_ACE, and OBJECT_INHERIT_ACEAccessMask
- Specifies the mask of access rights to be granted to the specified SID.pSid
- A pointer to the SID representing a user, group, or logon account being granted access.boolean GetAce(WinNT.ACL pAcl, int dwAceIndex, PointerByReference pAce)
pAcl
- A pointer to an ACL that contains the ACE to be retrieved.dwAceIndex
- The index of the ACE to be retrieved. A value of zero corresponds to the first ACE in
the ACL, a value of one to the second ACE, and so on.pAce
- A pointer to a pointer that the function sets to the address of the ACE.boolean LogonUser(java.lang.String lpszUsername, java.lang.String lpszDomain, java.lang.String lpszPassword, int logonType, int logonProvider, WinNT.HANDLEByReference phToken)
lpszUsername
- A pointer to a null-terminated string that specifies the name
of the user. This is the name of the user account to log on
to. If you use the user principal name (UPN) format,
user@DNS_domain_name, the lpszDomain parameter must be NULL.lpszDomain
- A pointer to a null-terminated string that specifies the name
of the domain or server whose account database contains the
lpszUsername account. If this parameter is NULL, the user name
must be specified in UPN format. If this parameter is ".", the
function validates the account using only the local account
database.lpszPassword
- A pointer to a null-terminated string that specifies the
plaintext password for the user account specified by
lpszUsername.logonType
- The type of logon operation to perform.logonProvider
- Specifies the logon provider.phToken
- A pointer to a handle variable that receives a handle to a
token that represents the specified user.boolean OpenThreadToken(WinNT.HANDLE ThreadHandle, int DesiredAccess, boolean OpenAsSelf, WinNT.HANDLEByReference TokenHandle)
ThreadHandle
- Handle to the thread whose access token is opened.DesiredAccess
- Specifies an access mask that specifies the requested types of
access to the access token. These requested access types are
reconciled against the token's discretionary access control
list (DACL) to determine which accesses are granted or denied.OpenAsSelf
- Indicates whether the access check is to be made against the
security context of the thread calling the OpenThreadToken
function or against the security context of the process for
the calling thread.TokenHandle
- Pointer to a variable that receives the handle to the newly
opened access token.boolean SetThreadToken(WinNT.HANDLEByReference ThreadHandle, WinNT.HANDLE TokenHandle)
ThreadHandle
- [in, optional]
A pointer to a handle to the thread to which the function
assigns the impersonation token. If ThreadHandle is NULL, the
function assigns the impersonation token to the calling thread.TokenHandle
- [in, optional]
A handle to the impersonation token to assign to the thread.
This handle must have been opened with TOKEN_IMPERSONATE access
rights. For more information, see Access Rights for Access-Token
Objects. If Token is NULL, the function causes the
thread to stop using an impersonation token.boolean OpenProcessToken(WinNT.HANDLE ProcessHandle, int DesiredAccess, WinNT.HANDLEByReference TokenHandle)
ProcessHandle
- Handle to the process whose access token is opened. The
process must have the PROCESS_QUERY_INFORMATION access
permission.DesiredAccess
- Specifies an access mask that specifies the requested types of
access to the access token. These requested access types are
compared with the discretionary access control list (DACL) of
the token to determine which accesses are granted or denied.TokenHandle
- Pointer to a handle that identifies the newly opened access
token when the function returns.boolean DuplicateToken(WinNT.HANDLE ExistingTokenHandle, int ImpersonationLevel, WinNT.HANDLEByReference DuplicateTokenHandle)
ExistingTokenHandle
- Handle to an access token opened with TOKEN_DUPLICATE access.ImpersonationLevel
- Specifies a SECURITY_IMPERSONATION_LEVEL enumerated type that
supplies the impersonation level of the new token.DuplicateTokenHandle
- Pointer to a variable that receives a handle to the duplicate
token. This handle has TOKEN_IMPERSONATE and TOKEN_QUERY
access to the new token.boolean DuplicateTokenEx(WinNT.HANDLE hExistingToken, int dwDesiredAccess, WinBase.SECURITY_ATTRIBUTES lpTokenAttributes, int ImpersonationLevel, int TokenType, WinNT.HANDLEByReference phNewToken)
hExistingToken
- A handle to an access token opened with TOKEN_DUPLICATE
access.dwDesiredAccess
- Specifies the requested access rights for the new token.lpTokenAttributes
- A pointer to a SECURITY_ATTRIBUTES structure that specifies a
security descriptor for the new token and determines whether
child processes can inherit the token.ImpersonationLevel
- Specifies a value from the SECURITY_IMPERSONATION_LEVEL
enumeration that indicates the impersonation level of the new
token.TokenType
- Specifies one of the following values from the TOKEN_TYPE
enumeration.phNewToken
- A pointer to a HANDLE variable that receives the new token.boolean GetTokenInformation(WinNT.HANDLE tokenHandle, int tokenInformationClass, Structure tokenInformation, int tokenInformationLength, IntByReference returnLength)
tokenHandle
- Handle to an access token from which information is retrieved.
If TokenInformationClass specifies TokenSource, the handle
must have TOKEN_QUERY_SOURCE access. For all other
TokenInformationClass values, the handle must have TOKEN_QUERY
access.tokenInformationClass
- Specifies a value from the TOKEN_INFORMATION_CLASS enumerated
type to identify the type of information the function
retrieves.tokenInformation
- Pointer to a buffer the function fills with the requested
information. The structure put into this buffer depends upon
the type of information specified by the TokenInformationClass
parameter.tokenInformationLength
- Specifies the size, in bytes, of the buffer pointed to by the
TokenInformation parameter. If TokenInformation is NULL, this
parameter must be zero.returnLength
- Pointer to a variable that receives the number of bytes needed
for the buffer pointed to by the TokenInformation parameter.
If this value is larger than the value specified in the
TokenInformationLength parameter, the function fails and
stores no data in the buffer.boolean ImpersonateLoggedOnUser(WinNT.HANDLE hToken)
hToken
- Handle to a primary or impersonation access token that
represents a logged-on user. This can be a token handle
returned by a call to LogonUser, CreateRestrictedToken,
DuplicateToken, DuplicateTokenEx, OpenProcessToken, or
OpenThreadToken functions. If hToken is a primary token, it
must have TOKEN_QUERY and TOKEN_DUPLICATE access. If hToken is
an impersonation token, it must have TOKEN_QUERY and
TOKEN_IMPERSONATE access.boolean ImpersonateSelf(int ImpersonationLevel)
ImpersonationLevel
- Specifies a SECURITY_IMPERSONATION_LEVEL enumerated type that
supplies the impersonation level of the new token.boolean RevertToSelf()
int RegOpenKeyEx(WinReg.HKEY hKey, java.lang.String lpSubKey, int ulOptions, int samDesired, WinReg.HKEYByReference phkResult)
hKey
- Handle to an open key.lpSubKey
- Pointer to a null-terminated string containing the name of the
subkey to open.ulOptions
- Reserved; must be zero.samDesired
- Access mask that specifies the desired access rights to the
key. The function fails if the security descriptor of the key
does not permit the requested access for the calling process.phkResult
- Pointer to a variable that receives a handle to the opened
key. If the key is not one of the predefined registry keys,
call the RegCloseKey function after you have finished using
the handle.int RegConnectRegistry(java.lang.String lpMachineName, WinReg.HKEY hKey, WinReg.HKEYByReference phkResult)
lpMachineName
- The name of the remote computer. The string has
the following form:\\computername
The caller must have access to the remote computer or the
function fails.hKey
- A predefined registry handle. This parameter can be one of
the following predefined keys on the remote computer.phkResult
- A pointer to a variable that receives a key handle
identifying the predefined handle on the remote computer.WinError.ERROR_SUCCESS
.WinError.ERROR_BAD_NETPATH
.WinError.ERROR_INVALID_HANDLE
.WinError.ERROR_ACCESS_DENIED
. Native.getLastError()
method to get a generic description
of the error.int RegQueryValueEx(WinReg.HKEY hKey, java.lang.String lpValueName, int lpReserved, IntByReference lpType, char[] lpData, IntByReference lpcbData)
hKey
- Handle to an open key. The key must have been opened with the
KEY_QUERY_VALUE access right.lpValueName
- Pointer to a null-terminated string containing the name of the
value to query. If lpValueName is NULL or an empty string, "",
the function retrieves the type and data for the key's unnamed
or default value, if any.lpReserved
- Reserved; must be NULL.lpType
- Pointer to a variable that receives a code indicating the type
of data stored in the specified value.lpData
- Pointer to a buffer that receives the value's data. This
parameter can be NULL if the data is not required. If the data
is a string, the function checks for a terminating null
character. If one is not found, the string is stored with a
null terminator if the buffer is large enough to accommodate
the extra character. Otherwise, the string is stored as is.lpcbData
- Pointer to a variable that specifies the size of the buffer
pointed to by the lpData parameter, in bytes. When the
function returns, this variable contains the size of the data
copied to lpData. The lpcbData parameter can be NULL only if
lpData is NULL. If the data has the REG_SZ, REG_MULTI_SZ or
REG_EXPAND_SZ type, this size includes any terminating null
character or characters. If the buffer specified by lpData
parameter is not large enough to hold the data, the function
returns ERROR_MORE_DATA and stores the required buffer size in
the variable pointed to by lpcbData. In this case, the
contents of the lpData buffer are undefined. If lpData is
NULL, and lpcbData is non-NULL, the function returns
ERROR_SUCCESS and stores the size of the data, in bytes, in
the variable pointed to by lpcbData. This enables an
application to determine the best way to allocate a buffer for
the value's data.int RegQueryValueEx(WinReg.HKEY hKey, java.lang.String lpValueName, int lpReserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData)
int RegQueryValueEx(WinReg.HKEY hKey, java.lang.String lpValueName, int lpReserved, IntByReference lpType, IntByReference lpData, IntByReference lpcbData)
int RegQueryValueEx(WinReg.HKEY hKey, java.lang.String lpValueName, int lpReserved, IntByReference lpType, LongByReference lpData, IntByReference lpcbData)
int RegQueryValueEx(WinReg.HKEY hKey, java.lang.String lpValueName, int lpReserved, IntByReference lpType, Pointer lpData, IntByReference lpcbData)
int RegCloseKey(WinReg.HKEY hKey)
hKey
- Handle to the open key to be closed. The handle must have been
opened by the RegCreateKeyEx, RegOpenKeyEx, or
RegConnectRegistry function.int RegDeleteValue(WinReg.HKEY hKey, java.lang.String lpValueName)
hKey
- Handle to an open key. The key must have been opened with the
KEY_SET_VALUE access right.lpValueName
- Pointer to a null-terminated string that names the value to
remove. If this parameter is NULL or an empty string, the
value set by the RegSetValue function is removed.int RegSetValueEx(WinReg.HKEY hKey, java.lang.String lpValueName, int Reserved, int dwType, Pointer lpData, int cbData)
hKey
- Handle to an open key. The key must have been opened with the
KEY_SET_VALUE access right.lpValueName
- Pointer to a string containing the name of the value to set.
If a value with this name is not already present in the key,
the function adds it to the key. If lpValueName is NULL or an
empty string, "", the function sets the type and data for the
key's unnamed or default value.Reserved
- Reserved; must be zero.dwType
- Type of data pointed to by the lpData parameter.lpData
- Pointer to a buffer containing the data to be stored with the
specified value name.cbData
- Size of the information pointed to by the lpData parameter, in
bytes. If the data is of type REG_SZ, REG_EXPAND_SZ, or
REG_MULTI_SZ, cbData must include the size of the terminating
null character or characters.int RegSetValueEx(WinReg.HKEY hKey, java.lang.String lpValueName, int Reserved, int dwType, char[] lpData, int cbData)
int RegSetValueEx(WinReg.HKEY hKey, java.lang.String lpValueName, int Reserved, int dwType, byte[] lpData, int cbData)
int RegCreateKeyEx(WinReg.HKEY hKey, java.lang.String lpSubKey, int Reserved, java.lang.String lpClass, int dwOptions, int samDesired, WinBase.SECURITY_ATTRIBUTES lpSecurityAttributes, WinReg.HKEYByReference phkResult, IntByReference lpdwDisposition)
hKey
- registry keylpSubKey
- subkey nameReserved
- unusedlpClass
- classdwOptions
- optionssamDesired
- ?lpSecurityAttributes
- security attributesphkResult
- resulting keylpdwDisposition
- ?int RegDeleteKey(WinReg.HKEY hKey, java.lang.String name)
hKey
- registry keyname
- key nameint RegEnumKeyEx(WinReg.HKEY hKey, int dwIndex, char[] lpName, IntByReference lpcName, IntByReference reserved, char[] lpClass, IntByReference lpcClass, WinBase.FILETIME lpftLastWriteTime)
hKey
- Handle to an open key. The key must have been opened with the
KEY_ENUMERATE_SUB_KEYS access right.dwIndex
- Index of the subkey to retrieve. This parameter should be zero
for the first call to the RegEnumKeyEx function and then
incremented for subsequent calls. Because subkeys are not
ordered, any new subkey will have an arbitrary index. This
means that the function may return subkeys in any order.lpName
- Pointer to a buffer that receives the name of the subkey,
including the terminating null character. The function copies
only the name of the subkey, not the full key hierarchy, to
the buffer.lpcName
- Pointer to a variable that specifies the size of the buffer
specified by the lpName parameter, in TCHARs. This size should
include the terminating null character. When the function
returns, the variable pointed to by lpcName contains the
number of characters stored in the buffer. The count returned
does not include the terminating null character.reserved
- Reserved; must be NULL.lpClass
- Pointer to a buffer that receives the null-terminated class
string of the enumerated subkey. This parameter can be NULL.lpcClass
- Pointer to a variable that specifies the size of the buffer
specified by the lpClass parameter, in TCHARs. The size should
include the terminating null character. When the function
returns, lpcClass contains the number of characters stored in
the buffer. The count returned does not include the
terminating null character. This parameter can be NULL only if
lpClass is NULL.lpftLastWriteTime
- Pointer to a variable that receives the time at which the
enumerated subkey was last written.int RegEnumValue(WinReg.HKEY hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved, IntByReference lpType, Pointer lpData, IntByReference lpcbData)
hKey
- Handle to an open key. The key must have been opened with the
KEY_QUERY_VALUE access right.dwIndex
- Index of the value to be retrieved. This parameter should be
zero for the first call to the RegEnumValue function and then
be incremented for subsequent calls. Because values are not
ordered, any new value will have an arbitrary index. This
means that the function may return values in any order.lpValueName
- Pointer to a buffer that receives the name of the value,
including the terminating null character.lpcchValueName
- Pointer to a variable that specifies the size of the buffer
pointed to by the lpValueName parameter, in TCHARs. This size
should include the terminating null character. When the
function returns, the variable pointed to by lpcValueName
contains the number of characters stored in the buffer. The
count returned does not include the terminating null
character.reserved
- Reserved; must be NULL.lpType
- Pointer to a variable that receives a code indicating the type
of data stored in the specified value.lpData
- Pointer to a buffer that receives the data for the value
entry. This parameter can be NULL if the data is not required.lpcbData
- Pointer to a variable that specifies the size of the buffer
pointed to by the lpData parameter, in bytes.int RegEnumValue(WinReg.HKEY hKey, int dwIndex, char[] lpValueName, IntByReference lpcchValueName, IntByReference reserved, IntByReference lpType, byte[] lpData, IntByReference lpcbData)
int RegQueryInfoKey(WinReg.HKEY hKey, char[] lpClass, IntByReference lpcClass, IntByReference lpReserved, IntByReference lpcSubKeys, IntByReference lpcMaxSubKeyLen, IntByReference lpcMaxClassLen, IntByReference lpcValues, IntByReference lpcMaxValueNameLen, IntByReference lpcMaxValueLen, IntByReference lpcbSecurityDescriptor, WinBase.FILETIME lpftLastWriteTime)
hKey
- A handle to an open key. The key must have been opened with
the KEY_QUERY_VALUE access right.lpClass
- A pointer to a buffer that receives the null-terminated class
string of the key. This parameter can be ignored. This
parameter can be NULL.lpcClass
- A pointer to a variable that specifies the size of the buffer
pointed to by the lpClass parameter, in characters.lpReserved
- Reserved; must be NULL.lpcSubKeys
- A pointer to a variable that receives the number of subkeys
that are contained by the specified key. This parameter can be
NULL.lpcMaxSubKeyLen
- A pointer to a variable that receives the size of the key's
subkey with the longest name, in characters, not including the
terminating null character. This parameter can be NULL.lpcMaxClassLen
- A pointer to a variable that receives the size of the longest
string that specifies a subkey class, in characters. The count
returned does not include the terminating null character. This
parameter can be NULL.lpcValues
- A pointer to a variable that receives the number of values
that are associated with the key. This parameter can be NULL.lpcMaxValueNameLen
- A pointer to a variable that receives the size of the key's
longest value name, in characters. The size does not include
the terminating null character. This parameter can be NULL.lpcMaxValueLen
- A pointer to a variable that receives the size of the longest
data component among the key's values, in bytes. This
parameter can be NULL.lpcbSecurityDescriptor
- A pointer to a variable that receives the size of the key's
security descriptor, in bytes. This parameter can be NULL.lpftLastWriteTime
- A pointer to a FILETIME structure that receives the last write
time. This parameter can be NULL.int RegGetValue(WinReg.HKEY hkey, java.lang.String lpSubKey, java.lang.String lpValue, int dwFlags, IntByReference pdwType, Pointer pvData, IntByReference pcbData)
hkey
- [in] A handle to an open registry key. The key must have been
opened with the KEY_QUERY_VALUE access right. For more
information, see Registry Key Security and Access Rights.
This handle is returned by the RegCreateKeyEx,
RegCreateKeyTransacted, RegOpenKeyEx, or RegOpenKeyTransacted
function. It can also be one of the following predefined keys:
HKEY_CLASSES_ROOT HKEY_CURRENT_CONFIG HKEY_CURRENT_USER
HKEY_LOCAL_MACHINE HKEY_PERFORMANCE_DATA
HKEY_PERFORMANCE_NLSTEXT HKEY_PERFORMANCE_TEXT HKEY_USERSlpSubKey
- [in, optional] The name of the registry key. This key must be
a subkey of the key specified by the hkey parameter.
Key names are not case sensitive.lpValue
- [in, optional]
The name of the registry value.
If this parameter is NULL or an empty string, "", the function
retrieves the type and data for the key's unnamed or default
value, if any.
For more information, see Registry Element Size Limits.
Keys do not automatically have an unnamed or default value.
Unnamed values can be of any type.dwFlags
- [in, optional]
The flags that restrict the data type of value to be queried.
If the data type of the value does not meet this criteria, the
function fails. This parameter can be one or more of the
following values.
RRF_RT_ANY 0x0000ffff No type restriction. RRF_RT_DWORD
0x00000018 Restrict type to 32-bit
RRF_RT_REG_BINARY|RRF_RT_REG_DWORD. RRF_RT_QWORD 0x00000048
Restrict type to 64-bit RRF_RT_REG_BINARY | RRF_RT_REG_DWORD.
RRF_RT_REG_BINARY 0x00000008 Restrict type to REG_BINARY.
RRF_RT_REG_DWORD 0x00000010 Restrict type to REG_DWORD.
RRF_RT_REG_EXPAND_SZ 0x00000004 Restrict type to
REG_EXPAND_SZ. RRF_RT_REG_MULTI_SZ 0x00000020 Restrict type to
REG_MULTI_SZ. RRF_RT_REG_NONE 0x00000001 Restrict type to
REG_NONE. RRF_RT_REG_QWORD 0x00000040 Restrict type to
REG_QWORD. RRF_RT_REG_SZ 0x00000002 Restrict type to REG_SZ.
This parameter can also include one or more of the following
values. RRF_NOEXPAND 0x10000000
Do not automatically expand environment strings if the value
is of type REG_EXPAND_SZ.
RRF_ZEROONFAILURE 0x20000000
If pvData is not NULL, set the contents of the buffer to
zeroes on failure.pdwType
- [out, optional]
A pointer to a variable that receives a code indicating the
type of data stored in the specified value. For a list of the
possible type codes, see Registry Value Types. This parameter
can be NULL if the type is not required.pvData
- [out, optional]
A pointer to a buffer that receives the value's data. This
parameter can be NULL if the data is not required.
If the data is a string, the function checks for a terminating
null character. If one is not found, the string is stored with
a null terminator if the buffer is large enough to accommodate
the extra character. Otherwise, the function fails and returns
ERROR_MORE_DATA.pcbData
- [in, out, optional]
A pointer to a variable that specifies the size of the buffer
pointed to by the pvData parameter, in bytes. When the
function returns, this variable contains the size of the data
copied to pvData.
The pcbData parameter can be NULL only if pvData is NULL.
If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ
type, this size includes any terminating null character or
characters. For more information, see Remarks.
If the buffer specified by pvData parameter is not large
enough to hold the data, the function returns ERROR_MORE_DATA
and stores the required buffer size in the variable pointed to
by pcbData. In this case, the contents of the pvData buffer
are undefined.
If pvData is NULL, and pcbData is non-NULL, the function
returns ERROR_SUCCESS and stores the size of the data, in
bytes, in the variable pointed to by pcbData. This enables an
application to determine the best way to allocate a buffer for
the value's data.
If hKey specifies HKEY_PERFORMANCE_DATA and the pvData buffer
is not large enough to contain all of the returned data, the
function returns ERROR_MORE_DATA and the value returned
through the pcbData parameter is undefined. This is because
the size of the performance data can change from one call to
the next. In this case, you must increase the buffer size and
call RegGetValue again passing the updated buffer size in the
pcbData parameter. Repeat this until the function succeeds.
You need to maintain a separate variable to keep track of the
buffer size, because the value returned by pcbData is
unpredictable.
Return value If the function succeeds, the return value is
ERROR_SUCCESS. If the function fails, the return value is a
system error code. If the pvData buffer is too small to
receive the value, the function returns ERROR_MORE_DATA.int RegGetValue(WinReg.HKEY hkey, java.lang.String lpSubKey, java.lang.String lpValue, int dwFlags, IntByReference pdwType, byte[] pvData, IntByReference pcbData)
WinNT.HANDLE RegisterEventSource(java.lang.String lpUNCServerName, java.lang.String lpSourceName)
lpUNCServerName
- The Universal Naming Convention (UNC) name of the remote
server on which this operation is to be performed. If this
parameter is NULL, the local computer is used.lpSourceName
- The name of the event source whose handle is to be retrieved.
The source name must be a subkey of a log under the Eventlog
registry key. However, the Security log is for system use
only.boolean DeregisterEventSource(WinNT.HANDLE hEventLog)
hEventLog
- A handle to the event log. The RegisterEventSource function
returns this handle.WinNT.HANDLE OpenEventLog(java.lang.String lpUNCServerName, java.lang.String lpSourceName)
lpUNCServerName
- The Universal Naming Convention (UNC) name of the remote
server on which the event log is to be opened. If this
parameter is NULL, the local computer is used.lpSourceName
- The name of the log. If you specify a custom log and it cannot
be found, the event logging service opens the Application log;
however, there will be no associated message or category
string file.boolean CloseEventLog(WinNT.HANDLE hEventLog)
hEventLog
- A handle to the event log to be closed. The OpenEventLog or
OpenBackupEventLog function returns this handle.boolean GetNumberOfEventLogRecords(WinNT.HANDLE hEventLog, IntByReference NumberOfRecords)
hEventLog
- A handle to the open event log. The OpenEventLog or
OpenBackupEventLog function returns this handle.NumberOfRecords
- A pointer to a variable that receives the number of records in
the specified event log.boolean ReportEvent(WinNT.HANDLE hEventLog, int wType, int wCategory, int dwEventID, WinNT.PSID lpUserSid, int wNumStrings, int dwDataSize, java.lang.String[] lpStrings, Pointer lpRawData)
hEventLog
- A handle to the event log. The RegisterEventSource function
returns this handle. As of Windows XP with SP2, this parameter
cannot be a handle to the Security log. To write an event to
the Security log, use the AuthzReportSecurityEvent function.wType
- The type of event to be logged.wCategory
- The event category. This is source-specific information; the
category can have any value.dwEventID
- The event identifier. The event identifier specifies the entry
in the message file associated with the event source.lpUserSid
- A pointer to the current user's security identifier. This
parameter can be NULL if the security identifier is not
required.wNumStrings
- The number of insert strings in the array pointed to by the
lpStrings parameter. A value of zero indicates that no strings
are present.dwDataSize
- The number of bytes of event-specific raw (binary) data to
write to the log. If this parameter is zero, no event-specific
data is present.lpStrings
- A pointer to a buffer containing an array of null-terminated
strings that are merged into the message before Event Viewer
displays the string to the user. This parameter must be a
valid pointer (or NULL), even if wNumStrings is zero. Each
string is limited to 31,839 characters.lpRawData
- A pointer to the buffer containing the binary data. This
parameter must be a valid pointer (or NULL), even if the
dwDataSize parameter is zero.boolean ClearEventLog(WinNT.HANDLE hEventLog, java.lang.String lpBackupFileName)
hEventLog
- A handle to the event log to be cleared. The OpenEventLog
function returns this handle.lpBackupFileName
- The absolute or relative path of the backup file. If this file
already exists, the function fails. If the lpBackupFileName
parameter is NULL, the event log is not backed up.boolean BackupEventLog(WinNT.HANDLE hEventLog, java.lang.String lpBackupFileName)
hEventLog
- A handle to the open event log. The OpenEventLog function
returns this handle.lpBackupFileName
- The absolute or relative path of the backup file.WinNT.HANDLE OpenBackupEventLog(java.lang.String lpUNCServerName, java.lang.String lpFileName)
lpUNCServerName
- The Universal Naming Convention (UNC) name of the remote
server on which this operation is to be performed. If this
parameter is NULL, the local computer is used.lpFileName
- The full path of the backup file.boolean ReadEventLog(WinNT.HANDLE hEventLog, int dwReadFlags, int dwRecordOffset, Pointer lpBuffer, int nNumberOfBytesToRead, IntByReference pnBytesRead, IntByReference pnMinNumberOfBytesNeeded)
hEventLog
- A handle to the event log to be read. The OpenEventLog
function returns this handle.dwReadFlags
- Use the following flag values to indicate how to read the log
file.dwRecordOffset
- The record number of the log-entry at which the read operation
should start. This parameter is ignored unless dwReadFlags
includes the EVENTLOG_SEEK_READ flag.lpBuffer
- An application-allocated buffer that will receive one or more
EVENTLOGRECORD structures. This parameter cannot be NULL, even
if the nNumberOfBytesToRead parameter is zero. The maximum
size of this buffer is 0x7ffff bytes.nNumberOfBytesToRead
- The size of the lpBuffer buffer, in bytes. This function will
read as many log entries as will fit in the buffer; the
function will not return partial entries.pnBytesRead
- A pointer to a variable that receives the number of bytes read
by the function.pnMinNumberOfBytesNeeded
- A pointer to a variable that receives the required size of the
lpBuffer buffer. This value is valid only this function
returns zero and GetLastError returns
ERROR_INSUFFICIENT_BUFFER.boolean GetOldestEventLogRecord(WinNT.HANDLE hEventLog, IntByReference OldestRecord)
hEventLog
- Handle to the open event log. This handle is returned by the
OpenEventLog or OpenBackupEventLog function.OldestRecord
- Pointer to a variable that receives the absolute record number
of the oldest record in the specified event log.boolean ChangeServiceConfig2(Winsvc.SC_HANDLE hService, int dwInfoLevel, Winsvc.ChangeServiceConfig2Info lpInfo)
hService
- A handle to the service. This handle is returned by the
OpenService or CreateService function and must have the
SERVICE_CHANGE_CONFIG access right. For more information,
see Service Security and Access Rights.
If the service controller handles the SC_ACTION_RESTART
action, hService must have the SERVICE_START access right.dwInfoLevel
- The configuration information to be changed.lpInfo
- A pointer to the new value to be set for the configuration
information. The format of this data depends on the value
of the dwInfoLevel parameter. If this value is NULL, the
information remains unchanged.boolean QueryServiceConfig2(Winsvc.SC_HANDLE hService, int dwInfoLevel, Pointer lpBuffer, int cbBufSize, IntByReference pcbBytesNeeded)
hService
- A handle to the service. This handle is returned by the OpenService or
CreateService function and must have the SERVICE_QUERY_CONFIG access right. For
more information, see Service Security and Access Rights.dwInfoLevel
- The configuration information to be queried.lpBuffer
- A pointer to the buffer that receives the service configuration information. The
format of this data depends on the value of the dwInfoLevel parameter.
The maximum size of this array is 8K bytes. To determine the required size,
specify NULL for this parameter and 0 for the cbBufSize parameter. The function
fails and GetLastError returns ERROR_INSUFFICIENT_BUFFER. The pcbBytesNeeded
parameter receives the needed size.cbBufSize
- The size of the structure pointed to by the lpBuffer parameter, in bytes.pcbBytesNeeded
- A pointer to a variable that receives the number of bytes required to store the
configuration information, if the function fails with ERROR_INSUFFICIENT_BUFFER.boolean QueryServiceStatusEx(Winsvc.SC_HANDLE hService, int InfoLevel, Winsvc.SERVICE_STATUS_PROCESS lpBuffer, int cbBufSize, IntByReference pcbBytesNeeded)
hService
- A handle to the service. This handle is returned by the
OpenService(SC_HANDLE, String, int) or CreateService()
function, and it must have the SERVICE_QUERY_STATUS access
right. For more information, see Service Security and Access Rights.InfoLevel
- The service attributes to be returned (a value from
SC_STATUS_TYPE enumeration). Use SC_STATUS_PROCESS_INFO to
retrieve the service status information. The lpBuffer
parameter is a pointer to a SERVICE_STATUS_PROCESS structure.
Currently, no other information levels are defined.lpBuffer
- (optional) A pointer to the buffer that receives the status
information. The format of this data depends on the value of
the InfoLevel parameter. The maximum size of this array is 8K
bytes. To determine the required size, specify NULL for this
parameter and 0 for the cbBufSize parameter. The function will
fail and GetLastError will return ERROR_INSUFFICIENT_BUFFER.
The pcbBytesNeeded parameter will receive the required size.cbBufSize
- The size of the buffer pointed to by the lpBuffer parameter,
in bytes.pcbBytesNeeded
- A pointer to a variable that receives the number of bytes
needed to store all status information, if the function fails
with ERROR_INSUFFICIENT_BUFFER.boolean QueryServiceStatus(Winsvc.SC_HANDLE hService, Winsvc.SERVICE_STATUS lpServiceStatus)
hService
- A handle to the service. This handle is returned by the
OpenService(SC_HANDLE, String, int) or CreateService()
function, and it must have the SERVICE_QUERY_STATUS access
right. For more information, see Service Security and Access Rights.lpServiceStatus
- A pointer to a SERVICE_STATUS structure that receives the status information.boolean ControlService(Winsvc.SC_HANDLE hService, int dwControl, Winsvc.SERVICE_STATUS lpServiceStatus)
hService
- A handle to the service. This handle is returned by the
OpenService(SC_HANDLE, String, int) or CreateService()
function. The access rights required for this handle depend on
the dwControl code requested.dwControl
- This parameter can be one of the following control codes
(found in Winsvc.h): SERVICE_CONTROL_STOP,
SERVICE_CONTROL_PAUSE, SERVICE_CONTROL_CONTINUE
SERVICE_CONTROL_INTERROGATE, SERVICE_CONTROL_PARAMCHANGE,
SERVICE_CONTROL_NETBINDADD, SERVICE_CONTROL_NETBINDREMOVE,
SERVICE_CONTROL_NETBINDENABLE, SERVICE_CONTROL_NETBINDDISABLE
This value can also be a user-defined control code, as
described below: Range 128 to 255 - The service defines the
action associated with the control code. The hService handle
must have the SERVICE_USER_DEFINED_CONTROL access right.lpServiceStatus
- A pointer to a SERVICE_STATUS structure that receives the
latest service status information. The information returned
reflects the most recent status that the service reported to
the service control manager. The service control manager fills
in the structure only when ControlService returns one of the
following error codes: NO_ERROR,
ERROR_INVALID_SERVICE_CONTROL,
ERROR_SERVICE_CANNOT_ACCEPT_CTRL, or ERROR_SERVICE_NOT_ACTIVE.
Otherwise, the structure is not filled in.boolean StartService(Winsvc.SC_HANDLE hService, int dwNumServiceArgs, java.lang.String[] lpServiceArgVectors)
hService
- A handle to the service. This handle is returned by the
OpenService(SC_HANDLE, String, int) or CreateService()
function, and it must have the SERVICE_START access right. For
more information, see
Service Security and Access Rights.dwNumServiceArgs
- The number of strings in the lpServiceArgVectors array. If
lpServiceArgVectors is NULL, this parameter can be zero.lpServiceArgVectors
- The null-terminated strings to be passed to the ServiceMain
function for the service as arguments. If there are no
arguments, this parameter can be null. Otherwise, the first
argument (lpServiceArgVectors[0]) is the name of the service,
followed by any additional arguments (lpServiceArgVectors[1]
through lpServiceArgVectors[dwNumServiceArgs-1]). Driver
services do not receive these arguments.boolean CloseServiceHandle(Winsvc.SC_HANDLE hSCObject)
hSCObject
- A handle to the service control manager object or the service
object to close. Handles to service control manager objects
are returned by the OpenSCManager(String, String, int)
function, and handles to service objects are returned by
either the OpenService(SC_HANDLE, String, int) or
CreateService() function.Winsvc.SC_HANDLE OpenService(Winsvc.SC_HANDLE hSCManager, java.lang.String lpServiceName, int dwDesiredAccess)
hSCManager
- A handle to the service control manager database. The
OpenSCManager(String, String, int) function returns this
handle.lpServiceName
- The name of the service to be opened. This is the name
specified by the lpServiceName parameter of the CreateService
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.dwDesiredAccess
- The access to the service. For a list of access rights, see
Service Security and Access Rights. Before granting the
requested access, the system checks the access token of the
calling process against the discretionary access-control list
of the security descriptor associated with the service object.Winsvc.SC_HANDLE OpenSCManager(java.lang.String lpMachineName, java.lang.String lpDatabaseName, int dwDesiredAccess)
lpMachineName
- 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
- 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
- The access to the service control manager. For a list of
access rights, see
Service Security and Access Rights. 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.boolean EnumDependentServices(Winsvc.SC_HANDLE hService, int dwServiceState, Pointer lpService, int cbBufSize, IntByReference pcbBytesNeeded, IntByReference lpServicesReturned)
hService
- A handle to the service. This handle is
returned by the OpenService or CreateService
function, and it must have the
SERVICE_ENUMERATE_DEPENDENTS access right. For
more information, see Service Security and
Access Rights.dwServiceState
- The state of the services to be enumerated.
This parameter can be one of the following
values.
Value | Meaning |
---|---|
Winsvc.SERVICE_ACTIVE | Enumerates services that
are in the following states:
Winsvc.SERVICE_START_PENDING , Winsvc.SERVICE_STOP_PENDING , Winsvc.SERVICE_RUNNING , Winsvc.SERVICE_CONTINUE_PENDING , Winsvc.SERVICE_PAUSE_PENDING ,
and Winsvc.SERVICE_PAUSED . |
Winsvc.SERVICE_INACTIVE | Enumerates services that
are in the Winsvc.SERVICE_STOPPED state. |
Winsvc.SERVICE_STATE_ALL | Combines the following
states: Winsvc.SERVICE_ACTIVE and
Winsvc.SERVICE_INACTIVE . |
lpService
- A pointer to an array of ENUM_SERVICE_STATUS
structures that receives the name and service
status information for each dependent service
in the database. The buffer must be large
enough to hold the structures, plus the strings
to which their members point.
The order of the services in this array is the reverse of the start order of the services. In other words, the first service in the array is the one that would be started last, and the last service in the array is the one that would be started first.
The maximum size of this array is 64,000 bytes. To determine the required size, specify NULL for this parameter and 0 for the cbBufSize parameter. The function will fail and GetLastError will return ERROR_MORE_DATA. The pcbBytesNeeded parameter will receive the required size.
cbBufSize
- The size of the buffer pointed to by the
lpServices parameter, in bytes.pcbBytesNeeded
- A pointer to a variable that receives the
number of bytes needed to store the array of
service entries. The variable only receives
this value if the buffer pointed to by
lpServices is too small, indicated by function
failure and the ERROR_MORE_DATA error;
otherwise, the contents of pcbBytesNeeded are
undefined.lpServicesReturned
- A pointer to a variable that receives the
number of service entries returned.If the function fails, the return value is zero. To get extended error information, call GetLastError.
The following error codes may be set by the service control manager. Other error codes may be set by the registry functions that are called by the service control manager.
Return code | Description |
---|---|
WinError.ERROR_ACCESS_DENIED | The handle does not have the Winsvc.SERVICE_ENUMERATE_DEPENDENTS access right. |
WinError.ERROR_INVALID_HANDLE | The specified handle is invalid. |
WinError.ERROR_INVALID_PARAMETER | A parameter that was specified is invalid. |
WinError.ERROR_MORE_DATA | The buffer pointed to by lpServices is not large enough. The function sets the variable pointed to by lpServicesReturned to the actual number of service entries stored into the buffer. The function sets the variable pointed to by pcbBytesNeeded to the number of bytes required to store all of the service entries. |
boolean EnumServicesStatusEx(Winsvc.SC_HANDLE hSCManager, int InfoLevel, int dwServiceType, int dwServiceState, Pointer lpServices, int cbBufSize, IntByReference pcbBytesNeeded, IntByReference lpServicesReturned, IntByReference lpResumeHandle, java.lang.String pszGroupName)
hSCManager
- A handle to the service control manager
database. This handle is returned by the
OpenSCManager(java.lang.String, java.lang.String, int)
function, and must have
the Winsvc.SC_MANAGER_ENUMERATE_SERVICE
access right. For more information, see Service
Security and Access Rights.InfoLevel
- The service attributes that are to be returned.
Use Winsvc.SC_ENUM_PROCESS_INFO
to
retrieve the name and service status
information for each service in the database.
The lpServices parameter is a pointer to a
buffer that receives an array of
Winsvc.ENUM_SERVICE_STATUS_PROCESS
structures. The buffer must be large enough to
hold the structures as well as the strings to
which their members point.
Currently, no other information levels are defined.
dwServiceType
- The type of services to be enumerated. This
parameter can be one or more of the following
values.
Value | Meaning |
---|---|
WinNT.SERVICE_DRIVER | Services of type WinNT.SERVICE_KERNEL_DRIVER and WinNT.SERVICE_FILE_SYSTEM_DRIVER . |
WinNT.SERVICE_FILE_SYSTEM_DRIVER | File system driver services. |
WinNT.SERVICE_KERNEL_DRIVER | Driver services. |
WinNT.SERVICE_WIN32 | Services of type WinNT.SERVICE_WIN32_OWN_PROCESS and WinNT.SERVICE_WIN32_SHARE_PROCESS . |
WinNT.SERVICE_WIN32_OWN_PROCESS | Services that run in their own processes. |
WinNT.SERVICE_WIN32_SHARE_PROCESS | Services that share a process with one or more other services. For more information, see Service Programs. |
dwServiceState
- The state of the services to be enumerated.
This parameter can be one of the following
values.
Value | Meaning |
---|---|
Winsvc.SERVICE_ACTIVE | Enumerates services that
are in the following states:
Winsvc.SERVICE_START_PENDING , Winsvc.SERVICE_STOP_PENDING , Winsvc.SERVICE_RUNNING , Winsvc.SERVICE_CONTINUE_PENDING , Winsvc.SERVICE_PAUSE_PENDING ,
and Winsvc.SERVICE_PAUSED . |
Winsvc.SERVICE_INACTIVE | Enumerates services that
are in the Winsvc.SERVICE_STOPPED state. |
Winsvc.SERVICE_STATE_ALL | Combines the following
states: Winsvc.SERVICE_ACTIVE and
Winsvc.SERVICE_INACTIVE . |
lpServices
- A pointer to the buffer that receives the
status information. The format of this data
depends on the value of the InfoLevel
parameter.
The maximum size of this array is 256K bytes. To determine the required size, specify NULL for this parameter and 0 for the cbBufSize parameter. The function will fail and GetLastError will return ERROR_MORE_DATA. The pcbBytesNeeded parameter will receive the required size.
Windows Server 2003 and Windows XP: The maximum size of this array is 64K bytes. This limit was increased as of Windows Server 2003 with SP1 and Windows XP with SP2.
cbBufSize
- The size of the buffer pointed to by the
lpServices parameter, in bytes.pcbBytesNeeded
- A pointer to a variable that receives the
number of bytes needed to store the array of
service entries. The variable only receives
this value if the buffer pointed to by
lpServices is too small, indicated by function
failure and the ERROR_MORE_DATA error;
otherwise, the contents of pcbBytesNeeded are
undefined.lpServicesReturned
- A pointer to a variable that receives the
number of service entries returned.lpResumeHandle
- A pointer to a variable that, on input,
specifies the starting point of enumeration.
You must set this value to zero the first time
the EnumServicesStatusEx(com.sun.jna.platform.win32.Winsvc.SC_HANDLE, int, int, int, com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference, java.lang.String)
function is
called. On output, this value is zero if the
function succeeds. However, if the function
returns zero and the
Kernel32.GetLastError()
function returns
WinError.ERROR_MORE_DATA
, this value
indicates the next service entry to be read
when the EnumServicesStatusEx(com.sun.jna.platform.win32.Winsvc.SC_HANDLE, int, int, int, com.sun.jna.Pointer, int, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference, com.sun.jna.ptr.IntByReference, java.lang.String)
function
is called to retrieve the additional data.pszGroupName
- The load-order group name. If this parameter is
a string, the only services enumerated are
those that belong to the group that has the
name specified by the string. If this parameter
is an empty string, only services that do not
belong to any group are enumerated. If this
parameter is NULL, group membership is ignored
and all services are enumerated.If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError. The following errors may be returned.
Return code | Description |
---|---|
WinError.ERROR_ACCESS_DENIED | The handle does not have the Winsvc.SERVICE_ENUMERATE_DEPENDENTS access right. |
WinError.ERROR_MORE_DATA | The buffer pointed to by lpServices is not large enough. The function sets the variable pointed to by lpServicesReturned to the actual number of service entries stored into the buffer. The function sets the variable pointed to by pcbBytesNeeded to the number of bytes required to store all of the service entries. |
WinError.ERROR_INVALID_HANDLE | The specified handle is invalid. |
WinError.ERROR_INVALID_PARAMETER | A parameter that was specified is invalid. |
WinError.ERROR_INVALID_LEVEL | The InfoLevel parameter contains an unsupported value. |
WinError.ERROR_SHUTDOWN_IN_PROGRESS | The system is shutting down; this function cannot be called. |
boolean CreateProcessAsUser(WinNT.HANDLE hToken, java.lang.String lpApplicationName, java.lang.String lpCommandLine, WinBase.SECURITY_ATTRIBUTES lpProcessAttributes, WinBase.SECURITY_ATTRIBUTES lpThreadAttributes, boolean bInheritHandles, int dwCreationFlags, java.lang.String lpEnvironment, java.lang.String lpCurrentDirectory, WinBase.STARTUPINFO lpStartupInfo, WinBase.PROCESS_INFORMATION lpProcessInformation)
hToken
- A handle to the primary token that represents a user.lpApplicationName
- The name of the module to be executed.lpCommandLine
- The command line to be executed.lpProcessAttributes
- A pointer to a SECURITY_ATTRIBUTES structure that specifies a
security descriptor for the new process object and determines
whether child processes can inherit the returned handle to the
process.lpThreadAttributes
- A pointer to a SECURITY_ATTRIBUTES structure that specifies a
security descriptor for the new thread object and determines
whether child processes can inherit the returned handle to the
thread.bInheritHandles
- If this parameter is TRUE, each inheritable handle in the
calling process is inherited by the new process. If the
parameter is FALSE, the handles are not inherited. Note that
inherited handles have the same value and access rights as the
original handles.dwCreationFlags
- The flags that control the priority class and the creation of
the process. For a list of values, see Process Creation Flags.lpEnvironment
- A pointer to an environment block for the new process. If this
parameter is NULL, the new process uses the environment of the
calling process.
An environment block consists of a null-terminated block of
null-terminated strings. Each string is in the following form:
name=value\0lpCurrentDirectory
- The full path to the current directory for the process. The
string can also specify a UNC path.lpStartupInfo
- A pointer to a STARTUPINFO or STARTUPINFOEX structure.lpProcessInformation
- A pointer to a PROCESS_INFORMATION structure that receives
identification information about the new process.boolean AdjustTokenPrivileges(WinNT.HANDLE TokenHandle, boolean DisableAllPrivileges, WinNT.TOKEN_PRIVILEGES NewState, int BufferLength, WinNT.TOKEN_PRIVILEGES PreviousState, IntByReference ReturnLength)
TokenHandle
- A handle to the access token that contains the privileges to
be modified.DisableAllPrivileges
- Specifies whether the function disables all of the token's
privileges.NewState
- A pointer to a TOKEN_PRIVILEGES structure that specifies an
array of privileges and their attributes.BufferLength
- Specifies the size, in bytes, of the buffer pointed to by the
PreviousState parameter. This parameter can be zero if the
PreviousState parameter is NULL.PreviousState
- A pointer to a buffer that the function fills with a
TOKEN_PRIVILEGES structure that contains the previous state of
any privileges that the function modifies.ReturnLength
- A pointer to a variable that receives the required size, in
bytes, of the buffer pointed to by the PreviousState
parameter.boolean LookupPrivilegeName(java.lang.String lpSystemName, WinNT.LUID lpLuid, char[] lpName, IntByReference cchName)
lpSystemName
- A pointer to a null-terminated string that specifies the name
of the system on which the privilege name is retrieved. If a
null string is specified, the function attempts to find the
privilege name on the local system.lpLuid
- A pointer to the LUID by which the privilege is known on the
target system.lpName
- A pointer to a buffer that receives a null-terminated string
that represents the privilege name. For example, this string
could be "SeSecurityPrivilege".cchName
- A pointer to a variable that specifies the size, in a TCHAR
value, of the lpName buffer.boolean LookupPrivilegeValue(java.lang.String lpSystemName, java.lang.String lpName, WinNT.LUID lpLuid)
lpSystemName
- A pointer to a null-terminated string that specifies the name
of the system on which the privilege name is retrieved. If a
null string is specified, the function attempts to find the
privilege name on the local system.lpName
- A pointer to a null-terminated string that specifies the name
of the privilege, as defined in the Winnt.h header file. For
example, this parameter could specify the constant,
SE_SECURITY_NAME, or its corresponding string,
"SeSecurityPrivilege".lpLuid
- A pointer to a variable that receives the LUID by which the
privilege is known on the system specified by the lpSystemName
parameter.boolean GetFileSecurity(java.lang.String lpFileName, int RequestedInformation, Pointer pointer, int nLength, IntByReference lpnLengthNeeded)
lpFileName
- A pointer to a null-terminated string that specifies the file
or directory for which security information is retrieved.RequestedInformation
- A SECURITY_INFORMATION value that identifies the security
information being requested. See WinNT *_SECURITY_INFORMATIONpointer
- A pointer to a buffer that receives a copy of the security
descriptor of the object specified by the lpFileName
parameter. The calling process must have permission to view
the specified aspects of the object's security status. The
SECURITY_DESCRIPTOR structure is returned in self-relative
format.nLength
- Specifies the size, in bytes, of the buffer pointed to by the
pSecurityDescriptor parameter.lpnLengthNeeded
- A pointer to the variable that receives the number of bytes
necessary to store the complete security descriptor. If the
returned number of bytes is less than or equal to nLength, the
entire security descriptor is returned in the output buffer;
otherwise, none of the descriptor is returned.boolean SetFileSecurity(java.lang.String lpFileName, int SecurityInformation, Pointer pSecurityDescriptor)
lpFileName
- A pointer to a null-terminated string that specifies the file or directory for which security is set.
Note that security applied to a directory is not inherited by its children.SecurityInformation
- Specifies a SECURITY_INFORMATION structure that identifies the contents of the security descriptor
pointed to by the pSecurityDescriptor parameter.pSecurityDescriptor
- A pointer to a SECURITY_DESCRIPTOR structure.int GetSecurityInfo(WinNT.HANDLE handle, int ObjectType, int SecurityInfo, PointerByReference ppsidOwner, PointerByReference ppsidGroup, PointerByReference ppDacl, PointerByReference ppSacl, PointerByReference ppSecurityDescriptor)
handle
- [in]
A handle to the object from which to retrieve security information.ObjectType
- [in]
SE_OBJECT_TYPE enumeration value that indicates the type of object.SecurityInfo
- [in]
A set of bit flags that indicate the type of security information to retrieve. See WinNT *_SECURITY_INFORMATIONppsidOwner
- [out, optional]
A pointer to a variable that receives a pointer to the owner SID in the security descriptor returned
in ppSecurityDescriptor. The returned pointer is valid only if you set the OWNER_SECURITY_INFORMATION flag.
This parameter can be NULL if you do not need the owner SID.ppsidGroup
- [in, optional]
A pointer to a variable that receives a pointer to the primary group SID in the returned security descriptor.
The returned pointer is valid only if you set the GROUP_SECURITY_INFORMATION flag. This parameter can be NULL
if you do not need the group SID.ppDacl
- [in, optional]
A pointer to a variable that receives a pointer to the DACL in the returned security descriptor. The returned
pointer is valid only if you set the DACL_SECURITY_INFORMATION flag. This parameter can be NULL if you do not
need the DACL.ppSacl
- [in, optional]
A pointer to a variable that receives a pointer to the SACL in the returned security descriptor. The returned
pointer is valid only if you set the SACL_SECURITY_INFORMATION flag. This parameter can be NULL if you do not
need the SACL.ppSecurityDescriptor
- A pointer to a variable that receives a pointer to the security descriptor of the object. When you have finished
using the pointer, free the returned buffer by calling the LocalFree function.
This parameter is required if any one of the ppsidOwner, ppsidGroup, ppDacl, or ppSacl parameters is not NULL.NOTES:
1. If the ppsidOwner, ppsidGroup, ppDacl, and ppSacl parameters are non-NULL, and the SecurityInfo parameter specifies that they be retrieved from the object, those parameters will point to the corresponding parameters in the security descriptor returned in ppSecurityDescriptor.
2. To read the owner, group, or DACL from the object's security descriptor, the calling process must have been granted READ_CONTROL access when the handle was opened. To get READ_CONTROL access, the caller must be the owner of the object or the object's DACL must grant the access.
3. To read the SACL from the security descriptor, the calling process must have been granted ACCESS_SYSTEM_SECURITY access when the handle was opened. The proper way to get this access is to enable the SE_SECURITY_NAME privilege in the caller's current token, open the handle for ACCESS_SYSTEM_SECURITY access, and then disable the privilege.
4. If the supplied handle was opened with an ACCESS_MASK value of MAXIMUM_ALLOWED, then the SetSecurityInfo function will not propagate ACEs to children.
int SetSecurityInfo(WinNT.HANDLE handle, int ObjectType, int SecurityInfo, Pointer ppsidOwner, Pointer ppsidGroup, Pointer ppDacl, Pointer ppSacl)
handle
- [in]
A handle to the object for which to set security information.ObjectType
- [in]
A value of the SE_OBJECT_TYPE enumeration that indicates the type
of object named by the pObjectName parameter.SecurityInfo
- [in]
A set of bit flags that indicate the type of security
information to set. See WinNT *_SECURITY_INFORMATIONppsidOwner
- [in, optional]
A pointer to a SID structure that identifies the owner of the object.
If the caller does not have the SeRestorePrivilege constant
(see Privilege Constants), this SID must be contained in the
caller's token, and must have the SE_GROUP_OWNER permission enabled.
The SecurityInfo parameter must include the OWNER_SECURITY_INFORMATION
flag. To set the owner, the caller must have WRITE_OWNER access to
the object or have the SE_TAKE_OWNERSHIP_NAME privilege enabled.
If you are not setting the owner SID, this parameter can be NULL.ppsidGroup
- [in, optional]
A pointer to a SID that identifies the primary group of the object.
The SecurityInfo parameter must include the GROUP_SECURITY_INFORMATION
flag. If you are not setting the primary group SID, this parameter
can be NULL.ppDacl
- [in, optional]
A pointer to the new DACL for the object. The SecurityInfo parameter
must include the DACL_SECURITY_INFORMATION flag. The caller must have
WRITE_DAC access to the object or be the owner of the object. If you
are not setting the DACL, this parameter can be NULL.ppSacl
- [in, optional]
A pointer to the new SACL for the object. The SecurityInfo parameter
must include any of the following flags: SACL_SECURITY_INFORMATION,
LABEL_SECURITY_INFORMATION, ATTRIBUTE_SECURITY_INFORMATION,
SCOPE_SECURITY_INFORMATION, or BACKUP_SECURITY_INFORMATION.
If setting SACL_SECURITY_INFORMATION or SCOPE_SECURITY_INFORMATION,
the caller must have the SE_SECURITY_NAME privilege enabled. If
you are not setting the SACL, this parameter can be NULL.NOTES:
1. If you are setting the discretionary access control list (DACL) or any elements in the system access control list (SACL) of an object, the system automatically propagates any inheritable access control entries (ACEs) to existing child objects, according to the ACE inheritance rules.
2. The SetSecurityInfo function does not reorder access-allowed or access-denied ACEs based on the preferred order. When propagating inheritable ACEs to existing child objects, SetSecurityInfo puts inherited ACEs in order after all of the noninherited ACEs in the DACLs of the child objects.
3. If share access to the children of the object is not available, this function will not propagate unprotected ACEs to the children. For example, if a directory is opened with exclusive access, the operating system will not propagate unprotected ACEs to the subdirectories or files of that directory when the security on the directory is changed.
4. If the supplied handle was opened with an ACCESS_MASK value of MAXIMUM_ALLOWED, then the SetSecurityInfo function will not propagate ACEs to children.
int GetNamedSecurityInfo(java.lang.String pObjectName, int ObjectType, int SecurityInfo, PointerByReference ppsidOwner, PointerByReference ppsidGroup, PointerByReference ppDacl, PointerByReference ppSacl, PointerByReference ppSecurityDescriptor)
pObjectName
- A pointer to a that specifies the name of the object from
which to retrieve security information.
For descriptions of the string formats for the different
object types, see SE_OBJECT_TYPE.ObjectType
- Specifies a value from the SE_OBJECT_TYPE enumeration that
indicates the type of object named by the pObjectName parameter.SecurityInfo
- A set of bit flags that indicate the type of security
information to retrieve. See WinNT *_SECURITY_INFORMATIONppsidOwner
- [out, optional]
A pointer to a variable that receives a pointer to the owner SID
in the security descriptor returned in ppSecurityDescriptor
or NULL if the security descriptor has no owner SID.
The returned pointer is valid only if you set the
OWNER_SECURITY_INFORMATION flag. Also, this parameter can be
NULL if you do not need the owner SID.ppsidGroup
- [out, optional]
A pointer to a variable that receives a pointer to the primary
group SID in the returned security descriptor or NULL if the
security descriptor has no group SID. The returned pointer is
valid only if you set the GROUP_SECURITY_INFORMATION flag.
Also, this parameter can be NULL if you do not need the group SID.ppDacl
- [out, optional]
A pointer to a variable that receives a pointer to the DACL in
the returned security descriptor or NULL if the security
descriptor has no DACL. The returned pointer is valid only if
you set the DACL_SECURITY_INFORMATION flag. Also, this parameter
can be NULL if you do not need the DACL.ppSacl
- [out, optional]
A pointer to a variable that receives a pointer to the SACL in
the returned security descriptor or NULL if the security
descriptor has no SACL. The returned pointer is valid only if
you set the SACL_SECURITY_INFORMATION flag. Also, this parameter
can be NULL if you do not need the SACL.ppSecurityDescriptor
- A pointer to a variable that receives a pointer to the security
descriptor of the object. When you have finished using the
pointer, free the returned buffer by calling the LocalFree
function.
This parameter is required if any one of the ppsidOwner,
ppsidGroup, ppDacl, or ppSacl parameters is not NULL.int SetNamedSecurityInfo(java.lang.String pObjectName, int ObjectType, int SecurityInfo, Pointer ppsidOwner, Pointer ppsidGroup, Pointer ppDacl, Pointer ppSacl)
pObjectName
- [in]
A pointer to a string that specifies the name of the object for
which to set security information. This can be
the name of a local or remote file or directory on an NTFS file
system, network share, registry key, semaphore, event, mutex,
file mapping, or waitable timer. *
For descriptions of the string formats for the different
object types, see SE_OBJECT_TYPE.ObjectType
- [in]
A value of the SE_OBJECT_TYPE enumeration that indicates the type
of object named by the pObjectName parameter.SecurityInfo
- [in]
A set of bit flags that indicate the type of security
information to set. See WinNT *_SECURITY_INFORMATIONppsidOwner
- [in, optional]
A pointer to a SID structure that identifies the owner of the object.
If the caller does not have the SeRestorePrivilege constant
(see Privilege Constants), this SID must be contained in the
caller's token, and must have the SE_GROUP_OWNER permission enabled.
The SecurityInfo parameter must include the OWNER_SECURITY_INFORMATION
flag. To set the owner, the caller must have WRITE_OWNER access to
the object or have the SE_TAKE_OWNERSHIP_NAME privilege enabled.
If you are not setting the owner SID, this parameter can be NULL.ppsidGroup
- [in, optional]
A pointer to a SID that identifies the primary group of the object.
The SecurityInfo parameter must include the GROUP_SECURITY_INFORMATION
flag. If you are not setting the primary group SID, this parameter
can be NULL.ppDacl
- [in, optional]
A pointer to the new DACL for the object. The SecurityInfo parameter
must include the DACL_SECURITY_INFORMATION flag. The caller must have
WRITE_DAC access to the object or be the owner of the object. If you
are not setting the DACL, this parameter can be NULL.ppSacl
- [in, optional]
A pointer to the new SACL for the object. The SecurityInfo parameter
must include any of the following flags: SACL_SECURITY_INFORMATION,
LABEL_SECURITY_INFORMATION, ATTRIBUTE_SECURITY_INFORMATION,
SCOPE_SECURITY_INFORMATION, or BACKUP_SECURITY_INFORMATION.
If setting SACL_SECURITY_INFORMATION or SCOPE_SECURITY_INFORMATION,
the caller must have the SE_SECURITY_NAME privilege enabled. If
you are not setting the SACL, this parameter can be NULL.int GetSecurityDescriptorLength(Pointer ppSecurityDescriptor)
ppSecurityDescriptor
- A pointer to the SECURITY_DESCRIPTOR structure whose length the function returns.
The pointer is assumed to be valid.boolean IsValidSecurityDescriptor(Pointer ppSecurityDescriptor)
ppSecurityDescriptor
- [in]
A pointer to a SECURITY_DESCRIPTOR structure that the function validates.boolean MakeSelfRelativeSD(WinNT.SECURITY_DESCRIPTOR pAbsoluteSD, WinNT.SECURITY_DESCRIPTOR_RELATIVE pSelfRelativeSD, IntByReference lpdwBufferLength)
pAbsoluteSD
- A pointer to a SECURITY_DESCRIPTOR structure in absolute format. The function creates a version of this
security descriptor in self-relative format without modifying the original.pSelfRelativeSD
- A pointer to a buffer the function fills with a security descriptor in self-relative format.lpdwBufferLength
- A pointer to a variable specifying the size of the buffer pointed to by the pSelfRelativeSD parameter.
If the buffer is not large enough for the security descriptor, the function fails and sets this variable
to the minimum required size.boolean MakeAbsoluteSD(WinNT.SECURITY_DESCRIPTOR_RELATIVE pSelfRelativeSD, WinNT.SECURITY_DESCRIPTOR pAbsoluteSD, IntByReference lpdwAbsoluteSDSize, WinNT.ACL pDacl, IntByReference lpdwDaclSize, WinNT.ACL pSacl, IntByReference lpdwSaclSize, WinNT.PSID pOwner, IntByReference lpdwOwnerSize, WinNT.PSID pPrimaryGroup, IntByReference lpdwPrimaryGroupSize)
pSelfRelativeSD
- A pointer to a SECURITY_DESCRIPTOR structure in self-relative format. The function creates an
absolute-format version of this security descriptor without modifying the original security descriptor.pAbsoluteSD
- A pointer to a buffer that the function fills with the main body of an absolute-format security
descriptor. This information is formatted as a SECURITY_DESCRIPTOR structure.lpdwAbsoluteSDSize
- A pointer to a variable that specifies the size of the buffer pointed to by the pAbsoluteSD parameter.
If the buffer is not large enough for the security descriptor, the function fails and sets this variable
to the minimum required size.pDacl
- A pointer to a buffer the function fills with the discretionary access control list (DACL) of the
absolute-format security descriptor. The main body of the absolute-format security descriptor references
this pointer.lpdwDaclSize
- A pointer to a variable that specifies the size of the buffer pointed to by the pDacl parameter. If
the buffer is not large enough for the access control list (ACL), the function fails and sets this
variable to the minimum required size.pSacl
- A pointer to a buffer the function fills with the system access control list (SACL) of the absolute-format
security descriptor. The main body of the absolute-format security descriptor references this pointer.lpdwSaclSize
- A pointer to a variable that specifies the size of the buffer pointed to by the pSacl parameter. If the
buffer is not large enough for the ACL, the function fails and sets this variable to the minimum required
size.pOwner
- A pointer to a buffer the function fills with the security identifier (SID) of the owner of the
absolute-format security descriptor. The main body of the absolute-format security descriptor references
this pointer.lpdwOwnerSize
- A pointer to a variable that specifies the size of the buffer pointed to by the pOwner parameter.
If the buffer is not large enough for the SID, the function fails and sets this variable to the minimum
required size.pPrimaryGroup
- A pointer to a buffer the function fills with the SID of the absolute-format security descriptor's
primary group. The main body of the absolute-format security descriptor references this pointer.lpdwPrimaryGroupSize
- A pointer to a variable that specifies the size of the buffer pointed to by the pPrimaryGroup parameter.
If the buffer is not large enough for the SID, the function fails and sets this variable to the minimum
required size.boolean IsValidAcl(Pointer pAcl)
pAcl
- [in]
A pointer to an ACL structure validated by this function. This value must not be NULL.void MapGenericMask(WinDef.DWORDByReference AccessMask, WinNT.GENERIC_MAPPING GenericMapping)
AccessMask
- [in, out] A pointer to an access mask.GenericMapping
- [in] A pointer to a GENERIC_MAPPING structure specifying a mapping of generic access types to specific and standard access types.boolean AccessCheck(Pointer pSecurityDescriptor, WinNT.HANDLE ClientToken, WinDef.DWORD DesiredAccess, WinNT.GENERIC_MAPPING GenericMapping, WinNT.PRIVILEGE_SET PrivilegeSet, WinDef.DWORDByReference PrivilegeSetLength, WinDef.DWORDByReference GrantedAccess, WinDef.BOOLByReference AccessStatus)
pSecurityDescriptor
- [in] A pointer to a SECURITY_DESCRIPTOR structure against which access is checked.ClientToken
- [in] A handle to an impersonation token that represents the client that is attempting to gain access. The handle must have TOKEN_QUERY access to the token; otherwise, the function fails with ERROR_ACCESS_DENIED.DesiredAccess
- [in] Access mask that specifies the access rights to check. This mask must have been mapped by the MapGenericMask function to contain no generic access rights.GenericMapping
- [in] A pointer to the GENERIC_MAPPING structure associated with the object for which access is being checked.PrivilegeSet
- [out, optional] A pointer to a PRIVILEGE_SET structure that receives the privileges used to perform the access validation. If no privileges were used, the function sets the PrivilegeCount member to zero.PrivilegeSetLength
- [in, out] Specifies the size, in bytes, of the buffer pointed to by the PrivilegeSet parameter.GrantedAccess
- [out] A pointer to an access mask that receives the granted access rights. If AccessStatus is set to FALSE, the function sets the access mask to zero. If the function fails, it does not set the access mask.AccessStatus
- [out] A pointer to a variable that receives the results of the access check. If the security descriptor allows the requested access rights to the client identified by the access token, AccessStatus is set to TRUE. Otherwise, AccessStatus is set to FALSE, and you can call GetLastError to get extended error information.boolean EncryptFile(java.lang.String lpFileName)
lpFileName
- The name of the file or directory to be encrypted.boolean DecryptFile(java.lang.String lpFileName, WinDef.DWORD dwReserved)
lpFileName
- The name of the file or directory to be decrypted.dwReserved
- Reserved; must be zero.boolean FileEncryptionStatus(java.lang.String lpFileName, WinDef.DWORDByReference lpStatus)
lpFileName
- The name of the file.lpStatus
- A pointer to a variable that receives the encryption status of the
file.boolean EncryptionDisable(java.lang.String DirPath, boolean Disable)
DirPath
- The name of the directory for which to enable or disable
encryption.Disable
- Indicates whether to disable encryption (TRUE) or enable it
(FALSE).int OpenEncryptedFileRaw(java.lang.String lpFileName, WinDef.ULONG ulFlags, PointerByReference pvContext)
lpFileName
- The name of the file to be opened. The string must consist of
characters from the Windows character set.ulFlags
- The operation to be performed.pvContext
- The address of a context block that must be presented in subsequent
calls to ReadEncryptedFileRaw, WriteEncryptedFileRaw, or
CloseEncryptedFileRaw. Do not modify it.int ReadEncryptedFileRaw(WinBase.FE_EXPORT_FUNC pfExportCallback, Pointer pvCallbackContext, Pointer pvContext)
pfExportCallback
- A pointer to the export callback function. The system calls the
callback function multiple times, each time passing a block of the
file's data to the callback function until the entire file has been
read. For more information, see ExportCallback.pvCallbackContext
- A pointer to an application-defined and allocated context block.
The system passes this pointer to the callback function as a
parameter so that the callback function can have access to
application-specific data. This can be a structure and can contain
any data the application needs, such as the handle to the file that
will contain the backup copy of the encrypted file.pvContext
- A pointer to a system-defined context block. The context block is
returned by the OpenEncryptedFileRaw function. Do not modify it.int WriteEncryptedFileRaw(WinBase.FE_IMPORT_FUNC pfImportCallback, Pointer pvCallbackContext, Pointer pvContext)
pfImportCallback
- A pointer to the import callback function. The system calls the
callback function multiple times, each time passing a buffer that
will be filled by the callback function with a portion of backed-up
file's data. When the callback function signals that the entire
file has been processed, it tells the system that the restore
operation is finished. For more information, see ImportCallback.pvCallbackContext
- A pointer to an application-defined and allocated context block.
The system passes this pointer to the callback function as a
parameter so that the callback function can have access to
application-specific data. This can be a structure and can contain
any data the application needs, such as the handle to the file that
will contain the backup copy of the encrypted file.pvContext
- A pointer to a system-defined context block. The context block is
returned by the OpenEncryptedFileRaw function. Do not modify it.void CloseEncryptedFileRaw(Pointer pvContext)
pvContext
- A pointer to a system-defined context block. The
OpenEncryptedFileRaw function returns the context block.boolean CreateProcessWithLogonW(java.lang.String lpUsername, java.lang.String lpDomain, java.lang.String lpPassword, int dwLogonFlags, java.lang.String lpApplicationName, java.lang.String lpCommandLine, int dwCreationFlags, Pointer lpEnvironment, java.lang.String lpCurrentDirectory, WinBase.STARTUPINFO lpStartupInfo, WinBase.PROCESS_INFORMATION lpProcessInfo)
BOOL WINAPI CreateProcessWithLogonW(
_In_ LPCWSTR lpUsername,
_In_opt_ LPCWSTR lpDomain,
_In_ LPCWSTR lpPassword,
_In_ DWORD dwLogonFlags,
_In_opt_ LPCWSTR lpApplicationName,
_Inout_opt_ LPWSTR lpCommandLine,
_In_ DWORD dwCreationFlags,
_In_opt_ LPVOID lpEnvironment,
_In_opt_ LPCWSTR lpCurrentDirectory,
_In_ LPSTARTUPINFOW lpStartupInfo,
_Out_ LPPROCESS_INFORMATION lpProcessInfo
);
lpUsername
- [in]lpDomain
- [in, optional]lpPassword
- [in]dwLogonFlags
- [in]lpApplicationName
- [in, optional]lpCommandLine
- [in, out, optional]dwCreationFlags
- The flags that control how the process is created. lpEnvironment
- [in, optional]lpCurrentDirectory
- [in, optional]lpStartupInfo
- [in]lpProcessInfo
- [out]boolean StartServiceCtrlDispatcher(Winsvc.SERVICE_TABLE_ENTRY[] lpServiceTable)
lpServiceTable
- A pointer to an array of SERVICE_TABLE_ENTRY
structures containing one entry for each service
that can execute in the calling process. The
members of the last entry in the table must have
NULL values to designate the end of the table.Return code | Description |
---|---|
ERROR_FAILED_SERVICE_CONTROLLER_CONNECT | This error is returned if the program is being run as a console application rather than as a service. If the program will be run as a console application for debugging purposes, structure it such that service-specific code is not called when this error is returned. |
ERROR_INVALID_DATA | The specified dispatch table contains entries that are not in the proper format. |
ERROR_SERVICE_ALREADY_RUNNING | The process has already called StartServiceCtrlDispatcher. Each process can call StartServiceCtrlDispatcher only one time. |
Winsvc.SERVICE_STATUS_HANDLE RegisterServiceCtrlHandler(java.lang.String lpServiceName, Library.Handler lpHandlerProc)
This function has been superseded by the RegisterServiceCtrlHandlerEx function. A service can use either function, but the new function supports user-defined context data, and the new handler function supports additional extended control codes.
lpServiceName
- The name of the service run by the calling thread.
This is the service name that the service control
program specified in the CreateService function when
creating the service.
If the service type is SERVICE_WIN32_OWN_PROCESS, the function does not verify that the specified name is valid, because there is only one registered service in the process.
lpHandlerProc
- A pointer to the handler function to be registered.
For more information, see
WinSvc.Handler
.Return code | Description |
---|---|
ERROR_NOT_ENOUGH_MEMORY | Not enough memory is available to convert an ANSI string parameter to Unicode. This error does not occur for Unicode string parameters. |
ERROR_SERVICE_NOT_IN_EXE | The service entry was specified incorrectly when the process called the StartServiceCtrlDispatcher(com.sun.jna.platform.win32.Winsvc.SERVICE_TABLE_ENTRY[]) function. |
Winsvc.SERVICE_STATUS_HANDLE RegisterServiceCtrlHandlerEx(java.lang.String lpServiceName, Winsvc.HandlerEx lpHandlerProc, Pointer lpContext)
lpServiceName
- The name of the service run by the calling thread.
This is the service name that the service control
program specified in the CreateService function when
creating the service.lpHandlerProc
- The handler function to be registered.
For more information, see HandlerEx.lpContext
- Any user-defined data. This parameter, which is
passed to the handler function, can help identify
the service when multiple services share a process.Return code | Description |
---|---|
ERROR_NOT_ENOUGH_MEMORY | Not enough memory is available to convert an ANSI string parameter to Unicode. This error does not occur for Unicode string parameters. |
ERROR_SERVICE_NOT_IN_EXE | The service entry was specified incorrectly when the process called the StartServiceCtrlDispatcher(com.sun.jna.platform.win32.Winsvc.SERVICE_TABLE_ENTRY[]) function. |
boolean SetServiceStatus(Winsvc.SERVICE_STATUS_HANDLE hServiceStatus, Winsvc.SERVICE_STATUS lpServiceStatus)
hServiceStatus
- A handle to the status information structure for
the current service. This handle is returned by
the RegisterServiceCtrlHandlerEx function.lpServiceStatus
- A pointer to the SERVICE_STATUS structure the
contains the latest status information for the
calling service.Return code | Description |
---|---|
ERROR_INVALID_DATA | The specified service status structure is invalid. |
ERROR_INVALID_HANDLE | The specified handle is invalid. |
Winsvc.SC_HANDLE CreateService(Winsvc.SC_HANDLE hSCManager, java.lang.String lpServiceName, java.lang.String lpDisplayName, int dwDesiredAccess, int dwServiceType, int dwStartType, int dwErrorControl, java.lang.String lpBinaryPathName, java.lang.String lpLoadOrderGroup, IntByReference lpdwTagId, java.lang.String lpDependencies, java.lang.String lpServiceStartName, java.lang.String lpPassword)
hSCManager
- [in] A handle to the service control manager
database. This handle is returned by the
OpenSCManager function and must have the
SC_MANAGER_CREATE_SERVICE access right. For
more information, see Service Security and
Access Rights.lpServiceName
- [in] 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
- [in, optional] 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.dwDesiredAccess
- [in] The access to the service. Before granting
the requested access, the system checks the
access token of the calling process. For a list
of values, see Service Security and Access
Rights.dwServiceType
- [in] The service type. This parameter can be
one of the following values.
Value | Meaning |
---|---|
SERVICE_ADAPTER 0x00000004 | Reserved. |
SERVICE_FILE_SYSTEM_DRIVER 0x00000002 | File system driver service. |
SERVICE_KERNEL_DRIVER 0x00000001 | Driver service. |
SERVICE_RECOGNIZER_DRIVER 0x00000008 | Reserved. |
SERVICE_WIN32_OWN_PROCESS 0x00000010 | Service that runs in its own process. |
SERVICE_WIN32_SHARE_PROCESS 0x00000020 | Service that shares a process with one or more other services. For more information, see Service Programs. |
If you specify either SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS, and the service is running in the context of the LocalSystem account, you can also specify the following value.
Value | Meaning |
---|---|
SERVICE_INTERACTIVE_PROCESS 0x00000100 | The service can interact with the desktop. |
dwStartType
- [in] The service start options. This parameter
can be one of the following values.
Value | Meaning |
---|---|
SERVICE_AUTO_START 0x00000002 | A service started automatically by the service control manager during system startup. |
SERVICE_BOOT_START 0x00000000 | A device driver started by the system loader. This value is valid only for driver services. |
SERVICE_DEMAND_START 0x00000003 | A service started by the service control manager when a process calls the StartService function. |
SERVICE_DISABLED 0x00000004 | A service that cannot be started. Attempts to start the service result in the error code ERROR_SERVICE_DISABLED. |
SERVICE_SYSTEM_START 0x00000001 | A device driver started by the IoInitSystem function. This value is valid only for driver services. |
dwErrorControl
- [in] The severity of the error, and action
taken, if this service fails to start. This
parameter can be one of the following values.
Value | Meaning |
---|---|
SERVICE_ERROR_CRITICAL 0x00000003 | The startup program logs the error in the event log, if possible. If the last-known-good configuration is being started, the startup operation fails. Otherwise, the system is restarted with the last-known good configuration. |
SERVICE_ERROR_IGNORE 0x00000000 | The startup program ignores the error and continues the startup operation. |
SERVICE_ERROR_NORMAL 0x00000001 | The startup program logs the error in the event log but continues the startup operation. |
SERVICE_ERROR_SEVERE 0x00000002 | The startup program logs the error in the event log. If the last-known-good configuration is being started, the startup operation continues. Otherwise, the system is restarted with the last-known-good configuration. |
lpBinaryPathName
- [in, optional] 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 passed to the service entry point (typically the main function).
If you specify a path on another computer, the share must be accessible by the computer account of the local computer because this is the security context used in the remote call. However, this requirement allows any potential vulnerabilities in the remote computer to affect the local computer. Therefore, it is best to use a local file.
lpLoadOrderGroup
- [in, optional] The names of the load ordering
group of which this service is a member.
Specify NULL or an empty string if the service
does not belong to a group.
The startup program uses load ordering groups to load groups of services in a specified order with respect to the other groups. The list of load ordering groups is contained in the following registry value:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ServiceGroupOrder
lpdwTagId
- [out, optional] A pointer to a variable that
receives a tag value that is unique in the
group specified in the lpLoadOrderGroup
parameter. Specify NULL if you are not changing
the existing tag.
You can use a tag for ordering service startup within a load ordering group by specifying a tag order vector in the following registry value:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\GroupOrderList
Tags are only evaluated for driver services that have SERVICE_BOOT_START or SERVICE_SYSTEM_START start types.
lpDependencies
- [in, optional] A pointer to a double
null-terminated array of null-separated names
of services or load ordering groups that the
system must start before this service. Specify
NULL or an empty string if the service has no
dependencies. Dependency on a group means that
this service can run if at least one member of
the group is running after an attempt to start
all members of the group.
You must prefix group names with SC_GROUP_IDENTIFIER so that they can be distinguished from a service name, because services and service groups share the same name space.
lpServiceStartName
- [in, optional] The name of the account under
which the service should run. If the service
type is SERVICE_WIN32_OWN_PROCESS, 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.
If this parameter is NULL, CreateService uses the LocalSystem account. If the service type specifies SERVICE_INTERACTIVE_PROCESS, the service must run in the LocalSystem account.
If this parameter is NT AUTHORITY\LocalService, CreateService uses the LocalService account. If the parameter is NT AUTHORITY\NetworkService, CreateService uses the NetworkService account.
A shared process can run as any user.
If the service type is SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER, the name is the driver object name that the system uses to load the device driver. Specify NULL if the driver is to use a default object name created by the I/O system.
A service can be configured to use a managed account or a virtual account. If the service is configured to use a managed service account, the name is the managed service account name. If the service is configured to use a virtual account, specify the name as NT SERVICE\ServiceName. For more information about managed service accounts and virtual accounts, see the Service Accounts Step-by-Step Guide.
Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: Managed service accounts and virtual accounts are not supported until Windows 7 and Windows Server 2008 R2.
lpPassword
- [in, optional] 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. For more information, see Service
Record List.
If the account name specified by the lpServiceStartName parameter is the name of a managed service account or virtual account name, the lpPassword parameter must be NULL.
Passwords are ignored for driver services.
Return code | Description |
---|---|
ERROR_ACCESS_DENIED | The handle to the SCM database does not have the SC_MANAGER_CREATE_SERVICE access right. |
ERROR_CIRCULAR_DEPENDENCY | A circular service dependency was specified. |
ERROR_DUPLICATE_SERVICE_NAME | The display name already exists in the service control manager database either as a service name or as another display name. |
ERROR_INVALID_HANDLE | The handle to the specified service control manager database is invalid. |
ERROR_INVALID_NAME | The specified service name is invalid. |
ERROR_INVALID_PARAMETER | A parameter that was specified is invalid. |
ERROR_INVALID_SERVICE_ACCOUNT | The user account name specified in the lpServiceStartName parameter does not exist. |
ERROR_SERVICE_EXISTS | The specified service already exists in this database. |
ERROR_SERVICE_MARKED_FOR_DELETE | The specified service already exists in this database and has been marked for deletion. |
boolean DeleteService(Winsvc.SC_HANDLE hService)
hService
- [in] A handle to the service. This handle is returned by
the OpenService or CreateService function, and it must
have the DELETE access right.Return code | Description |
---|---|
ERROR_ACCESS_DENIED | The handle does not have the DELETE access right. |
ERROR_INVALID_HANDLE | The specified handle is invalid. |
ERROR_SERVICE_MARKED_FOR_DELETE | The specified service has already been marked for deletion. |