2 * Win32 definitions for Windows NT
4 * Copyright 1996 Alexandre Julliard
15 /* Argument 1 passed to the DllEntryProc. */
16 #define DLL_PROCESS_DETACH 0 /* detach process (unload library) */
17 #define DLL_PROCESS_ATTACH 1 /* attach process (load library) */
18 #define DLL_THREAD_ATTACH 2 /* attach new thread */
19 #define DLL_THREAD_DETACH 3 /* detach thread */
22 /* u.x.wProcessorArchitecture (NT) */
23 #define PROCESSOR_ARCHITECTURE_INTEL 0
24 #define PROCESSOR_ARCHITECTURE_MIPS 1
25 #define PROCESSOR_ARCHITECTURE_ALPHA 2
26 #define PROCESSOR_ARCHITECTURE_PPC 3
27 #define PROCESSOR_ARCHITECTURE_SHX 4
28 #define PROCESSOR_ARCHITECTURE_ARM 5
29 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
32 #define PROCESSOR_INTEL_386 386
33 #define PROCESSOR_INTEL_486 486
34 #define PROCESSOR_INTEL_PENTIUM 586
35 #define PROCESSOR_INTEL_860 860
36 #define PROCESSOR_MIPS_R2000 2000
37 #define PROCESSOR_MIPS_R3000 3000
38 #define PROCESSOR_MIPS_R4000 4000
39 #define PROCESSOR_ALPHA_21064 21064
40 #define PROCESSOR_PPC_601 601
41 #define PROCESSOR_PPC_603 603
42 #define PROCESSOR_PPC_604 604
43 #define PROCESSOR_PPC_620 620
44 #define PROCESSOR_HITACHI_SH3 10003
45 #define PROCESSOR_HITACHI_SH3E 10004
46 #define PROCESSOR_HITACHI_SH4 10005
47 #define PROCESSOR_MOTOROLA_821 821
48 #define PROCESSOR_SHx_SH3 103
49 #define PROCESSOR_SHx_SH4 104
50 #define PROCESSOR_STRONGARM 2577
51 #define PROCESSOR_ARM720 1824 /* 0x720 */
52 #define PROCESSOR_ARM820 2080 /* 0x820 */
53 #define PROCESSOR_ARM920 2336 /* 0x920 */
54 #define PROCESSOR_ARM_7TDMI 70001
56 #define ANYSIZE_ARRAY 1
60 #define MINSHORT 0x8000
61 #define MAXSHORT 0x7fff
62 #define MINLONG 0x80000000
63 #define MAXLONG 0x7fffffff
65 #define MAXWORD 0xffff
66 #define MAXDWORD 0xffffffff
68 #define FIELD_OFFSET(type, field) \
69 ((LONG)(INT)&(((type *)0)->field))
71 #define CONTAINING_RECORD(address, type, field) \
72 ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
76 /* TCHAR data types definitions for Winelib. */
77 /* These types are _not_ defined for the emulator, because they */
78 /* depend on the UNICODE macro that only exists in user's code. */
82 typedef LPWSTR LPTSTR
;
83 typedef LPCWSTR LPCTSTR
;
84 #define __TEXT(string) L##string /*probably wrong */
87 typedef LPCSTR LPCTSTR
;
88 #define __TEXT(string) string
91 #define TEXT(quote) __TEXT(quote)
94 typedef BOOLEAN
*PBOOLEAN
;
96 typedef struct _LIST_ENTRY
{
97 struct _LIST_ENTRY
*Flink
;
98 struct _LIST_ENTRY
*Blink
;
99 } LIST_ENTRY
, *PLIST_ENTRY
;
101 typedef struct _SINGLE_LIST_ENTRY
{
102 struct _SINGLE_LIST_ENTRY
*Next
;
103 } SINGLE_LIST_ENTRY
, *PSINGLE_LIST_ENTRY
;
107 #define HEAP_NO_SERIALIZE 0x00000001
108 #define HEAP_GROWABLE 0x00000002
109 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
110 #define HEAP_ZERO_MEMORY 0x00000008
111 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
112 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
113 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
114 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
115 #define HEAP_CREATE_ALIGN_16 0x00010000
116 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
117 #define HEAP_WINE_SEGPTR 0x01000000 /* Not a Win32 flag */
118 #define HEAP_WINE_CODESEG 0x02000000 /* Not a Win32 flag */
119 #define HEAP_WINE_CODE16SEG 0x04000000 /* Not a Win32 flag */
121 /* Processor feature flags. */
122 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
123 #define PF_FLOATING_POINT_EMULATED 1
124 #define PF_COMPARE_EXCHANGE_DOUBLE 2
125 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
126 #define PF_PPC_MOVEMEM_64BIT_OK 4
127 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
130 /* The Win32 register context */
132 /* CONTEXT is the CPU-dependent context; it should be used */
133 /* wherever a platform-specific context is needed (e.g. exception */
134 /* handling, Win32 register functions). */
136 /* CONTEXT86 is the i386-specific context; it should be used */
137 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
138 /* Win16 register functions), so that this code can be compiled */
139 /* on all platforms. */
141 #define SIZE_OF_80387_REGISTERS 80
143 typedef struct _FLOATING_SAVE_AREA
152 BYTE RegisterArea
[SIZE_OF_80387_REGISTERS
];
154 } FLOATING_SAVE_AREA
, *PFLOATING_SAVE_AREA
;
156 typedef struct _CONTEXT86
160 /* These are selected by CONTEXT_DEBUG_REGISTERS */
168 /* These are selected by CONTEXT_FLOATING_POINT */
169 FLOATING_SAVE_AREA FloatSave
;
171 /* These are selected by CONTEXT_SEGMENTS */
177 /* These are selected by CONTEXT_INTEGER */
185 /* These are selected by CONTEXT_CONTROL */
194 #define CONTEXT_X86 0x00010000
195 #define CONTEXT_i386 CONTEXT_X86
196 #define CONTEXT_i486 CONTEXT_X86
198 #define CONTEXT86_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
199 #define CONTEXT86_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
200 #define CONTEXT86_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
201 #define CONTEXT86_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
202 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
203 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
205 /* i386 context definitions */
208 #define CONTEXT_CONTROL CONTEXT86_CONTROL
209 #define CONTEXT_INTEGER CONTEXT86_INTEGER
210 #define CONTEXT_SEGMENTS CONTEXT86_SEGMENTS
211 #define CONTEXT_FLOATING_POINT CONTEXT86_FLOATING_POINT
212 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
213 #define CONTEXT_FULL CONTEXT86_FULL
215 typedef CONTEXT86 CONTEXT
;
217 #endif /* __i386__ */
219 /* Alpha context definitions */
222 #define CONTEXT_ALPHA 0x00020000
224 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
225 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
226 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
227 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
229 typedef struct _CONTEXT
231 /* selected by CONTEXT_FLOATING_POINT */
265 /* selected by CONTEXT_INTEGER */
299 /* selected by CONTEXT_FLOATING_POINT */
303 /* selected by CONTEXT_CONTROL */
310 #define _QUAD_PSR_OFFSET HighSoftFpcr
311 #define _QUAD_FLAGS_OFFSET HighFir
315 /* Mips context definitions */
318 #define CONTEXT_R4000 0x00010000
320 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
321 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
322 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
324 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
326 typedef struct _CONTEXT
329 /* These are selected by CONTEXT_FLOATING_POINT */
363 /* These are selected by CONTEXT_INTEGER */
399 /* These are selected by CONTEXT_FLOATING_POINT */
402 /* These are selected by CONTEXT_CONTROL */
412 /* PowerPC context definitions */
415 #define CONTEXT_CONTROL 0x0001
416 #define CONTEXT_FLOATING_POINT 0x0002
417 #define CONTEXT_INTEGER 0x0004
418 #define CONTEXT_DEBUG_REGISTERS 0x0008
419 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
423 /* These are selected by CONTEXT_FLOATING_POINT */
458 /* These are selected by CONTEXT_INTEGER */
495 /* These are selected by CONTEXT_CONTROL */
504 /* These are selected by CONTEXT_DEBUG_REGISTERS */
515 typedef struct _STACK_FRAME_HEADER
532 } STACK_FRAME_HEADER
,*PSTACK_FRAME_HEADER
;
541 * There is no official CONTEXT structure defined for the SPARC
542 * architecture, so I just made one up.
544 * This structure is valid only for 32-bit SPARC architectures,
545 * not for 64-bit SPARC.
547 * Note that this structure contains only the 'top-level' registers;
548 * the rest of the register window chain is not visible.
550 * The layout follows the Solaris 'prgregset_t' structure.
554 #define CONTEXT_SPARC 0x10000000
556 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
557 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
558 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
560 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
562 typedef struct _CONTEXT
566 /* These are selected by CONTEXT_INTEGER */
600 /* These are selected by CONTEXT_CONTROL */
608 /* FIXME: floating point registers missing */
614 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
615 #error You need to define a CONTEXT for your CPU
618 typedef CONTEXT
*PCONTEXT
;
619 typedef HANDLE
*PHANDLE
;
623 /* Macros for easier access to i386 context registers */
625 #define EAX_reg(context) ((context)->Eax)
626 #define EBX_reg(context) ((context)->Ebx)
627 #define ECX_reg(context) ((context)->Ecx)
628 #define EDX_reg(context) ((context)->Edx)
629 #define ESI_reg(context) ((context)->Esi)
630 #define EDI_reg(context) ((context)->Edi)
631 #define EBP_reg(context) ((context)->Ebp)
633 #define CS_reg(context) ((context)->SegCs)
634 #define DS_reg(context) ((context)->SegDs)
635 #define ES_reg(context) ((context)->SegEs)
636 #define FS_reg(context) ((context)->SegFs)
637 #define GS_reg(context) ((context)->SegGs)
638 #define SS_reg(context) ((context)->SegSs)
640 #define EFL_reg(context) ((context)->EFlags)
641 #define EIP_reg(context) ((context)->Eip)
642 #define ESP_reg(context) ((context)->Esp)
644 #define AX_reg(context) (*(WORD*)&EAX_reg(context))
645 #define BX_reg(context) (*(WORD*)&EBX_reg(context))
646 #define CX_reg(context) (*(WORD*)&ECX_reg(context))
647 #define DX_reg(context) (*(WORD*)&EDX_reg(context))
648 #define SI_reg(context) (*(WORD*)&ESI_reg(context))
649 #define DI_reg(context) (*(WORD*)&EDI_reg(context))
650 #define BP_reg(context) (*(WORD*)&EBP_reg(context))
652 #define AL_reg(context) (*(BYTE*)&EAX_reg(context))
653 #define AH_reg(context) (*((BYTE*)&EAX_reg(context)+1))
654 #define BL_reg(context) (*(BYTE*)&EBX_reg(context))
655 #define BH_reg(context) (*((BYTE*)&EBX_reg(context)+1))
656 #define CL_reg(context) (*(BYTE*)&ECX_reg(context))
657 #define CH_reg(context) (*((BYTE*)&ECX_reg(context)+1))
658 #define DL_reg(context) (*(BYTE*)&EDX_reg(context))
659 #define DH_reg(context) (*((BYTE*)&EDX_reg(context)+1))
661 #define SET_CFLAG(context) (EFL_reg(context) |= 0x0001)
662 #define RESET_CFLAG(context) (EFL_reg(context) &= ~0x0001)
663 #define SET_ZFLAG(context) (EFL_reg(context) |= 0x0040)
664 #define RESET_ZFLAG(context) (EFL_reg(context) &= ~0x0040)
666 #define ISV86(context) (EFL_reg(context) & 0x00020000)
667 #define V86BASE(context) ((context)->Dr7) /* ugly */
670 /* Macros to retrieve the current context */
673 #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \
674 __asm__(".align 4\n\t" \
675 ".globl " #name "\n\t" \
676 ".type " #name ",@function\n\t" \
678 "call CALL32_Regs\n\t" \
679 ".long " #fn "\n\t" \
680 ".byte " #args ", " #args "\n\t");
682 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
683 _DEFINE_REGS_ENTRYPOINT( name, fn, 0 )
684 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
685 _DEFINE_REGS_ENTRYPOINT( name, fn, 4 )
686 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
687 _DEFINE_REGS_ENTRYPOINT( name, fn, 8 )
688 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
689 _DEFINE_REGS_ENTRYPOINT( name, fn, 12 )
690 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
691 _DEFINE_REGS_ENTRYPOINT( name, fn, 16 )
693 #endif /* __i386__ */
696 /* FIXME: use getcontext() to retrieve full context */
697 #define _GET_CONTEXT \
699 do { memset(&context, 0, sizeof(CONTEXT)); \
700 context.ContextFlags = CONTEXT_CONTROL; \
701 context.pc = (DWORD)__builtin_return_address(0); \
704 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
705 void WINAPI name ( void ) \
706 { _GET_CONTEXT; fn( &context ); }
707 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
708 void WINAPI name ( t1 a1 ) \
709 { _GET_CONTEXT; fn( a1, &context ); }
710 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
711 void WINAPI name ( t1 a1, t2 a2 ) \
712 { _GET_CONTEXT; fn( a1, a2, &context ); }
713 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
714 void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
715 { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
716 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
717 void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
718 { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
720 #endif /* __sparc__ */
722 #ifndef DEFINE_REGS_ENTRYPOINT_0
723 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
727 # define GET_IP(context) ((LPVOID)(context)->Eip)
730 # define GET_IP(context) ((LPVOID)(context)->pc)
733 #if !defined(GET_IP) && !defined(RC_INVOKED)
734 # error You must define GET_IP for this CPU
737 #endif /* __WINE__ */
743 #define STATUS_SUCCESS 0x00000000
744 #define STATUS_WAIT_0 0x00000000
745 #define STATUS_ABANDONED_WAIT_0 0x00000080
746 #define STATUS_USER_APC 0x000000C0
747 #define STATUS_TIMEOUT 0x00000102
748 #define STATUS_PENDING 0x00000103
749 #define STATUS_GUARD_PAGE_VIOLATION 0x80000001
750 #define STATUS_DATATYPE_MISALIGNMENT 0x80000002
751 #define STATUS_BREAKPOINT 0x80000003
752 #define STATUS_SINGLE_STEP 0x80000004
753 #define STATUS_BUFFER_OVERFLOW 0x80000005
754 #define STATUS_UNSUCCESSFUL 0xC0000001
755 #define STATUS_ACCESS_VIOLATION 0xC0000005
756 #define STATUS_IN_PAGE_ERROR 0xC0000006
757 #define STATUS_INVALID_PARAMETER 0xC000000D
758 #define STATUS_NO_MEMORY 0xC0000017
759 #define STATUS_CONFLICTING_ADDRESSES 0xC0000018
760 #define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
761 #define STATUS_BUFFER_TOO_SMALL 0xC0000023
762 #define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
763 #define STATUS_INVALID_DISPOSITION 0xC0000026
764 #define STATUS_UNWIND 0xC0000027
765 #define STATUS_BAD_STACK 0xC0000028
766 #define STATUS_INVALID_UNWIND_TARGET 0xC0000029
767 #define STATUS_UNKNOWN_REVISION 0xC0000058
768 #define STATUS_INVALID_SECURITY_DESCR 0xC0000079
769 #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
770 #define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
771 #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
772 #define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
773 #define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
774 #define STATUS_FLOAT_OVERFLOW 0xC0000091
775 #define STATUS_FLOAT_STACK_CHECK 0xC0000092
776 #define STATUS_FLOAT_UNDERFLOW 0xC0000093
777 #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
778 #define STATUS_INTEGER_OVERFLOW 0xC0000095
779 #define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
780 #define STATUS_INVALID_PARAMETER_2 0xC00000F0
781 #define STATUS_STACK_OVERFLOW 0xC00000FD
782 #define STATUS_CONTROL_C_EXIT 0xC000013A
784 #define MAXIMUM_WAIT_OBJECTS 64
785 #define MAXIMUM_SUSPEND_COUNT 127
789 * Return values from the actual exception handlers
792 #define ExceptionContinueExecution 0
793 #define ExceptionContinueSearch 1
794 #define ExceptionNestedException 2
795 #define ExceptionCollidedUnwind 3
798 * Return values from filters in except() and from UnhandledExceptionFilter
801 #define EXCEPTION_EXECUTE_HANDLER 1
802 #define EXCEPTION_CONTINUE_SEARCH 0
803 #define EXCEPTION_CONTINUE_EXECUTION -1
806 * From OS/2 2.0 exception handling
807 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
810 #define EH_NONCONTINUABLE 0x01
811 #define EH_UNWINDING 0x02
812 #define EH_EXIT_UNWIND 0x04
813 #define EH_STACK_INVALID 0x08
814 #define EH_NESTED_CALL 0x10
816 #define EXCEPTION_CONTINUABLE 0
817 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
820 * The exception record used by Win32 to give additional information
821 * about exception to exception handlers.
824 #define EXCEPTION_MAXIMUM_PARAMETERS 15
826 typedef struct __EXCEPTION_RECORD
829 DWORD ExceptionFlags
;
830 struct __EXCEPTION_RECORD
*ExceptionRecord
;
832 LPVOID ExceptionAddress
;
833 DWORD NumberParameters
;
834 DWORD ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
835 } EXCEPTION_RECORD
, *PEXCEPTION_RECORD
;
838 * The exception pointers structure passed to exception filters
839 * in except() and the UnhandledExceptionFilter().
842 typedef struct _EXCEPTION_POINTERS
844 PEXCEPTION_RECORD ExceptionRecord
;
845 PCONTEXT ContextRecord
;
846 } EXCEPTION_POINTERS
, *PEXCEPTION_POINTERS
;
850 * The exception frame, used for registering exception handlers
851 * Win32 cares only about this, but compilers generally emit
852 * larger exception frames for their own use.
855 struct __EXCEPTION_FRAME
;
857 typedef DWORD (*PEXCEPTION_HANDLER
)(PEXCEPTION_RECORD
,struct __EXCEPTION_FRAME
*,
858 PCONTEXT
,struct __EXCEPTION_FRAME
**);
860 typedef struct __EXCEPTION_FRAME
862 struct __EXCEPTION_FRAME
*Prev
;
863 PEXCEPTION_HANDLER Handler
;
864 } EXCEPTION_FRAME
, *PEXCEPTION_FRAME
;
869 * function pointer to a exception filter
872 typedef LONG (CALLBACK
*PTOP_LEVEL_EXCEPTION_FILTER
)(PEXCEPTION_POINTERS ExceptionInfo
);
873 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER
;
875 DWORD WINAPI
UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers
);
876 LPTOP_LEVEL_EXCEPTION_FILTER
877 WINAPI
SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter
);
879 /* status values for ContinueDebugEvent */
880 #define DBG_CONTINUE 0x00010002
881 #define DBG_TERMINATE_THREAD 0x40010003
882 #define DBG_TERMINATE_PROCESS 0x40010004
883 #define DBG_CONTROL_C 0x40010005
884 #define DBG_CONTROL_BREAK 0x40010008
885 #define DBG_EXCEPTION_NOT_HANDLED 0x80010001
891 #if defined(__i386__)
892 static inline struct _TEB
* WINE_UNUSED
__get_teb(void)
895 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb
));
898 #elif defined(HAVE__LWP_CREATE)
899 extern void *_lwp_getprivate(void);
900 static inline struct _TEB
* WINE_UNUSED
__get_teb(void)
902 return (struct _TEB
*)_lwp_getprivate();
905 #error NtCurrentTeb() not defined for this architecture!
908 #define NtCurrentTeb() __get_teb()
911 extern struct _TEB
* WINAPI
NtCurrentTeb(void);
915 * Here follows typedefs for security and tokens.
919 * First a constant for the following typdefs.
922 #define ANYSIZE_ARRAY 1
924 /* FIXME: Orphan. What does it point to? */
925 typedef PVOID PACCESS_TOKEN
;
928 * TOKEN_INFORMATION_CLASS
931 typedef enum _TOKEN_INFORMATION_CLASS
{
940 TokenImpersonationLevel
,
942 } TOKEN_INFORMATION_CLASS
;
944 #ifndef _SECURITY_DEFINED
945 #define _SECURITY_DEFINED
947 #include "pshpack1.h"
949 typedef DWORD ACCESS_MASK
, *PACCESS_MASK
;
951 typedef struct _GENERIC_MAPPING
{
952 ACCESS_MASK GenericRead
;
953 ACCESS_MASK GenericWrite
;
954 ACCESS_MASK GenericExecute
;
955 ACCESS_MASK GenericAll
;
956 } GENERIC_MAPPING
, *PGENERIC_MAPPING
;
958 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
959 #define SID_IDENTIFIER_AUTHORITY_DEFINED
962 } SID_IDENTIFIER_AUTHORITY
,*PSID_IDENTIFIER_AUTHORITY
,*LPSID_IDENTIFIER_AUTHORITY
;
963 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
967 typedef struct _SID
{
969 BYTE SubAuthorityCount
;
970 SID_IDENTIFIER_AUTHORITY IdentifierAuthority
;
971 DWORD SubAuthority
[1];
973 #endif /* !defined(SID_DEFINED) */
975 #define SID_REVISION (1) /* Current revision */
976 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
977 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
984 typedef struct _ACL
{
992 /* SECURITY_DESCRIPTOR */
993 #define SECURITY_DESCRIPTOR_REVISION 1
994 #define SECURITY_DESCRIPTOR_REVISION1 1
997 #define SE_OWNER_DEFAULTED 0x0001
998 #define SE_GROUP_DEFAULTED 0x0002
999 #define SE_DACL_PRESENT 0x0004
1000 #define SE_DACL_DEFAULTED 0x0008
1001 #define SE_SACL_PRESENT 0x0010
1002 #define SE_SACL_DEFAULTED 0x0020
1003 #define SE_SELF_RELATIVE 0x8000
1005 typedef DWORD SECURITY_INFORMATION
, *PSECURITY_INFORMATION
;
1006 typedef WORD SECURITY_DESCRIPTOR_CONTROL
, *PSECURITY_DESCRIPTOR_CONTROL
;
1008 /* The security descriptor structure */
1012 SECURITY_DESCRIPTOR_CONTROL Control
;
1017 } SECURITY_DESCRIPTOR
, *PSECURITY_DESCRIPTOR
;
1019 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
1021 #include "poppack.h"
1023 #endif /* _SECURITY_DEFINED */
1025 #include "pshpack1.h"
1028 * SID_AND_ATTRIBUTES
1031 typedef struct _SID_AND_ATTRIBUTES
{
1034 } SID_AND_ATTRIBUTES
;
1040 typedef struct _TOKEN_USER
{
1041 SID_AND_ATTRIBUTES User
;
1048 typedef struct _TOKEN_GROUPS
{
1050 SID_AND_ATTRIBUTES Groups
[ANYSIZE_ARRAY
];
1054 * LUID_AND_ATTRIBUTES
1057 typedef union _LARGE_INTEGER
{
1063 } LARGE_INTEGER
, *LPLARGE_INTEGER
, *PLARGE_INTEGER
;
1065 typedef union _ULARGE_INTEGER
{
1071 } ULARGE_INTEGER
, *LPULARGE_INTEGER
, *PULARGE_INTEGER
;
1074 * Locally Unique Identifier
1077 typedef LARGE_INTEGER LUID
,*PLUID
;
1079 typedef struct _LUID_AND_ATTRIBUTES
{
1082 } LUID_AND_ATTRIBUTES
;
1088 typedef struct _PRIVILEGE_SET
{
1089 DWORD PrivilegeCount
;
1091 LUID_AND_ATTRIBUTES Privilege
[ANYSIZE_ARRAY
];
1092 } PRIVILEGE_SET
, *PPRIVILEGE_SET
;
1098 typedef struct _TOKEN_PRIVILEGES
{
1099 DWORD PrivilegeCount
;
1100 LUID_AND_ATTRIBUTES Privileges
[ANYSIZE_ARRAY
];
1101 } TOKEN_PRIVILEGES
, *PTOKEN_PRIVILEGES
;
1107 typedef struct _TOKEN_OWNER
{
1112 * TOKEN_PRIMARY_GROUP
1115 typedef struct _TOKEN_PRIMARY_GROUP
{
1117 } TOKEN_PRIMARY_GROUP
;
1121 * TOKEN_DEFAULT_DACL
1124 typedef struct _TOKEN_DEFAULT_DACL
{
1126 } TOKEN_DEFAULT_DACL
;
1132 typedef struct _TOKEN_SOURCE
{
1134 LUID SourceIdentifier
;
1141 typedef enum tagTOKEN_TYPE
{
1147 * SECURITY_IMPERSONATION_LEVEL
1150 typedef enum _SECURITY_IMPERSONATION_LEVEL
{
1152 SecurityIdentification
,
1153 SecurityImpersonation
,
1155 } SECURITY_IMPERSONATION_LEVEL
, *PSECURITY_IMPERSONATION_LEVEL
;
1158 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE
,
1159 * PSECURITY_CONTEXT_TRACKING_MODE
;
1161 * Quality of Service
1164 typedef struct _SECURITY_QUALITY_OF_SERVICE
{
1166 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
1167 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
;
1169 } SECURITY_QUALITY_OF_SERVICE
, *PSECURITY_QUALITY_OF_SERVICE
;
1175 typedef struct _TOKEN_STATISTICS
{
1177 LUID AuthenticationId
;
1178 LARGE_INTEGER ExpirationTime
;
1179 TOKEN_TYPE TokenType
;
1180 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
1181 DWORD DynamicCharged
;
1182 DWORD DynamicAvailable
;
1184 DWORD PrivilegeCount
;
1192 #define ACL_REVISION 2
1194 #define ACL_REVISION1 1
1195 #define ACL_REVISION2 2
1197 /* ACEs, directly starting after an ACL */
1198 typedef struct _ACE_HEADER
{
1202 } ACE_HEADER
,*PACE_HEADER
;
1205 #define ACCESS_ALLOWED_ACE_TYPE 0
1206 #define ACCESS_DENIED_ACE_TYPE 1
1207 #define SYSTEM_AUDIT_ACE_TYPE 2
1208 #define SYSTEM_ALARM_ACE_TYPE 3
1210 /* inherit AceFlags */
1211 #define OBJECT_INHERIT_ACE 0x01
1212 #define CONTAINER_INHERIT_ACE 0x02
1213 #define NO_PROPAGATE_INHERIT_ACE 0x04
1214 #define INHERIT_ONLY_ACE 0x08
1215 #define VALID_INHERIT_FLAGS 0x0F
1217 /* AceFlags mask for what events we (should) audit */
1218 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
1219 #define FAILED_ACCESS_ACE_FLAG 0x80
1221 /* different ACEs depending on AceType
1222 * SidStart marks the begin of a SID
1223 * so the thing finally looks like this:
1228 typedef struct _ACCESS_ALLOWED_ACE
{
1232 } ACCESS_ALLOWED_ACE
,*PACCESS_ALLOWED_ACE
;
1234 typedef struct _ACCESS_DENIED_ACE
{
1238 } ACCESS_DENIED_ACE
,*PACCESS_DENIED_ACE
;
1240 typedef struct _SYSTEM_AUDIT_ACE
{
1244 } SYSTEM_AUDIT_ACE
,*PSYSTEM_AUDIT_ACE
;
1246 typedef struct _SYSTEM_ALARM_ACE
{
1250 } SYSTEM_ALARM_ACE
,*PSYSTEM_ALARM_ACE
;
1252 typedef enum tagSID_NAME_USE
{
1257 SidTypeWellKnownGroup
,
1258 SidTypeDeletedAccount
,
1261 } SID_NAME_USE
,*PSID_NAME_USE
;
1265 #define DELETE 0x00010000
1266 #define READ_CONTROL 0x00020000
1267 #define WRITE_DAC 0x00040000
1268 #define WRITE_OWNER 0x00080000
1269 #define SYNCHRONIZE 0x00100000
1270 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
1272 #define STANDARD_RIGHTS_READ READ_CONTROL
1273 #define STANDARD_RIGHTS_WRITE READ_CONTROL
1274 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
1276 #define STANDARD_RIGHTS_ALL 0x001f0000
1278 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
1280 #define GENERIC_READ 0x80000000
1281 #define GENERIC_WRITE 0x40000000
1282 #define GENERIC_EXECUTE 0x20000000
1283 #define GENERIC_ALL 0x10000000
1285 #define MAXIMUM_ALLOWED 0x02000000
1286 #define ACCESS_SYSTEM_SECURITY 0x01000000
1288 #define EVENT_MODIFY_STATE 0x0002
1289 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
1291 #define SEMAPHORE_MODIFY_STATE 0x0002
1292 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
1294 #define MUTEX_MODIFY_STATE 0x0001
1295 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
1297 #define PROCESS_TERMINATE 0x0001
1298 #define PROCESS_CREATE_THREAD 0x0002
1299 #define PROCESS_VM_OPERATION 0x0008
1300 #define PROCESS_VM_READ 0x0010
1301 #define PROCESS_VM_WRITE 0x0020
1302 #define PROCESS_DUP_HANDLE 0x0040
1303 #define PROCESS_CREATE_PROCESS 0x0080
1304 #define PROCESS_SET_QUOTA 0x0100
1305 #define PROCESS_SET_INFORMATION 0x0200
1306 #define PROCESS_QUERY_INFORMATION 0x0400
1307 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
1309 #define THREAD_TERMINATE 0x0001
1310 #define THREAD_SUSPEND_RESUME 0x0002
1311 #define THREAD_GET_CONTEXT 0x0008
1312 #define THREAD_SET_CONTEXT 0x0010
1313 #define THREAD_SET_INFORMATION 0x0020
1314 #define THREAD_QUERY_INFORMATION 0x0040
1315 #define THREAD_SET_THREAD_TOKEN 0x0080
1316 #define THREAD_IMPERSONATE 0x0100
1317 #define THREAD_DIRECT_IMPERSONATION 0x0200
1318 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
1320 #define THREAD_BASE_PRIORITY_LOWRT 15
1321 #define THREAD_BASE_PRIORITY_MAX 2
1322 #define THREAD_BASE_PRIORITY_MIN -2
1323 #define THREAD_BASE_PRIORITY_IDLE -15
1325 #define FILE_READ_DATA 0x0001 /* file & pipe */
1326 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
1327 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
1328 #define FILE_ADD_FILE 0x0002 /* directory */
1329 #define FILE_APPEND_DATA 0x0004 /* file */
1330 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
1331 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
1332 #define FILE_READ_EA 0x0008 /* file & directory */
1333 #define FILE_READ_PROPERTIES FILE_READ_EA
1334 #define FILE_WRITE_EA 0x0010 /* file & directory */
1335 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
1336 #define FILE_EXECUTE 0x0020 /* file */
1337 #define FILE_TRAVERSE 0x0020 /* directory */
1338 #define FILE_DELETE_CHILD 0x0040 /* directory */
1339 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
1340 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
1341 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
1343 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
1344 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
1346 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
1347 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
1348 FILE_APPEND_DATA | SYNCHRONIZE)
1349 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
1350 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
1353 /* File attribute flags
1355 #define FILE_SHARE_READ 0x00000001L
1356 #define FILE_SHARE_WRITE 0x00000002L
1357 #define FILE_SHARE_DELETE 0x00000004L
1358 #define FILE_ATTRIBUTE_READONLY 0x00000001L
1359 #define FILE_ATTRIBUTE_HIDDEN 0x00000002L
1360 #define FILE_ATTRIBUTE_SYSTEM 0x00000004L
1361 #define FILE_ATTRIBUTE_LABEL 0x00000008L /* Not in Windows API */
1362 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010L
1363 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020L
1364 #define FILE_ATTRIBUTE_NORMAL 0x00000080L
1365 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100L
1366 #define FILE_ATTRIBUTE_ATOMIC_WRITE 0x00000200L
1367 #define FILE_ATTRIBUTE_XACTION_WRITE 0x00000400L
1368 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800L
1369 #define FILE_ATTRIBUTE_OFFLINE 0x00001000L
1371 /* File alignments (NT) */
1372 #define FILE_BYTE_ALIGNMENT 0x00000000
1373 #define FILE_WORD_ALIGNMENT 0x00000001
1374 #define FILE_LONG_ALIGNMENT 0x00000003
1375 #define FILE_QUAD_ALIGNMENT 0x00000007
1376 #define FILE_OCTA_ALIGNMENT 0x0000000f
1377 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
1378 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
1379 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
1380 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
1381 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
1383 /* Registry security values */
1384 #define OWNER_SECURITY_INFORMATION 0x00000001
1385 #define GROUP_SECURITY_INFORMATION 0x00000002
1386 #define DACL_SECURITY_INFORMATION 0x00000004
1387 #define SACL_SECURITY_INFORMATION 0x00000008
1389 #include "poppack.h"
1391 #endif /* __WINE_WINNT_H */