--- mstools/h/winnt.h 2018/08/09 18:20:01 1.1 +++ mstools/h/winnt.h 2018/08/09 18:20:25 1.1.1.2 @@ -1,6 +1,6 @@ -/*++ BUILD Version: 0047 // Increment this if a change has global effects +/*++ BUILD Version: 0078 // Increment this if a change has global effects -Copyright (c) 1990 Microsoft Corporation +Copyright (c) 1990-1992 Microsoft Corporation Module Name: @@ -11,10 +11,6 @@ Abstract: This module defines the 32-Bit Windows types and constants that are defined by NT, but exposed through the Win32 API. -Created: - - 18-Sep-1990 - Revision History: --*/ @@ -22,6 +18,7 @@ Revision History: #ifndef _WINNT_ #define _WINNT_ +#define ANYSIZE_ARRAY 1 #ifdef MIPS #define UNALIGNED __unaligned #else @@ -41,33 +38,104 @@ typedef long LONG; #endif // -// UNICODE +// UNICODE (Wide Character) types // typedef unsigned short WCHAR; // wc, 16-bit UNICODE character -typedef WCHAR *LPWCH, *PWCH; // pwc -typedef WCHAR *LPWSTR, *PWSTR; // pwsz, 0x0000 terminated UNICODE strings only +typedef WCHAR *PWCHAR; +typedef WCHAR *LPWCH, *PWCH; +typedef CONST WCHAR *LPCWCH, *PCWCH; +typedef WCHAR *NWPSTR; +typedef WCHAR *LPWSTR, *PWSTR; + +typedef CONST WCHAR *LPCWSTR, *PCWSTR; // -// Portable UNICODE types and macros +// ANSI (Multi-byte Character) types // +typedef CHAR *PCHAR; +typedef CHAR *LPCH, *PCH; + +typedef CONST CHAR *LPCCH, *PCCH; +typedef CHAR *NPSTR; +typedef CHAR *LPSTR, *PSTR; +typedef CONST CHAR *LPCSTR, *PCSTR; + +// +// Neutral ANSI/UNICODE types and macros +// #ifdef UNICODE typedef WCHAR TCHAR; +typedef LPWSTR LPTCH, PTCH; +typedef LPWSTR PTSTR, LPTSTR; +typedef LPCWSTR LPCTSTR; +typedef LPWSTR LP; #define TEXT(quote) L##quote #else -typedef char TCHAR; +typedef char TCHAR, *PTCHAR; +typedef LPSTR LPTCH, PTCH; +typedef LPSTR PTSTR, LPTSTR; +typedef LPCSTR LPCTSTR; #define TEXT(quote) quote #endif -typedef TCHAR *LPTSTR; typedef SHORT *PSHORT; typedef LONG *PLONG; -typedef PVOID HANDLE; -typedef HANDLE *PHANDLE; +#ifdef STRICT +typedef const void *HANDLE; +#define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef const struct name##__ *name + +#else +typedef PVOID HANDLE; +#define DECLARE_HANDLE(name) typedef HANDLE name +#endif +typedef HANDLE *PHANDLE; +typedef char CCHAR; +/*lint -e624 */ +/*lint +e624 */ +#define APPLICATION_ERROR_MASK 0x20000000 +#define ERROR_SEVERITY_SUCCESS 0x00000000 +#define ERROR_SEVERITY_INFORMATIONAL 0x40000000 +#define ERROR_SEVERITY_WARNING 0x80000000 +#define ERROR_SEVERITY_ERROR 0xC0000000 + +typedef struct _LARGE_INTEGER { + DWORD LowPart; + LONG HighPart; +} LARGE_INTEGER, *PLARGE_INTEGER; + +typedef struct _ULARGE_INTEGER { + DWORD LowPart; + DWORD HighPart; +} ULARGE_INTEGER, *PULARGE_INTEGER; + +typedef LARGE_INTEGER LUID; +typedef LUID *PLUID; #define UNICODE_NULL ((WCHAR)0) +typedef CCHAR BOOLEAN; +typedef BOOLEAN *PBOOLEAN; +// +// Doubly linked list structure. Can be used as either a list head, or +// as link words. +// + +typedef struct _LIST_ENTRY { + struct _LIST_ENTRY *Flink; + struct _LIST_ENTRY *Blink; +} LIST_ENTRY; +typedef LIST_ENTRY *PLIST_ENTRY; + +// +// Singly linked list structure. Can be used as either a list head, or +// as link words. +// + +typedef struct _SINGLE_LIST_ENTRY { + struct _SINGLE_LIST_ENTRY *Next; +} SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; #define MINCHAR 0x80 #define MAXCHAR 0x7f #define MINSHORT 0x8000 @@ -128,18 +196,33 @@ typedef HANDLE *PHANDLE; #endif // lint or _lint -/*lint -e767 */ // Don't complain about different definitions +/*lint -e767 */ #define STATUS_WAIT_0 ((DWORD )0x00000000L) #define STATUS_ABANDONED_WAIT_0 ((DWORD )0x00000080L) +#define STATUS_USER_APC ((DWORD )0x000000C0L) #define STATUS_TIMEOUT ((DWORD )0x00000102L) #define STATUS_PENDING ((DWORD )0x00000103L) #define STATUS_DATATYPE_MISALIGNMENT ((DWORD )0x80000002L) #define STATUS_BREAKPOINT ((DWORD )0x80000003L) #define STATUS_SINGLE_STEP ((DWORD )0x80000004L) #define STATUS_ACCESS_VIOLATION ((DWORD )0xC0000005L) +#define STATUS_ILLEGAL_INSTRUCTION ((DWORD )0xC000001DL) #define STATUS_NONCONTINUABLE_EXCEPTION ((DWORD )0xC0000025L) +#define STATUS_INVALID_DISPOSITION ((DWORD )0xC0000026L) +#define STATUS_ARRAY_BOUNDS_EXCEEDED ((DWORD )0xC000008CL) +#define STATUS_FLOAT_DENORMAL_OPERAND ((DWORD )0xC000008DL) +#define STATUS_FLOAT_DIVIDE_BY_ZERO ((DWORD )0xC000008EL) +#define STATUS_FLOAT_INEXACT_RESULT ((DWORD )0xC000008FL) +#define STATUS_FLOAT_INVALID_OPERATION ((DWORD )0xC0000090L) +#define STATUS_FLOAT_OVERFLOW ((DWORD )0xC0000091L) +#define STATUS_FLOAT_STACK_CHECK ((DWORD )0xC0000092L) +#define STATUS_FLOAT_UNDERFLOW ((DWORD )0xC0000093L) +#define STATUS_INTEGER_DIVIDE_BY_ZERO ((DWORD )0xC0000094L) +#define STATUS_INTEGER_OVERFLOW ((DWORD )0xC0000095L) +#define STATUS_PRIVILEGED_INSTRUCTION ((DWORD )0xC0000096L) +#define STATUS_STACK_OVERFLOW ((DWORD )0xC00000FDL) #define STATUS_CONTROL_C_EXIT ((DWORD )0xC000013AL) -/*lint +e767 */ // Resume checking for different macro definitions +/*lint +e767 */ #define MAXIMUM_WAIT_OBJECTS 64 // Maximum number of wait objects #define MAXIMUM_SUSPEND_COUNT MAXCHAR // Maximum times thread can be suspended @@ -151,7 +234,6 @@ typedef DWORD KSPIN_LOCK; // Define the size of the 80387 save area, which is in the context frame. // -#define SIZE_OF_80387_ENVIRONMENT 108 #define SIZE_OF_80387_REGISTERS 80 // @@ -159,7 +241,7 @@ typedef DWORD KSPIN_LOCK; // #define CONTEXT_i386 0x00010000 // this assumes that i386 and -#define CONTEXT_i486 0x00010000 // i486 have identical context records +#define CONTEXT_i486 0x00010000 // i486 have identical context records #define CONTEXT_CONTROL (CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP #define CONTEXT_INTEGER (CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI @@ -168,7 +250,7 @@ typedef DWORD KSPIN_LOCK; #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x00000010L) // DB 0-3,6,7 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER |\ - CONTEXT_SEGMENTS) + CONTEXT_SEGMENTS) typedef struct _FLOATING_SAVE_AREA { DWORD ControlWord; @@ -179,6 +261,7 @@ typedef struct _FLOATING_SAVE_AREA { DWORD DataOffset; DWORD DataSelector; BYTE RegisterArea[SIZE_OF_80387_REGISTERS]; + DWORD Cr0NpxState; } FLOATING_SAVE_AREA; typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA; @@ -481,14 +564,16 @@ __jump_unwind ( #endif // MIPS #define EXCEPTION_NONCONTINUABLE 0x1 // Noncontinuable exception -#define EXCEPTION_MAXIMUM_PARAMETERS 4 // maximum number of exception parameters +#define EXCEPTION_MAXIMUM_PARAMETERS 15 // maximum number of exception parameters // // Exception record definition. // typedef struct _EXCEPTION_RECORD { + /*lint -e18 */ // Don't complain about different definitions DWORD ExceptionCode; + /*lint +e18 */ // Resume checking for different definitions DWORD ExceptionFlags; struct _EXCEPTION_RECORD *ExceptionRecord; PVOID ExceptionAddress; @@ -507,6 +592,8 @@ typedef struct _EXCEPTION_POINTERS { PCONTEXT ContextRecord; } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS; #define PROCESS_TERMINATE (0x0001) +#define PROCESS_CREATE_THREAD (0x0002) +#define PROCESS_VM_OPERATION (0x0008) #define PROCESS_VM_READ (0x0010) #define PROCESS_VM_WRITE (0x0020) #define PROCESS_DUP_HANDLE (0x0040) @@ -515,6 +602,7 @@ typedef struct _EXCEPTION_POINTERS { #define PROCESS_QUERY_INFORMATION (0x0400) #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \ 0xFFF) + #define THREAD_TERMINATE (0x0001) #define THREAD_SUSPEND_RESUME (0x0002) #define THREAD_GET_CONTEXT (0x0008) @@ -556,7 +644,6 @@ typedef struct _EXCEPTION_POINTERS { #define PROCESSOR_STEP_I0 0x00080000 #define PROCESSOR_OPTION_387 0x00000001 -#define PROCESSOR_OPTION_WEITEK 0x00000002 typedef struct _MEMORY_BASIC_INFORMATION { PVOID BaseAddress; @@ -566,8 +653,7 @@ typedef struct _MEMORY_BASIC_INFORMATION DWORD State; DWORD Protect; DWORD Type; -} MEMORY_BASIC_INFORMATION; -typedef MEMORY_BASIC_INFORMATION *PMEMORY_BASIC_INFORMATION; +} MEMORY_BASIC_INFORMATION, *PMEMORY_BASIC_INFORMATION; #define SECTION_QUERY 0x0001 #define SECTION_MAP_WRITE 0x0002 #define SECTION_MAP_READ 0x0004 @@ -593,16 +679,78 @@ typedef MEMORY_BASIC_INFORMATION *PMEMOR #define FILE_ATTRIBUTE_READONLY 0x00000001 #define FILE_ATTRIBUTE_HIDDEN 0x00000002 #define FILE_ATTRIBUTE_SYSTEM 0x00000004 +#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020 #define FILE_ATTRIBUTE_NORMAL 0x00000080 +#define FILE_ATTRIBUTE_TEMPORARY 0x00000100 +#define FILE_ATTRIBUTE_ATOMIC_WRITE 0x00000200 +#define FILE_ATTRIBUTE_XACTION_WRITE 0x00000400 +#define FILE_NOTIFY_CHANGE_FILE_NAME 0x00000001 +#define FILE_NOTIFY_CHANGE_DIR_NAME 0x00000002 +#define FILE_NOTIFY_CHANGE_ATTRIBUTES 0x00000004 +#define FILE_NOTIFY_CHANGE_SIZE 0x00000008 +#define FILE_NOTIFY_CHANGE_LAST_WRITE 0x00000010 +#define FILE_NOTIFY_CHANGE_SECURITY 0x00000100 #define FILE_CASE_SENSITIVE_SEARCH 0x00000001 #define FILE_CASE_PRESERVED_NAMES 0x00000002 #define FILE_UNICODE_ON_DISK 0x00000004 #define DUPLICATE_CLOSE_SOURCE 0x00000001 #define DUPLICATE_SAME_ACCESS 0x00000002 +typedef PVOID PACCESS_TOKEN; typedef PVOID PSECURITY_DESCRIPTOR; typedef PVOID PSID; -typedef DWORD ACCESS_MASK; +//////////////////////////////////////////////////////////////////////// +// // +// ACCESS MASK // +// // +//////////////////////////////////////////////////////////////////////// + +// +// Define the access mask as a longword sized structure divided up as +// follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---------------+---------------+-------------------------------+ +// |G|G|G|G|Res'd|A| StandardRights| SpecificRights | +// |R|W|E|A| |S| | | +// +-+-------------+---------------+-------------------------------+ +// +// typedef struct _ACCESS_MASK { +// WORD SpecificRights; +// BYTE StandardRights; +// BYTE AccessSystemAcl : 1; +// BYTE Reserved : 3; +// BYTE GenericAll : 1; +// BYTE GenericExecute : 1; +// BYTE GenericWrite : 1; +// BYTE GenericRead : 1; +// } ACCESS_MASK; +// typedef ACCESS_MASK *PACCESS_MASK; +// +// but to make life simple for programmer's we'll allow them to specify +// a desired access mask by simply OR'ing together mulitple single rights +// and treat an access mask as a ulong. For example +// +// DesiredAccess = DELETE | READ_CONTROL +// +// So we'll declare ACCESS_MASK as DWORD +// + +typedef DWORD ACCESS_MASK; +typedef ACCESS_MASK *PACCESS_MASK; + +//////////////////////////////////////////////////////////////////////// +// // +// ACCESS TYPES // +// // +//////////////////////////////////////////////////////////////////////// + + +// +// The following are masks for the predefined standard access types +// + #define DELETE (0x00010000L) #define READ_CONTROL (0x00020000L) #define WRITE_DAC (0x00040000L) @@ -639,15 +787,907 @@ typedef DWORD ACCESS_MASK; #define GENERIC_WRITE (0x40000000L) #define GENERIC_EXECUTE (0x20000000L) #define GENERIC_ALL (0x10000000L) -// Obsolete definition - not portable. -// replaced by DWORD definition below -//typedef struct _SECURITY_INFORMATION { -// DWORD Owner :1; -// DWORD Group :1; -// DWORD Dacl :1; -// DWORD Sacl :1; -// DWORD Reserved :28; -// } SECURITY_INFORMATION, *PSECURITY_INFORMATION; + + +// +// Define the generic mapping array. This is used to denote the +// mapping of each generic access right to a specific access mask. +// + +typedef struct _GENERIC_MAPPING { + ACCESS_MASK GenericRead; + ACCESS_MASK GenericWrite; + ACCESS_MASK GenericExecute; + ACCESS_MASK GenericAll; +} GENERIC_MAPPING; +typedef GENERIC_MAPPING *PGENERIC_MAPPING; + + + +//////////////////////////////////////////////////////////////////////// +// // +// LUID_AND_ATTRIBUTES // +// // +//////////////////////////////////////////////////////////////////////// +// +// + + +typedef struct _LUID_AND_ATTRIBUTES { + LUID Luid; + DWORD Attributes; + } LUID_AND_ATTRIBUTES, * PLUID_AND_ATTRIBUTES; + +typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY]; +typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY; + + +//////////////////////////////////////////////////////////////////////// +// // +// Security Id (SID) // +// // +//////////////////////////////////////////////////////////////////////// +// +// +// Pictorially the structure of an SID is as follows: +// +// 1 1 1 1 1 1 +// 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---------------------------------------------------------------+ +// | SubAuthorityCount |Reserved1 (SBZ)| Revision | +// +---------------------------------------------------------------+ +// | IdentifierAuthority[0] | +// +---------------------------------------------------------------+ +// | IdentifierAuthority[1] | +// +---------------------------------------------------------------+ +// | IdentifierAuthority[2] | +// +---------------------------------------------------------------+ +// | | +// +- - - - - - - - SubAuthority[] - - - - - - - - -+ +// | | +// +---------------------------------------------------------------+ +// +// + +typedef struct _SID_IDENTIFIER_AUTHORITY { + BYTE Value[6]; +} SID_IDENTIFIER_AUTHORITY, *PSID_IDENTIFIER_AUTHORITY; + + +typedef struct _SID { + BYTE Revision; + BYTE SubAuthorityCount; + SID_IDENTIFIER_AUTHORITY IdentifierAuthority; +#ifdef MIDL_PASS + [size_is(SubAuthorityCount)] DWORD SubAuthority[*]; +#else // MIDL_PASS + DWORD SubAuthority[ANYSIZE_ARRAY]; +#endif // MIDL_PASS +} SID, *PISID; + + + + + + + +#define SID_REVISION (1) // Current revision level +#define SID_MAX_SUB_AUTHORITIES (15) +#define SID_RECOMMENDED_SUB_AUTHORITIES (1) // Will change to around 6 + // in a future release. + +typedef enum _SID_NAME_USE { + SidTypeUser = 1, + SidTypeGroup, + SidTypeDomain, + SidTypeAlias, + SidTypeWellKnownGroup, + SidTypeDeletedAccount, + SidTypeInvalid, + SidTypeUnknown +} SID_NAME_USE, *PSID_NAME_USE; + + +typedef struct _SID_AND_ATTRIBUTES { + PSID Sid; + DWORD Attributes; + } SID_AND_ATTRIBUTES, * PSID_AND_ATTRIBUTES; + +typedef SID_AND_ATTRIBUTES SID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY]; +typedef SID_AND_ATTRIBUTES_ARRAY *PSID_AND_ATTRIBUTES_ARRAY; + + + + + + + + + +///////////////////////////////////////////////////////////////////////////// +// // +// Universal well-known SIDs // +// // +// Null SID S-1-0-0 // +// World S-1-1-0 // +// Local S-1-2-0 // +// Creator Owner ID S-1-3-0 // +// Creator Group ID S-1-3-1 // +// // +///////////////////////////////////////////////////////////////////////////// + +#define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0} +#define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1} +#define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2} +#define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3} + +#define SECURITY_NULL_RID (0x00000000L) +#define SECURITY_WORLD_RID (0x00000000L) +#define SECURITY_LOCAL_RID (0X00000000L) + +#define SECURITY_CREATOR_OWNER_RID (0x00000000L) +#define SECURITY_CREATOR_GROUP_RID (0x00000001L) + + + + +///////////////////////////////////////////////////////////////////////////// +// // +// NT well-known SIDs // +// // +// NT Authority S-1-5 // +// Dialup S-1-5-1 // +// // +// Network S-1-5-2 // +// Batch S-1-5-3 // +// Interactive S-1-5-4 // +// Service S-1-5-6 // +// // +// (Logon IDs) S-1-5-5-X-Y // +// // +// (Built-in domain) s-1-5-20 // +// // +///////////////////////////////////////////////////////////////////////////// + + +#define SECURITY_NT_AUTHORITY {0,0,0,0,0,5} + +#define SECURITY_DIALUP_RID (0x00000001L) +#define SECURITY_NETWORK_RID (0x00000002L) +#define SECURITY_BATCH_RID (0x00000003L) +#define SECURITY_INTERACTIVE_RID (0x00000004L) +#define SECURITY_SERVICE_RID (0x00000006L) + +#define SECURITY_LOGON_IDS_RID (0x00000005L) +#define SECURITY_LOGON_IDS_RID_COUNT (3L) + +#define SECURITY_LOCAL_SYSTEM_RID (0x00000012L) + +#define SECURITY_BUILTIN_DOMAIN_RID (0x00000020L) + + + + + +///////////////////////////////////////////////////////////////////////////// +// // +// well-known domain relative sub-authority values (RIDs)... // +// // +///////////////////////////////////////////////////////////////////////////// + +// Well-known users ... + +#define DOMAIN_USER_RID_ADMIN (0x000001F4L) +#define DOMAIN_USER_RID_GUEST (0x000001F5L) + + + +// well-known groups ... + +#define DOMAIN_GROUP_RID_ADMINS (0x00000200L) +#define DOMAIN_GROUP_RID_USERS (0x00000201L) + + + + +// well-known aliases ... + +#define DOMAIN_ALIAS_RID_ADMINS (0x00000220L) +#define DOMAIN_ALIAS_RID_USERS (0x00000221L) +#define DOMAIN_ALIAS_RID_GUESTS (0x00000222L) +#define DOMAIN_ALIAS_RID_POWER_USERS (0x00000223L) + +#define DOMAIN_ALIAS_RID_ACCOUNT_OPS (0x00000224L) +#define DOMAIN_ALIAS_RID_SYSTEM_OPS (0x00000225L) +#define DOMAIN_ALIAS_RID_PRINT_OPS (0x00000226L) +#define DOMAIN_ALIAS_RID_BACKUP_OPS (0x00000227L) + +#define DOMAIN_ALIAS_RID_REPLICATOR (0x00000228L) + + + + + + +// +// Allocate the System Luid. The first 1000 LUIDs are reserved. +// Use #999 here (0x3E7 = 999) +// + +#define SYSTEM_LUID {0x0, 0x3E7} + + + +//////////////////////////////////////////////////////////////////////// +// // +// User and Group related SID attributes // +// // +//////////////////////////////////////////////////////////////////////// + +// +// Group attributes +// + +#define SE_GROUP_MANDATORY (0x00000001L) +#define SE_GROUP_ENABLED_BY_DEFAULT (0x00000002L) +#define SE_GROUP_ENABLED (0x00000004L) +#define SE_GROUP_OWNER (0x00000008L) +#define SE_GROUP_LOGON_ID (0xC0000000L) + + + +// +// User attributes +// + +// (None yet defined.) + + + + +//////////////////////////////////////////////////////////////////////// +// // +// ACL and ACE // +// // +//////////////////////////////////////////////////////////////////////// + +// +// Define an ACL and the ACE format. The structure of an ACL header +// followed by one or more ACEs. Pictorally the structure of an ACL header +// is as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +-------------------------------+---------------+---------------+ +// | AclSize | Sbz1 | AclRevision | +// +-------------------------------+---------------+---------------+ +// | Sbz2 | AceCount | +// +-------------------------------+-------------------------------+ +// +// The current AclRevision is defined to be ACL_REVISION. +// +// AclSize is the size, in bytes, allocated for the ACL. This includes +// the ACL header, ACES, and remaining free space in the buffer. +// +// AceCount is the number of ACES in the ACL. +// + +// This is the *current* ACL revision + +#define ACL_REVISION (2) + +// This is the history of ACL revisions. Add a new one whenever +// ACL_REVISION is updated + +#define ACL_REVISION1 (1) +#define ACL_REVISION2 (2) + +typedef struct _ACL { + BYTE AclRevision; + BYTE Sbz1; + WORD AclSize; + WORD AceCount; + WORD Sbz2; +} ACL; +typedef ACL *PACL; + +// +// The structure of an ACE is a common ace header followed by ace type +// specific data. Pictorally the structure of the common ace header is +// as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---------------+-------+-------+---------------+---------------+ +// | AceSize | AceFlags | AceType | +// +---------------+-------+-------+---------------+---------------+ +// +// AceType denotes the type of the ace, there are some predefined ace +// types +// +// AceSize is the size, in bytes, of ace. +// +// AceFlags are the Ace flags for audit and inheritance, defined shortly. + +typedef struct _ACE_HEADER { + BYTE AceType; + BYTE AceFlags; + WORD AceSize; +} ACE_HEADER; +typedef ACE_HEADER *PACE_HEADER; + +// +// The following are the predefined ace types that go into the AceType +// field of an Ace header. +// + +#define ACCESS_ALLOWED_ACE_TYPE (0x0) +#define ACCESS_DENIED_ACE_TYPE (0x1) +#define SYSTEM_AUDIT_ACE_TYPE (0x2) +#define SYSTEM_ALARM_ACE_TYPE (0x3) + +// +// The following are the inherit flags that go into the AceFlags field +// of an Ace header. +// + +#define OBJECT_INHERIT_ACE (0x1) +#define CONTAINER_INHERIT_ACE (0x2) +#define NO_PROPAGATE_INHERIT_ACE (0x4) +#define INHERIT_ONLY_ACE (0x8) +#define VALID_INHERIT_FLAGS (0xF) + + +// The following are the currently defined ACE flags that go into the +// AceFlags field of an ACE header. Each ACE type has its own set of +// AceFlags. +// +// SUCCESSFUL_ACCESS_ACE_FLAG - used only with system audit and alarm ACE +// types to indicate that a message is generated for successful accesses. +// +// FAILED_ACCESS_ACE_FLAG - used only with system audit and alarm ACE types +// to indicate that a message is generated for failed accesses. +// + +// +// SYSTEM_AUDIT and SYSTEM_ALARM AceFlags +// +// These control the signaling of audit and alarms for success or failure. +// + +#define SUCCESSFUL_ACCESS_ACE_FLAG (0x40) +#define FAILED_ACCESS_ACE_FLAG (0x80) + + +// +// We'll define the structure of the predefined ACE types. Pictorally +// the structure of the predefined ACE's is as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---------------+-------+-------+---------------+---------------+ +// | AceFlags | Resd |Inherit| AceSize | AceType | +// +---------------+-------+-------+---------------+---------------+ +// | Mask | +// +---------------------------------------------------------------+ +// | | +// + + +// | | +// + Sid + +// | | +// + + +// | | +// +---------------------------------------------------------------+ +// +// Mask is the access mask associated with the ACE. This is either the +// access allowed, access denied, audit, or alarm mask. +// +// Sid is the Sid associated with the ACE. +// + +// The following are the four predefined ACE types. + +// Examine the AceType field in the Header to determine +// which structure is appropriate to use for casting. + +typedef struct _ACCESS_ALLOWED_ACE { + ACE_HEADER Header; + ACCESS_MASK Mask; + DWORD SidStart; +} ACCESS_ALLOWED_ACE; + +typedef ACCESS_ALLOWED_ACE *PACCESS_ALLOWED_ACE; + +typedef struct _ACCESS_DENIED_ACE { + ACE_HEADER Header; + ACCESS_MASK Mask; + DWORD SidStart; +} ACCESS_DENIED_ACE; +typedef ACCESS_DENIED_ACE *PACCESS_DENIED_ACE; + +typedef struct _SYSTEM_AUDIT_ACE { + ACE_HEADER Header; + ACCESS_MASK Mask; + DWORD SidStart; +} SYSTEM_AUDIT_ACE; +typedef SYSTEM_AUDIT_ACE *PSYSTEM_AUDIT_ACE; + +typedef struct _SYSTEM_ALARM_ACE { + ACE_HEADER Header; + ACCESS_MASK Mask; + DWORD SidStart; +} SYSTEM_ALARM_ACE; +typedef SYSTEM_ALARM_ACE *PSYSTEM_ALARM_ACE; + + + +// +// The following declarations are used for setting and querying information +// about and ACL. First are the various information classes available to +// the user. +// + +typedef enum _ACL_INFORMATION_CLASS { + AclRevisionInformation = 1, + AclSizeInformation +} ACL_INFORMATION_CLASS; + +// +// This record is returned/sent if the user is requesting/setting the +// AclRevisionInformation +// + +typedef struct _ACL_REVISION_INFORMATION { + DWORD AclRevision; +} ACL_REVISION_INFORMATION; +typedef ACL_REVISION_INFORMATION *PACL_REVISION_INFORMATION; + +// +// This record is returned if the user is requesting AclSizeInformation +// + +typedef struct _ACL_SIZE_INFORMATION { + DWORD AceCount; + DWORD AclBytesInUse; + DWORD AclBytesFree; +} ACL_SIZE_INFORMATION; +typedef ACL_SIZE_INFORMATION *PACL_SIZE_INFORMATION; + + +//////////////////////////////////////////////////////////////////////// +// // +// SECURITY_DESCRIPTOR // +// // +//////////////////////////////////////////////////////////////////////// +// +// Define the Security Descriptor and related data types. +// This is an opaque data structure. +// + +// +// Current security descriptor revision value +// + +#define SECURITY_DESCRIPTOR_REVISION (1) +#define SECURITY_DESCRIPTOR_REVISION1 (1) + +// +// Minimum length, in bytes, needed to build a security descriptor +// (NOTE: This must manually be kept consistent with the) +// (sizeof(SECURITY_DESCRIPTOR) ) +// + +#define SECURITY_DESCRIPTOR_MIN_LENGTH (20) + + +typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL; + +#define SE_OWNER_DEFAULTED (0x0001) +#define SE_GROUP_DEFAULTED (0x0002) +#define SE_DACL_PRESENT (0x0004) +#define SE_DACL_DEFAULTED (0x0008) +#define SE_SACL_PRESENT (0x0010) +#define SE_SACL_DEFAULTED (0x0020) +#define SE_SELF_RELATIVE (0x8000) + +// +// Where: +// +// SE_OWNER_DEFAULTED - This boolean flag, when set, indicates that the +// SID pointed to by the Owner field was provided by a +// defaulting mechanism rather than explicitly provided by the +// original provider of the security descriptor. This may +// affect the treatment of the SID with respect to inheritence +// of an owner. +// +// SE_GROUP_DEFAULTED - This boolean flag, when set, indicates that the +// SID in the Group field was provided by a defaulting mechanism +// rather than explicitly provided by the original provider of +// the security descriptor. This may affect the treatment of +// the SID with respect to inheritence of a primary group. +// +// SE_DACL_PRESENT - This boolean flag, when set, indicates that the +// security descriptor contains a discretionary ACL. If this +// flag is set and the Dacl field of the SECURITY_DESCRIPTOR is +// null, then a null ACL is explicitly being specified. +// +// SE_DACL_DEFAULTED - This boolean flag, when set, indicates that the +// ACL pointed to by the Dacl field was provided by a defaulting +// mechanism rather than explicitly provided by the original +// provider of the security descriptor. This may affect the +// treatment of the ACL with respect to inheritence of an ACL. +// This flag is ignored if the DaclPresent flag is not set. +// +// SE_SACL_PRESENT - This boolean flag, when set, indicates that the +// security descriptor contains a system ACL pointed to by the +// Sacl field. If this flag is set and the Sacl field of the +// SECURITY_DESCRIPTOR is null, then an empty (but present) +// ACL is being specified. +// +// SE_SACL_DEFAULTED - This boolean flag, when set, indicates that the +// ACL pointed to by the Sacl field was provided by a defaulting +// mechanism rather than explicitly provided by the original +// provider of the security descriptor. This may affect the +// treatment of the ACL with respect to inheritence of an ACL. +// This flag is ignored if the SaclPresent flag is not set. +// +// SE_SELF_RELATIVE - This boolean flag, when set, indicates that the +// security descriptor is in self-relative form. In this form, +// all fields of the security descriptor are contiguous in memory +// and all pointer fields are expressed as offsets from the +// beginning of the security descriptor. This form is useful +// for treating security descriptors as opaque data structures +// for transmission in communication protocol or for storage on +// secondary media. +// +// +// +// Pictorially the structure of a security descriptor is as follows: +// +// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +---------------------------------------------------------------+ +// | Control |Reserved1 (SBZ)| Revision | +// +---------------------------------------------------------------+ +// | Owner | +// +---------------------------------------------------------------+ +// | Group | +// +---------------------------------------------------------------+ +// | Sacl | +// +---------------------------------------------------------------+ +// | Dacl | +// +---------------------------------------------------------------+ +// +// In general, this data structure should be treated opaquely to ensure future +// compatibility. +// +// + +typedef struct _SECURITY_DESCRIPTOR { + BYTE Revision; + BYTE Sbz1; + SECURITY_DESCRIPTOR_CONTROL Control; + PSID Owner; + PSID Group; + PACL Sacl; + PACL Dacl; + } SECURITY_DESCRIPTOR, *PISECURITY_DESCRIPTOR; + + +// Where: +// +// Revision - Contains the revision level of the security +// descriptor. This allows this structure to be passed between +// systems or stored on disk even though it is expected to +// change in the future. +// +// Control - A set of flags which qualify the meaning of the +// security descriptor or individual fields of the security +// descriptor. +// +// Owner - is a pointer to an SID representing an object's owner. +// If this field is null, then no owner SID is present in the +// security descriptor. If the security descriptor is in +// self-relative form, then this field contains an offset to +// the SID, rather than a pointer. +// +// Group - is a pointer to an SID representing an object's primary +// group. If this field is null, then no primary group SID is +// present in the security descriptor. If the security descriptor +// is in self-relative form, then this field contains an offset to +// the SID, rather than a pointer. +// +// Sacl - is a pointer to a system ACL. This field value is only +// valid if the DaclPresent control flag is set. If the +// SaclPresent flag is set and this field is null, then a null +// ACL is specified. If the security descriptor is in +// self-relative form, then this field contains an offset to +// the ACL, rather than a pointer. +// +// Dacl - is a pointer to a discretionary ACL. This field value is +// only valid if the DaclPresent control flag is set. If the +// DaclPresent flag is set and this field is null, then a null +// ACL (unconditionally granting access) is specified. If the +// security descriptor is in self-relative form, then this field +// contains an offset to the ACL, rather than a pointer. +// + + + +//////////////////////////////////////////////////////////////////////// +// // +// Privilege Related Data Structures // +// // +//////////////////////////////////////////////////////////////////////// + + +// +// Privilege attributes +// + +#define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L) +#define SE_PRIVILEGE_ENABLED (0x00000002L) +#define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L) + + + + +// +// Privilege Set Control flags +// + +#define PRIVILEGE_SET_ALL_NECESSARY (1) + + +// +// Privilege Set - This is defined for a privilege set of one. +// If more than one privilege is needed, then this structure +// will need to be allocated with more space. +// +// Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET +// structure (defined in se.h) +// + +typedef struct _PRIVILEGE_SET { + DWORD PrivilegeCount; + DWORD Control; + LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY]; + } PRIVILEGE_SET, * PPRIVILEGE_SET; + + +//////////////////////////////////////////////////////////////////////// +// // +// NT Defined Privileges // +// // +//////////////////////////////////////////////////////////////////////// + +#define SE_CREATE_TOKEN_NAME L"SeCreateTokenPrivilege" +#define SE_ASSIGNPRIMARYTOKEN_NAME L"SeAssignPrimaryTokenPrivilege" +#define SE_LOCK_MEMORY_NAME L"SeLockMemoryPrivilege" +#define SE_INCREASE_QUOTA_NAME L"SeIncreaseQuotaPrivilege" +#define SE_UNSOLICITED_INPUT_NAME L"SeUnsolicitedInputPrivilege" +#define SE_TCB_NAME L"SeTcbPrivilege" +#define SE_SECURITY_NAME L"SeSecurityPrivilege" +#define SE_TAKE_OWNERSHIP_NAME L"SeTakeOwnershipPrivilege" +#define SE_LOAD_DRIVER_NAME L"SeLoadDriverPrivilege" +#define SE_SYSTEM_PROFILE_NAME L"SeSystemProfilePrivilege" +#define SE_SYSTEMTIME_NAME L"SeSystemtimePrivilege" +#define SE_PROF_SINGLE_PROCESS_NAME L"SeProfileSingleProcessPrivilege" +#define SE_INC_BASE_PRIORITY_NAME L"SeIncreaseBasePriorityPrivilege" +#define SE_CREATE_PAGEFILE_NAME L"SeCreatePagefilePrivilege" +#define SE_CREATE_PERMANENT_NAME L"SeCreatePermanentPrivilege" +#define SE_BACKUP_NAME L"SeBackupPrivilege" +#define SE_RESTORE_NAME L"SeRestorePrivilege" +#define SE_SHUTDOWN_NAME L"SeShutdownPrivilege" +#define SE_DEBUG_NAME L"SeDebugPrivilege" +#define SE_AUDIT_NAME L"SeAuditPrivilege" +#define SE_SYSTEM_ENVIRONMENT_NAME L"SeSystemEnvironmentPrivilege" +#define SE_CHANGE_NOTIFY_NAME L"SeChangeNotifyPrivilege" +#define SE_REMOTE_SHUTDOWN_NAME L"SeRemoteShutdownPrivilege" + + +//////////////////////////////////////////////////////////////////// +// // +// Security Quality Of Service // +// // +// // +//////////////////////////////////////////////////////////////////// + +// +// Impersonation Level +// +// Impersonation level is represented by a pair of bits in Windows. +// If a new impersonation level is added or lowest value is changed from +// 0 to something else, fix the Windows CreateFile call. +// + +typedef enum _SECURITY_IMPERSONATION_LEVEL { + SecurityAnonymous, + SecurityIdentification, + SecurityImpersonation, + SecurityDelegation + } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL; + +#define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation + +#define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation + + +// +// Security Tracking Mode +// + +#define SECURITY_DYNAMIC_TRACKING (TRUE) +#define SECURITY_STATIC_TRACKING (FALSE) + +typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, + * PSECURITY_CONTEXT_TRACKING_MODE; + + + +// +// Quality Of Service +// + +typedef struct _SECURITY_QUALITY_OF_SERVICE { + DWORD Length; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode; + BOOLEAN EffectiveOnly; + } SECURITY_QUALITY_OF_SERVICE, * PSECURITY_QUALITY_OF_SERVICE; + + +// +// Used to represent information related to a thread impersonation +// + +typedef struct _SE_IMPERSONATION_STATE { + PACCESS_TOKEN Token; + BOOLEAN CopyOnOpen; + BOOLEAN EffectiveOnly; + SECURITY_IMPERSONATION_LEVEL Level; +} SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE; + + +//////////////////////////////////////////////////////////////////// +// // +// Token Object Definitions // +// // +// // +//////////////////////////////////////////////////////////////////// + + +// +// Token Specific Access Rights. +// + +#define TOKEN_ASSIGN_PRIMARY (0x0001) +#define TOKEN_DUPLICATE (0x0002) +#define TOKEN_IMPERSONATE (0x0004) +#define TOKEN_QUERY (0x0008) +#define TOKEN_QUERY_SOURCE (0x0010) +#define TOKEN_ADJUST_PRIVILEGES (0x0020) +#define TOKEN_ADJUST_GROUPS (0x0040) +#define TOKEN_ADJUST_DEFAULT (0x0080) + +#define 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) + + +#define TOKEN_READ (STANDARD_RIGHTS_READ |\ + TOKEN_QUERY) + + +#define TOKEN_WRITE (STANDARD_RIGHTS_WRITE |\ + TOKEN_ADJUST_PRIVILEGES |\ + TOKEN_ADJUST_GROUPS |\ + TOKEN_ADJUST_DEFAULT) + +#define TOKEN_EXECUTE (STANDARD_RIGHTS_EXECUTE |\ + TOKEN_IMPERSONATE) + + +// +// Token Types +// + +typedef enum _TOKEN_TYPE { + TokenPrimary = 1, + TokenImpersonation + } TOKEN_TYPE; +typedef TOKEN_TYPE *PTOKEN_TYPE; + + +// +// Token Information Classes. +// + + +typedef enum _TOKEN_INFORMATION_CLASS { + TokenUser = 1, + TokenGroups, + TokenPrivileges, + TokenOwner, + TokenPrimaryGroup, + TokenDefaultDacl, + TokenSource, + TokenType, + TokenImpersonationLevel, + TokenStatistics +} TOKEN_INFORMATION_CLASS, *PTOKEN_INFORMATION_CLASS; + +// +// Token information class structures +// + +typedef struct _TOKEN_USER { + SID_AND_ATTRIBUTES User; +} TOKEN_USER, *PTOKEN_USER; + + +typedef struct _TOKEN_GROUPS { + DWORD GroupCount; + SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY]; +} TOKEN_GROUPS, *PTOKEN_GROUPS; + + +typedef struct _TOKEN_PRIVILEGES { + DWORD PrivilegeCount; + LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]; +} TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES; + + +typedef struct _TOKEN_OWNER { + PSID Owner; +} TOKEN_OWNER, *PTOKEN_OWNER; + + +typedef struct _TOKEN_PRIMARY_GROUP { + PSID PrimaryGroup; +} TOKEN_PRIMARY_GROUP, *PTOKEN_PRIMARY_GROUP; + + +typedef struct _TOKEN_DEFAULT_DACL { + PACL DefaultDacl; +} TOKEN_DEFAULT_DACL, *PTOKEN_DEFAULT_DACL; + + + +#define TOKEN_SOURCE_LENGTH 8 + +typedef struct _TOKEN_SOURCE { + CHAR SourceName[TOKEN_SOURCE_LENGTH]; + LUID SourceIdentifier; +} TOKEN_SOURCE, *PTOKEN_SOURCE; + + +typedef struct _TOKEN_STATISTICS { + LUID TokenId; + LUID AuthenticationId; + LARGE_INTEGER ExpirationTime; + TOKEN_TYPE TokenType; + SECURITY_IMPERSONATION_LEVEL ImpersonationLevel; + DWORD DynamicCharged; + DWORD DynamicAvailable; + DWORD GroupCount; + DWORD PrivilegeCount; + LUID ModifiedId; +} TOKEN_STATISTICS, *PTOKEN_STATISTICS; + + +typedef struct _TOKEN_CONTROL { + LUID TokenId; + LUID AuthenticationId; + LUID ModifiedId; + TOKEN_SOURCE TokenSource; + } TOKEN_CONTROL, *PTOKEN_CONTROL; typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION; @@ -659,11 +1699,13 @@ typedef DWORD SECURITY_INFORMATION, *PSE #define HEAP_SERIALIZE 0x00000001 typedef struct _RTL_CRITICAL_SECTION { - - PVOID CallingAddress; - PVOID CallersCaller; - PVOID Spare[5]; - +#if DEVL + WORD Type; + WORD Depth; + PVOID OwnerBackTrace[ 4 ]; + DWORD ContentionCount; + LIST_ENTRY ProcessLocksList; +#endif // DEVL // // The following three fields control entering and exiting the critical @@ -676,8 +1718,13 @@ typedef struct _RTL_CRITICAL_SECTION { HANDLE LockSemaphore; KSPIN_LOCK SpinLock; -} RTL_CRITICAL_SECTION; -typedef RTL_CRITICAL_SECTION *PRTL_CRITICAL_SECTION; +#if DEVL && defined(i386) + DWORD CreatorBackTraceIndex; +#else + DWORD Reserved; +#endif // DEVL && defined(i386) + +} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION; #define DLL_PROCESS_ATTACH 1 #define DLL_THREAD_ATTACH 2 #define DLL_THREAD_DETACH 3 @@ -686,22 +1733,399 @@ typedef RTL_CRITICAL_SECTION *PRTL_CRITI // // Defines for the READ flags for Eventlogging // -#define EVENTLOG_SEQUENTIAL_READ 0X0001 -#define EVENTLOG_SEEK_READ 0X0002 -#define EVENTLOG_FORWARDS_READ 0X0004 -#define EVENTLOG_BACKWARDS_READ 0X0008 +#define EVENTLOG_SEQUENTIAL_READ 0X0001 +#define EVENTLOG_SEEK_READ 0X0002 +#define EVENTLOG_FORWARDS_READ 0X0004 +#define EVENTLOG_BACKWARDS_READ 0X0008 // // The types of events that can be logged. // -#define EVENTLOG_ERROR_TYPE 0x0001 -#define EVENTLOG_WARNING_TYPE 0x0002 -#define EVENTLOG_INFORMATION_TYPE 0x0003 +#define EVENTLOG_SUCCESS 0X0000 +#define EVENTLOG_ERROR_TYPE 0x0001 +#define EVENTLOG_WARNING_TYPE 0x0002 +#define EVENTLOG_INFORMATION_TYPE 0x0004 +#define EVENTLOG_AUDIT_SUCCESS 0x0008 +#define EVENTLOG_AUDIT_FAILURE 0x0010 + +// +// Defines for the WRITE flags used by Auditing for paired events +// These are not implemented in Product 1 +// + +#define EVENTLOG_START_PAIRED_EVENT 0x0001 +#define EVENTLOG_END_PAIRED_EVENT 0x0002 +#define EVENTLOG_END_ALL_PAIRED_EVENTS 0x0004 +#define EVENTLOG_PAIRED_EVENT_ACTIVE 0x0008 +#define EVENTLOG_PAIRED_EVENT_INACTIVE 0x000C + +// +// Structure that defines the header of the Eventlog record. This is the +// fixed-sized portion before all the variable-length strings, binary +// data and pad bytes. +// +// TimeGenerated is the time it was generated at the client. +// TimeWritten is the time it was put into the log at the server end. +// + +typedef struct _EVENTLOGRECORD { + DWORD Length; // Length of full record + DWORD Reserved; // Used by the service + DWORD RecordNumber; // Absolute record number + DWORD TimeGenerated; // Seconds since 1-1-1970 + DWORD TimeWritten; // Seconds since 1-1-1970 + DWORD EventID; + WORD EventType; + WORD NumStrings; + WORD EventCategory; + WORD ReservedFlags; // For use with paired events (auditing) + DWORD ClosingRecordNumber; // For use with paired events (auditing) + DWORD StringOffset; // Offset from beginning of record + DWORD UserSidLength; + DWORD UserSidOffset; + DWORD DataLength; + DWORD DataOffset; // Offset from beginning of record + // + // Then follow: + // + // WCHAR SourceName[] + // WCHAR Computername[] + // SID UserSid + // WCHAR Strings[] + // BYTE Data[] + // CHAR Pad[] + // DWORD Length; + // +} EVENTLOGRECORD, *PEVENTLOGRECORD; #define DBG_CONTINUE ((DWORD )0x00010002L) #define DBG_TERMINATE_THREAD ((DWORD )0x40010003L) #define DBG_TERMINATE_PROCESS ((DWORD )0x40010004L) #define DBG_CONTROL_C ((DWORD )0x40010005L) #define DBG_EXCEPTION_NOT_HANDLED ((DWORD )0x80010001L) +// + +// +// Registry Specific Access Rights. +// + +#define KEY_QUERY_VALUE (0x0001) +#define KEY_SET_VALUE (0x0002) +#define KEY_CREATE_SUB_KEY (0x0004) +#define KEY_ENUMERATE_SUB_KEYS (0x0008) +#define KEY_NOTIFY (0x0010) +#define KEY_CREATE_LINK (0x0020) + +#define KEY_READ ((STANDARD_RIGHTS_READ |\ + KEY_QUERY_VALUE |\ + KEY_ENUMERATE_SUB_KEYS |\ + KEY_NOTIFY) \ + & \ + (~SYNCHRONIZE)) + + +#define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\ + KEY_SET_VALUE |\ + KEY_CREATE_SUB_KEY) \ + & \ + (~SYNCHRONIZE)) + +#define KEY_EXECUTE ((KEY_READ) \ + & \ + (~SYNCHRONIZE)) + +#define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\ + KEY_QUERY_VALUE |\ + KEY_SET_VALUE |\ + KEY_CREATE_SUB_KEY |\ + KEY_ENUMERATE_SUB_KEYS |\ + KEY_NOTIFY |\ + KEY_CREATE_LINK) \ + & \ + (~SYNCHRONIZE)) + + + +// +// Open/Create Options +// + +#define REG_OPTION_RESERVED (0x00000000L) // Parameter is reserved + +#define REG_OPTION_NON_VOLATILE (0x00000000L) // Key is preserved + // when system is rebooted + +#define REG_OPTION_VOLATILE (0x00000001L) // Key is not preserved + // when system is rebooted + +#define REG_OPTION_CREATE_LINK (0x00000002L) // Created key is a + // symbolic link + +// +// Key creation/open disposition +// + +#define REG_CREATED_NEW_KEY (0x00000001L) // New Registry Key created +#define REG_OPENED_EXISTING_KEY (0x00000002L) // Existing Key opened + +// +// Key restore flags +// + +#define REG_WHOLE_HIVE_VOLATILE (0x00000001L) // Restore whole hive volatile + +// +// Notify filter values +// +#define REG_NOTIFY_CHANGE_NAME (0x00000001L) // Create or delete (child) +#define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L) +#define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L) // time stamp +#define REG_NOTIFY_CHANGE_SECURITY (0x00000008L) + +#define REG_LEGAL_CHANGE_FILTER \ + (REG_NOTIFY_CHANGE_NAME |\ + REG_NOTIFY_CHANGE_ATTRIBUTES |\ + REG_NOTIFY_CHANGE_LAST_SET |\ + REG_NOTIFY_CHANGE_SECURITY) + +// +// + +// +// Predefined Value Types. +// + +#define REG_NONE ( 0 ) // No value type +#define REG_SZ ( 1 ) // Unicode nul terminated string +#define REG_EXPAND_SZ ( 2 ) // Unicode nul terminated string + // (with environment variable references) +#define REG_BINARY ( 3 ) // Free form binary +#define REG_DWORD ( 4 ) // 32-bit number +#define REG_DWORD_LITTLE_ENDIAN ( 4 ) // 32-bit number (same as REG_DWORD) +#define REG_DWORD_BIG_ENDIAN ( 5 ) // 32-bit number +#define REG_LINK ( 6 ) // Symbolic Link (unicode) +#define REG_MULTI_SZ ( 7 ) // Multiple Unicode strings +#define REG_RESOURCE_LIST ( 8 ) // Resource list in the resource map +#define REG_FULL_RESOURCE_DESCRIPTOR ( 9 ) // Resource list in the hardware description + + +// +// Service Types (Bit Mask) +// +#define SERVICE_KERNEL_DRIVER 0x00000001 +#define SERVICE_FILE_SYSTEM_DRIVER 0x00000002 +#define SERVICE_DRIVER (SERVICE_KERNEL_DRIVER | \ + SERVICE_FILE_SYSTEM_DRIVER) + +#define SERVICE_ADAPTER 0x00000004 + +#define SERVICE_WIN32_OWN_PROCESS 0x00000010 +#define SERVICE_WIN32_SHARE_PROCESS 0x00000020 +#define SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS | \ + SERVICE_WIN32_SHARE_PROCESS) + +#define SERVICE_TYPE_ALL (SERVICE_WIN32 | \ + SERVICE_ADAPTER | \ + SERVICE_DRIVER) + +// +// Start Type +// + +#define SERVICE_BOOT_START 0x00000000 +#define SERVICE_SYSTEM_START 0x00000001 +#define SERVICE_AUTO_START 0x00000002 +#define SERVICE_DEMAND_START 0x00000003 +#define SERVICE_DISABLED 0x00000004 + +// +// Error control type +// + +#define SERVICE_ERROR_NORMAL 0x00000001 +#define SERVICE_ERROR_SEVERE 0x00000002 +#define SERVICE_ERROR_CRITICAL 0x00000003 + +// +// +// Define the registry driver node enumerations +// + +typedef enum _CM_SERVICE_NODE_TYPE { + DriverType = SERVICE_KERNEL_DRIVER, + FileSystemType = SERVICE_FILE_SYSTEM_DRIVER, + Win32ServiceOwnProcess = SERVICE_WIN32_OWN_PROCESS, + Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS, + AdapterType = SERVICE_ADAPTER +} SERVICE_NODE_TYPE; + +typedef enum _CM_SERVICE_LOAD_TYPE { + BootLoad = SERVICE_BOOT_START, + SystemLoad = SERVICE_SYSTEM_START, + AutoLoad = SERVICE_AUTO_START, + DemandLoad = SERVICE_DEMAND_START, + DisableLoad = SERVICE_DISABLED +} SERVICE_LOAD_TYPE; + +typedef enum _CM_ERROR_CONTROL_TYPE { + NormalError = SERVICE_ERROR_NORMAL, + SevereError = SERVICE_ERROR_SEVERE, + CriticalError = SERVICE_ERROR_CRITICAL +} SERVICE_ERROR_TYPE; + +// + +// +// IOCTL_TAPE_ERASE definitions +// + +#define TAPE_ERASE_SHORT 0 +#define TAPE_ERASE_LONG 1 +#define TAPE_ERASE_SHORT_IMMED 2 +#define TAPE_ERASE_LONG_IMMED 3 + +typedef struct _TAPE_ERASE { + DWORD Partition; + DWORD Type; +} TAPE_ERASE, *PTAPE_ERASE; + + +// +// IOCTL_TAPE_PREPARE definitions +// + +#define TAPE_UNLOAD 0 +#define TAPE_UNLOAD_IMMED 1 +#define TAPE_TENSION 2 +#define TAPE_LOCK 3 +#define TAPE_UNLOCK 4 + +typedef struct _TAPE_PREPARE { + DWORD Operation; +} TAPE_PREPARE, *PTAPE_PREPARE; + +// +// IOCTL_TAPE_WRITE_MARKS definitions +// + +#define TAPE_SETMARKS 0 +#define TAPE_SHORT_FILEMARKS 1 +#define TAPE_LONG_FILEMARKS 2 +#define TAPE_SEQUENTIAL_FILEMARKS 3 + +typedef struct _TAPE_WRITE_MARKS { + DWORD Type; + DWORD Count; +} TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS; + +// +// IOCTL_TAPE_GET/SET_POSITION definitions +// + +#define TAPE_REWIND (TAPE_SEQUENTIAL_FILEMARKS+1) +#define TAPE_REWIND_IMMED (TAPE_SEQUENTIAL_FILEMARKS+2) +#define TAPE_END_OF_DATA (TAPE_SEQUENTIAL_FILEMARKS+3) +#define TAPE_ABSOLUTE_BLOCK (TAPE_SEQUENTIAL_FILEMARKS+4) +#define TAPE_RELATIVE_BLOCK (TAPE_SEQUENTIAL_FILEMARKS+5) +#define TAPE_BLOCKS (TAPE_SEQUENTIAL_FILEMARKS+6) + +typedef struct _TAPE_POSITION { + DWORD Method; + DWORD Partition; + LARGE_INTEGER Position; +} TAPE_POSITION, *PTAPE_POSITION; + +// +// IOCTL_TAPE_GET_MEDIA_PARAMS definitions +// + +typedef struct _TAPE_GET_MEDIA_PARAMETERS { + LARGE_INTEGER Capacity; + LARGE_INTEGER Remaining; + DWORD Type; + DWORD Density; + DWORD BlockSize; + DWORD Partitions; + BOOLEAN WriteProtected; +} TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS; + + +// +// IOCTL_TAPE_SET_MEDIA_PARAMS definitions +// + +typedef struct _TAPE_SET_MEDIA_PARAMETERS { + DWORD BlockSize; +} TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS; + + +// +// IOCTL_TAPE_GET_DRIVE_PARAMS definitions +// + +#define TAPE_DRIVE_SETMARKS 0x10000000 +#define TAPE_DRIVE_SHORT_FILEMARKS 0x20000000 +#define TAPE_DRIVE_LONG_FILEMARKS 0x40000000 + +#define TAPE_DRIVE_ECC 0x00000001 +#define TAPE_DRIVE_COMPRESSION 0x00000002 +#define TAPE_DRIVE_PADDING 0x00000004 + +typedef struct _TAPE_DRIVE_PARAMETERS { + DWORD Capabilities; + DWORD CurrentSettings; +} TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS; + +// +// IOCTL_TAPE_SET_DRIVE_PARAMS definitions +// + +#define TAPE_DRIVE_SETMARKS 0x10000000 +#define TAPE_DRIVE_SHORT_FILEMARKS 0x20000000 +#define TAPE_DRIVE_LONG_FILEMARKS 0x40000000 + +#define TAPE_DRIVE_SHORT_ERASE 0x00000010 +#define TAPE_DRIVE_LONG_ERASE 0x00000020 + +#define TAPE_DRIVE_ECC 0x00000001 +#define TAPE_DRIVE_COMPRESSION 0x00000002 +#define TAPE_DRIVE_PADDING 0x00000004 + +typedef struct _TAPE_SET_DRIVE_PARAMETERS { + DWORD CurrentSettings; +} TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS; + +// +// IOCTL_TAPE_GET_STATUS definitions +// + +#define TAPE_STATUS_DEVICE_READY 0x00000000 +#define TAPE_STATUS_NO_MEDIA 0x00000001 +#define TAPE_STATUS_WRITE_PROTECTED 0x00000002 +#define TAPE_STATUS_MEDIA_CHANGED 0x00000004 +#define TAPE_STATUS_RESET_DETECTED 0x00000008 +#define TAPE_STATUS_BEGINNING_OF_MEDIA 0x00000010 +#define TAPE_STATUS_END_OF_MEDIA 0x00000020 +#define TAPE_STATUS_DEVICE_NOT_READY 0x00000800 + +typedef struct _TAPE_STATUS { + DWORD Status; +} TAPE_STATUS, *PTAPE_STATUS; + +// +// IOCTL_TAPE_CREATE_PARTITION definitions +// + +#define TAPE_PARTITION_FIXED 0 +#define TAPE_PARTITION_SELECT 1 +#define TAPE_PARTITION_INITIATOR 2 + +typedef struct _TAPE_CREATE_PARTITION_PARAMETERS { + DWORD Type; + DWORD Count; + DWORD Size[1]; // variable length array, 0 terminates +} TAPE_CREATE_PARTITION_PARAMETERS, *PTAPE_CREATE_PARTITION_PARAMETERS; + + +#endif // _WINNT_ -#endif