//******************************************************************************************************// WindowsApi.cs - Gbtc//// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.//// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See// the NOTICE file distributed with this work for additional information regarding copyright ownership.// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may// not use this file except in compliance with the License. You may obtain a copy of the License at://// http://www.opensource.org/licenses/MIT//// Unless agreed to in writing, the subject software distributed under the License is distributed on an// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the// License for the specific language governing permissions and limitations.//// Code Modification History:// ----------------------------------------------------------------------------------------------------// 01/24/2006 - J. Ritchie Carroll// Initial version of source created.// 09/10/2008 - J. Ritchie Carroll// Converted to C#.// 08/05/2009 - Josh L. Patterson// Edited Comments.// 09/14/2009 - Stephen C. Wills// Added new header and license agreement.// 02/04/2011 - J. Ritchie Carroll// Added WindowsAPI methods used to define automation of service failure actions.// 02/20/2011 - J. Ritchie Carroll// Added WindowsAPI methods used to help with UAC (User Account Control).// 09/21/2011 - J. Ritchie Carroll// Excluded class from Mono deployments due to P/Invoke requirements.// 12/14/2012 - Starlynn Danyelle Gilliam// Modified Header.////****************************************************************************************************** using System;using System.Diagnostics.CodeAnalysis;using System.IO;using System.Runtime.InteropServices;using System.Text;using Microsoft.Win32.SafeHandles; #pragma warning disable 1591 namespace GSF.Interop{ /// <summary> /// Defines common Windows API constants, enumerations, structures and functions. /// </summary> [SuppressMessage("Microsoft.Interoperability", "CA1414:MarkBooleanPInvokeArgumentsWithMarshalAs")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "lp")] [SuppressMessage("Microsoft.Interoperability", "CA1401:PInvokesShouldNotBeVisible")] [SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "2#")] public static class WindowsApi { /// <summary> /// Use the standard logon provider for the system. The default security provider is NTLM. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "LOGON")] [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int LOGON32_PROVIDER_DEFAULT = 0; /// <summary> /// This logon type is intended for users who will be interactively using the computer, such as a user being logged on by a terminal server, /// remote shell, or similar process. This logon type has the additional expense of caching logon information for disconnected operations; /// therefore, it is inappropriate for some client/server applications, such as a mail server. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "LOGON")] [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int LOGON32_LOGON_INTERACTIVE = 2; /// <summary> /// This logon type is intended for high performance servers to authenticate plaintext passwords. The LogonUserEx function does not cache /// credentials for this logon type. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "LOGON")] [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int LOGON32_LOGON_NETWORK = 3; /// <summary> /// Impersonate a client at the impersonation level. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int SECURITY_IMPERSONATION = 2; /// <summary> /// Access is denied. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int ERROR_ACCESS_DENIED = 5; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int CRYPT_OID_INFO_OID_KEY = 1; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int CRYPT_OID_INFO_NAME_KEY = 2; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint CRYPT_OID_DISABLE_SEARCH_DS_FLAG = 0x80000000u; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int CRYPT_INSTALL_OID_INFO_BEFORE_FLAG = 1; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SERVICE_LOGON_NAME = "SeServiceLogonRight"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_AUDIT_NAME = "SeAuditPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_BACKUP_NAME = "SeBackupPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_GLOBAL_NAME = "SeCreateGlobalPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_SYMBOLIC_LINK_NAME = "SeCreateSymbolicLinkPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_DEBUG_NAME = "SeDebugPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_ENABLE_DELEGATION_NAME = "SeEnableDelegationPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_IMPERSONATE_NAME = "SeImpersonatePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_INC_WORKING_SET_NAME = "SeIncreaseWorkingSetPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_MANAGE_VOLUME_NAME = "SeManageVolumePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_RELABEL_NAME = "SeRelabelPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_RESTORE_NAME = "SeRestorePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SECURITY_NAME = "SeSecurityPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SYNC_AGENT_NAME = "SeSyncAgentPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_TCB_NAME = "SeTcbPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_TIME_ZONE_NAME = "SeTimeZonePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_TRUSTED_CREDMAN_ACCESS_NAME = "SeTrustedCredManAccessPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_UNDOCK_NAME = "SeUndockPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint SE_PRIVILEGE_ENABLED = 0x00000002; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint SE_PRIVILEGE_REMOVED = 0x00000004; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000; // Use these for DesiredAccess [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint STANDARD_RIGHTS_REQUIRED = 0x000F0000; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint STANDARD_RIGHTS_READ = 0x00020000; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ASSIGN_PRIMARY = 0x0001; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_DUPLICATE = 0x0002; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_IMPERSONATE = 0x0004; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_QUERY = 0x0008; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_QUERY_SOURCE = 0x0010; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ADJUST_PRIVILEGES = 0x0020; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ADJUST_GROUPS = 0x0040; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ADJUST_DEFAULT = 0x0080; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ADJUST_SESSIONID = 0x0100; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_READ = (STANDARD_RIGHTS_READ | TOKEN_QUERY); [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT | TOKEN_ADJUST_SESSIONID); /// <summary> /// Win32 TOKEN_INFORMATION_CLASS enumeration. /// </summary> [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue"), SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores"), SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] public enum TOKEN_INFORMATION_CLASS { /// <summary> /// The buffer receives a TOKEN_USER structure that contains the user account of the token. /// </summary> TokenUser = 1, /// <summary> /// The buffer receives a TOKEN_GROUPS structure that contains the group accounts associated with the token. /// </summary> TokenGroups, /// <summary> /// The buffer receives a TOKEN_PRIVILEGES structure that contains the privileges of the token. /// </summary> TokenPrivileges, /// <summary> /// The buffer receives a TOKEN_OWNER structure that contains the default owner security identifier (SID) for newly created objects. /// </summary> TokenOwner, /// <summary> /// The buffer receives a TOKEN_PRIMARY_GROUP structure that contains the default primary group SID for newly created objects. /// </summary> TokenPrimaryGroup, /// <summary> /// The buffer receives a TOKEN_DEFAULT_DACL structure that contains the default DACL for newly created objects. /// </summary> TokenDefaultDacl, /// <summary> /// The buffer receives a TOKEN_SOURCE structure that contains the source of the token. TOKEN_QUERY_SOURCE access is needed to retrieve this information. /// </summary> TokenSource, /// <summary> /// The buffer receives a TOKEN_TYPE value that indicates whether the token is a primary or impersonation token. /// </summary> TokenType, /// <summary> /// The buffer receives a SECURITY_IMPERSONATION_LEVEL value that indicates the impersonation level of the token. If the access token is not an impersonation token, the function fails. /// </summary> TokenImpersonationLevel, /// <summary> /// The buffer receives a TOKEN_STATISTICS structure that contains various token statistics. /// </summary> TokenStatistics, /// <summary> /// The buffer receives a TOKEN_GROUPS structure that contains the list of restricting SIDs in a restricted token. /// </summary> TokenRestrictedSids, /// <summary> /// The buffer receives a DWORD value that indicates the Terminal Services session identifier that is associated with the token. /// </summary> TokenSessionId, /// <summary> /// The buffer receives a TOKEN_GROUPS_AND_PRIVILEGES structure that contains the user SID, the group accounts, the restricted SIDs, and the authentication ID associated with the token. /// </summary> TokenGroupsAndPrivileges, /// <summary> /// Reserved. /// </summary> TokenSessionReference, /// <summary> /// The buffer receives a DWORD value that is nonzero if the token includes the SANDBOX_INERT flag. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "SandBox")] TokenSandBoxInert, /// <summary> /// Reserved. /// </summary> TokenAuditPolicy, /// <summary> /// The buffer receives a TOKEN_ORIGIN value. /// </summary> TokenOrigin, /// <summary> /// The buffer receives a TOKEN_ELEVATION_TYPE value that specifies the elevation level of the token. /// </summary> TokenElevationType, /// <summary> /// The buffer receives a TOKEN_LINKED_TOKEN structure that contains a handle to another token that is linked to this token. /// </summary> TokenLinkedToken, /// <summary> /// The buffer receives a TOKEN_ELEVATION structure that specifies whether the token is elevated. /// </summary> TokenElevation, /// <summary> /// The buffer receives a DWORD value that is nonzero if the token has ever been filtered. /// </summary> TokenHasRestrictions, /// <summary> /// The buffer receives a TOKEN_ACCESS_INFORMATION structure that specifies security information contained in the token. /// </summary> TokenAccessInformation, /// <summary> /// The buffer receives a DWORD value that is nonzero if virtualization is allowed for the token. /// </summary> TokenVirtualizationAllowed, /// <summary> /// The buffer receives a DWORD value that is nonzero if virtualization is enabled for the token. /// </summary> TokenVirtualizationEnabled, /// <summary> /// The buffer receives a TOKEN_MANDATORY_LABEL structure that specifies the token's integrity level. /// </summary> TokenIntegrityLevel, /// <summary> /// The buffer receives a DWORD value that is nonzero if the token has the UIAccess flag set. /// </summary> TokenUIAccess, /// <summary> /// The buffer receives a TOKEN_MANDATORY_POLICY structure that specifies the token's mandatory integrity policy. /// </summary> TokenMandatoryPolicy, /// <summary> /// The buffer receives the token's logon security identifier (SID). /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Logon")] TokenLogonSid, /// <summary> /// The maximum value for this enumeration /// </summary> MaxTokenInfoClass } /// <summary> /// Win32 ProcessAccessTypes enumeration. /// </summary> [SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags"), SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible"), Flags] public enum ProcessAccessTypes : uint { /// <summary /// >Enables usage of the process handle in the TerminateProcess function to terminate the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_TERMINATE = 0x00000001, /// <summary> /// Enables usage of the process handle in the CreateRemoteThread function to create a thread in the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_CREATE_THREAD = 0x00000002, /// <summary> /// Sets the session ID. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_SET_SESSIONID = 0x00000004, /// <summary> /// Enables usage of the process handle in the VirtualProtectEx and WriteProcessMemory functions to modify the virtual memory of the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_VM_OPERATION = 0x00000008, /// <summary> /// Enables usage of the process handle in the ReadProcessMemory function to read from the virtual memory of the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_VM_READ = 0x00000010, /// <summary> /// Enables usage of the process handle in the WriteProcessMemory function to write to the virtual memory of the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_VM_WRITE = 0x00000020, /// <summary> /// Enables usage of the process handle as either the source or target process in the DuplicateHandle function to duplicate a handle. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_DUP_HANDLE = 0x00000040, /// <summary> /// Creates a process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_CREATE_PROCESS = 0x00000080, /// <summary> /// Sets quota. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_SET_QUOTA = 0x00000100, /// <summary> /// Enables usage of the process handle in the SetPriorityClass function to set the priority class of the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_SET_INFORMATION = 0x00000200, /// <summary> /// Enables usage of the process handle in the GetExitCodeProcess and GetPriorityClass functions to read information from the process object. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_QUERY_INFORMATION = 0x00000400, /// <summary> /// Standard rights required. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] STANDARD_RIGHTS_REQUIRED = 0x000F0000, /// <summary> /// Enables usage of the process handle in any of the wait functions to wait for the process to terminate. /// </summary> SYNCHRONIZE = 0x00100000, /// <summary> /// Specifies all possible access flags for the process object. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_ALL_ACCESS = PROCESS_TERMINATE | PROCESS_CREATE_THREAD | PROCESS_SET_SESSIONID | PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_DUP_HANDLE | PROCESS_CREATE_PROCESS | PROCESS_SET_QUOTA | PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION | STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE } /// <summary> /// Win32 ShutdownReason enumeration. /// </summary> [SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags"), SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue"), SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible"), SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames"), Flags] public enum ShutdownReason : uint { // Microsoft major reasons. [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_OTHER = 0x00000000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_NONE = 0x00000000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_HARDWARE = 0x00010000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_OPERATINGSYSTEM = 0x00020000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_SOFTWARE = 0x00030000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_APPLICATION = 0x00040000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_SYSTEM = 0x00050000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_POWER = 0x00060000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_LEGACY_API = 0x00070000, // Microsoft minor reasons. [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_OTHER = 0x00000000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_NONE = 0x000000ff, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_MAINTENANCE = 0x00000001, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_INSTALLATION = 0x00000002, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_UPGRADE = 0x00000003, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_RECONFIG = 0x00000004, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_HUNG = 0x00000005, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_UNSTABLE = 0x00000006, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_DISK = 0x00000007, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_PROCESSOR = 0x00000008, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_NETWORKCARD = 0x00000000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_POWER_SUPPLY = 0x0000000a, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")]Lines 1–500 of 1266. Load more
//****************************************************************************************************** // WindowsApi.cs - Gbtc // // Copyright © 2012, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may // not use this file except in compliance with the License. You may obtain a copy of the License at: // // http://www.opensource.org/licenses/MIT // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 01/24/2006 - J. Ritchie Carroll // Initial version of source created. // 09/10/2008 - J. Ritchie Carroll // Converted to C#. // 08/05/2009 - Josh L. Patterson // Edited Comments. // 09/14/2009 - Stephen C. Wills // Added new header and license agreement. // 02/04/2011 - J. Ritchie Carroll // Added WindowsAPI methods used to define automation of service failure actions. // 02/20/2011 - J. Ritchie Carroll // Added WindowsAPI methods used to help with UAC (User Account Control). // 09/21/2011 - J. Ritchie Carroll // Excluded class from Mono deployments due to P/Invoke requirements. // 12/14/2012 - Starlynn Danyelle Gilliam // Modified Header. // //****************************************************************************************************** using System; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Runtime.InteropServices; using System.Text; using Microsoft.Win32.SafeHandles; #pragma warning disable 1591 namespace GSF.Interop { /// <summary> /// Defines common Windows API constants, enumerations, structures and functions. /// </summary> [SuppressMessage("Microsoft.Interoperability", "CA1414:MarkBooleanPInvokeArgumentsWithMarshalAs")] [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "lp")] [SuppressMessage("Microsoft.Interoperability", "CA1401:PInvokesShouldNotBeVisible")] [SuppressMessage("Microsoft.Design", "CA1045:DoNotPassTypesByReference", MessageId = "2#")] public static class WindowsApi { /// <summary> /// Use the standard logon provider for the system. The default security provider is NTLM. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "LOGON")] [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int LOGON32_PROVIDER_DEFAULT = 0; /// <summary> /// This logon type is intended for users who will be interactively using the computer, such as a user being logged on by a terminal server, /// remote shell, or similar process. This logon type has the additional expense of caching logon information for disconnected operations; /// therefore, it is inappropriate for some client/server applications, such as a mail server. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "LOGON")] [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int LOGON32_LOGON_INTERACTIVE = 2; /// <summary> /// This logon type is intended for high performance servers to authenticate plaintext passwords. The LogonUserEx function does not cache /// credentials for this logon type. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "LOGON")] [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int LOGON32_LOGON_NETWORK = 3; /// <summary> /// Impersonate a client at the impersonation level. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int SECURITY_IMPERSONATION = 2; /// <summary> /// Access is denied. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int ERROR_ACCESS_DENIED = 5; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int CRYPT_OID_INFO_OID_KEY = 1; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int CRYPT_OID_INFO_NAME_KEY = 2; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint CRYPT_OID_DISABLE_SEARCH_DS_FLAG = 0x80000000u; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const int CRYPT_INSTALL_OID_INFO_BEFORE_FLAG = 1; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SERVICE_LOGON_NAME = "SeServiceLogonRight"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_AUDIT_NAME = "SeAuditPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_BACKUP_NAME = "SeBackupPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_GLOBAL_NAME = "SeCreateGlobalPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_SYMBOLIC_LINK_NAME = "SeCreateSymbolicLinkPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_DEBUG_NAME = "SeDebugPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_ENABLE_DELEGATION_NAME = "SeEnableDelegationPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_IMPERSONATE_NAME = "SeImpersonatePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_INC_WORKING_SET_NAME = "SeIncreaseWorkingSetPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_MANAGE_VOLUME_NAME = "SeManageVolumePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_RELABEL_NAME = "SeRelabelPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_RESTORE_NAME = "SeRestorePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SECURITY_NAME = "SeSecurityPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SYNC_AGENT_NAME = "SeSyncAgentPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_TCB_NAME = "SeTcbPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_TIME_ZONE_NAME = "SeTimeZonePrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_TRUSTED_CREDMAN_ACCESS_NAME = "SeTrustedCredManAccessPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_UNDOCK_NAME = "SeUndockPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const string SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint SE_PRIVILEGE_ENABLED_BY_DEFAULT = 0x00000001; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint SE_PRIVILEGE_ENABLED = 0x00000002; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint SE_PRIVILEGE_REMOVED = 0x00000004; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint SE_PRIVILEGE_USED_FOR_ACCESS = 0x80000000; // Use these for DesiredAccess [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint STANDARD_RIGHTS_REQUIRED = 0x000F0000; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint STANDARD_RIGHTS_READ = 0x00020000; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ASSIGN_PRIMARY = 0x0001; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_DUPLICATE = 0x0002; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_IMPERSONATE = 0x0004; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_QUERY = 0x0008; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_QUERY_SOURCE = 0x0010; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ADJUST_PRIVILEGES = 0x0020; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ADJUST_GROUPS = 0x0040; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ADJUST_DEFAULT = 0x0080; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ADJUST_SESSIONID = 0x0100; [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_READ = (STANDARD_RIGHTS_READ | TOKEN_QUERY); [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] public const uint TOKEN_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY | TOKEN_QUERY_SOURCE | TOKEN_ADJUST_PRIVILEGES | TOKEN_ADJUST_GROUPS | TOKEN_ADJUST_DEFAULT | TOKEN_ADJUST_SESSIONID); /// <summary> /// Win32 TOKEN_INFORMATION_CLASS enumeration. /// </summary> [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue"), SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores"), SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] public enum TOKEN_INFORMATION_CLASS { /// <summary> /// The buffer receives a TOKEN_USER structure that contains the user account of the token. /// </summary> TokenUser = 1, /// <summary> /// The buffer receives a TOKEN_GROUPS structure that contains the group accounts associated with the token. /// </summary> TokenGroups, /// <summary> /// The buffer receives a TOKEN_PRIVILEGES structure that contains the privileges of the token. /// </summary> TokenPrivileges, /// <summary> /// The buffer receives a TOKEN_OWNER structure that contains the default owner security identifier (SID) for newly created objects. /// </summary> TokenOwner, /// <summary> /// The buffer receives a TOKEN_PRIMARY_GROUP structure that contains the default primary group SID for newly created objects. /// </summary> TokenPrimaryGroup, /// <summary> /// The buffer receives a TOKEN_DEFAULT_DACL structure that contains the default DACL for newly created objects. /// </summary> TokenDefaultDacl, /// <summary> /// The buffer receives a TOKEN_SOURCE structure that contains the source of the token. TOKEN_QUERY_SOURCE access is needed to retrieve this information. /// </summary> TokenSource, /// <summary> /// The buffer receives a TOKEN_TYPE value that indicates whether the token is a primary or impersonation token. /// </summary> TokenType, /// <summary> /// The buffer receives a SECURITY_IMPERSONATION_LEVEL value that indicates the impersonation level of the token. If the access token is not an impersonation token, the function fails. /// </summary> TokenImpersonationLevel, /// <summary> /// The buffer receives a TOKEN_STATISTICS structure that contains various token statistics. /// </summary> TokenStatistics, /// <summary> /// The buffer receives a TOKEN_GROUPS structure that contains the list of restricting SIDs in a restricted token. /// </summary> TokenRestrictedSids, /// <summary> /// The buffer receives a DWORD value that indicates the Terminal Services session identifier that is associated with the token. /// </summary> TokenSessionId, /// <summary> /// The buffer receives a TOKEN_GROUPS_AND_PRIVILEGES structure that contains the user SID, the group accounts, the restricted SIDs, and the authentication ID associated with the token. /// </summary> TokenGroupsAndPrivileges, /// <summary> /// Reserved. /// </summary> TokenSessionReference, /// <summary> /// The buffer receives a DWORD value that is nonzero if the token includes the SANDBOX_INERT flag. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "SandBox")] TokenSandBoxInert, /// <summary> /// Reserved. /// </summary> TokenAuditPolicy, /// <summary> /// The buffer receives a TOKEN_ORIGIN value. /// </summary> TokenOrigin, /// <summary> /// The buffer receives a TOKEN_ELEVATION_TYPE value that specifies the elevation level of the token. /// </summary> TokenElevationType, /// <summary> /// The buffer receives a TOKEN_LINKED_TOKEN structure that contains a handle to another token that is linked to this token. /// </summary> TokenLinkedToken, /// <summary> /// The buffer receives a TOKEN_ELEVATION structure that specifies whether the token is elevated. /// </summary> TokenElevation, /// <summary> /// The buffer receives a DWORD value that is nonzero if the token has ever been filtered. /// </summary> TokenHasRestrictions, /// <summary> /// The buffer receives a TOKEN_ACCESS_INFORMATION structure that specifies security information contained in the token. /// </summary> TokenAccessInformation, /// <summary> /// The buffer receives a DWORD value that is nonzero if virtualization is allowed for the token. /// </summary> TokenVirtualizationAllowed, /// <summary> /// The buffer receives a DWORD value that is nonzero if virtualization is enabled for the token. /// </summary> TokenVirtualizationEnabled, /// <summary> /// The buffer receives a TOKEN_MANDATORY_LABEL structure that specifies the token's integrity level. /// </summary> TokenIntegrityLevel, /// <summary> /// The buffer receives a DWORD value that is nonzero if the token has the UIAccess flag set. /// </summary> TokenUIAccess, /// <summary> /// The buffer receives a TOKEN_MANDATORY_POLICY structure that specifies the token's mandatory integrity policy. /// </summary> TokenMandatoryPolicy, /// <summary> /// The buffer receives the token's logon security identifier (SID). /// </summary> [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Logon")] TokenLogonSid, /// <summary> /// The maximum value for this enumeration /// </summary> MaxTokenInfoClass } /// <summary> /// Win32 ProcessAccessTypes enumeration. /// </summary> [SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags"), SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible"), Flags] public enum ProcessAccessTypes : uint { /// <summary /// >Enables usage of the process handle in the TerminateProcess function to terminate the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_TERMINATE = 0x00000001, /// <summary> /// Enables usage of the process handle in the CreateRemoteThread function to create a thread in the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_CREATE_THREAD = 0x00000002, /// <summary> /// Sets the session ID. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_SET_SESSIONID = 0x00000004, /// <summary> /// Enables usage of the process handle in the VirtualProtectEx and WriteProcessMemory functions to modify the virtual memory of the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_VM_OPERATION = 0x00000008, /// <summary> /// Enables usage of the process handle in the ReadProcessMemory function to read from the virtual memory of the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_VM_READ = 0x00000010, /// <summary> /// Enables usage of the process handle in the WriteProcessMemory function to write to the virtual memory of the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_VM_WRITE = 0x00000020, /// <summary> /// Enables usage of the process handle as either the source or target process in the DuplicateHandle function to duplicate a handle. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_DUP_HANDLE = 0x00000040, /// <summary> /// Creates a process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_CREATE_PROCESS = 0x00000080, /// <summary> /// Sets quota. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_SET_QUOTA = 0x00000100, /// <summary> /// Enables usage of the process handle in the SetPriorityClass function to set the priority class of the process. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_SET_INFORMATION = 0x00000200, /// <summary> /// Enables usage of the process handle in the GetExitCodeProcess and GetPriorityClass functions to read information from the process object. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_QUERY_INFORMATION = 0x00000400, /// <summary> /// Standard rights required. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] STANDARD_RIGHTS_REQUIRED = 0x000F0000, /// <summary> /// Enables usage of the process handle in any of the wait functions to wait for the process to terminate. /// </summary> SYNCHRONIZE = 0x00100000, /// <summary> /// Specifies all possible access flags for the process object. /// </summary> [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] PROCESS_ALL_ACCESS = PROCESS_TERMINATE | PROCESS_CREATE_THREAD | PROCESS_SET_SESSIONID | PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_DUP_HANDLE | PROCESS_CREATE_PROCESS | PROCESS_SET_QUOTA | PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION | STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE } /// <summary> /// Win32 ShutdownReason enumeration. /// </summary> [SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags"), SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue"), SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible"), SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames"), Flags] public enum ShutdownReason : uint { // Microsoft major reasons. [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_OTHER = 0x00000000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_NONE = 0x00000000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_HARDWARE = 0x00010000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_OPERATINGSYSTEM = 0x00020000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_SOFTWARE = 0x00030000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_APPLICATION = 0x00040000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_SYSTEM = 0x00050000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_POWER = 0x00060000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MAJOR_LEGACY_API = 0x00070000, // Microsoft minor reasons. [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_OTHER = 0x00000000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_NONE = 0x000000ff, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_MAINTENANCE = 0x00000001, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_INSTALLATION = 0x00000002, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_UPGRADE = 0x00000003, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_RECONFIG = 0x00000004, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_HUNG = 0x00000005, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_UNSTABLE = 0x00000006, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_DISK = 0x00000007, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_PROCESSOR = 0x00000008, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_NETWORKCARD = 0x00000000, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")] SHTDN_REASON_MINOR_POWER_SUPPLY = 0x0000000a, [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores")]