2 * Win32 definitions for Windows NT
4 * Copyright 1996 Alexandre Julliard
14 #define ANYSIZE_ARRAY 1
16 #define FIELD_OFFSET(type, field) \
17 ((LONG)(INT32)&(((type *)0)->field))
19 #define CONTAINING_RECORD(address, type, field) \
20 ((type *)((PCHAR)(address) - (PCHAR)(&((type *)0)->field)))
25 typedef BOOLEAN
*PBOOLEAN
;
27 typedef struct _LIST_ENTRY32
{
28 struct _LIST_ENTRY32
*Flink
;
29 struct _LIST_ENTRY32
*Blink
;
30 } LIST_ENTRY32
, *PLIST_ENTRY32
;
32 typedef struct _SINGLE_LIST_ENTRY32
{
33 struct _SINGLE_LIST_ENTRY32
*Next
;
34 } SINGLE_LIST_ENTRY32
, *PSINGLE_LIST_ENTRY32
;
38 #define HEAP_NO_SERIALIZE 0x00000001
39 #define HEAP_GROWABLE 0x00000002
40 #define HEAP_GENERATE_EXCEPTIONS 0x00000004
41 #define HEAP_ZERO_MEMORY 0x00000008
42 #define HEAP_REALLOC_IN_PLACE_ONLY 0x00000010
43 #define HEAP_TAIL_CHECKING_ENABLED 0x00000020
44 #define HEAP_FREE_CHECKING_ENABLED 0x00000040
45 #define HEAP_DISABLE_COALESCE_ON_FREE 0x00000080
46 #define HEAP_CREATE_ALIGN_16 0x00010000
47 #define HEAP_CREATE_ENABLE_TRACING 0x00020000
48 #define HEAP_WINE_SEGPTR 0x01000000 /* Not a Win32 flag */
49 #define HEAP_WINE_CODESEG 0x02000000 /* Not a Win32 flag */
50 #define HEAP_WINE_CODE16SEG 0x04000000 /* Not a Win32 flag */
52 /* Processor feature flags. */
53 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
54 #define PF_FLOATING_POINT_EMULATED 1
55 #define PF_COMPARE_EXCHANGE_DOUBLE 2
56 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
57 #define PF_PPC_MOVEMEM_64BIT_OK 4
58 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
61 /* The Win32 register context */
63 #define CONTEXT_i386 0x00010000
64 #define CONTEXT_i486 CONTEXT_i386
65 #define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
66 #define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
67 #define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
68 #define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
69 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
70 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
72 #define SIZE_OF_80387_REGISTERS 80
83 BYTE RegisterArea
[SIZE_OF_80387_REGISTERS
];
91 /* These are selected by CONTEXT_DEBUG_REGISTERS */
99 /* These are selected by CONTEXT_FLOATING_POINT */
100 FLOATING_SAVE_AREA FloatSave
;
102 /* These are selected by CONTEXT_SEGMENTS */
108 /* These are selected by CONTEXT_INTEGER */
116 /* These are selected by CONTEXT_CONTROL */
123 } CONTEXT
, *PCONTEXT
;
125 typedef HANDLE32
*PHANDLE
;
129 /* Macros for easier access to context registers */
131 #define EAX_reg(context) ((context)->Eax)
132 #define EBX_reg(context) ((context)->Ebx)
133 #define ECX_reg(context) ((context)->Ecx)
134 #define EDX_reg(context) ((context)->Edx)
135 #define ESI_reg(context) ((context)->Esi)
136 #define EDI_reg(context) ((context)->Edi)
137 #define EBP_reg(context) ((context)->Ebp)
139 #define CS_reg(context) ((context)->SegCs)
140 #define DS_reg(context) ((context)->SegDs)
141 #define ES_reg(context) ((context)->SegEs)
142 #define FS_reg(context) ((context)->SegFs)
143 #define GS_reg(context) ((context)->SegGs)
144 #define SS_reg(context) ((context)->SegSs)
146 #define EFL_reg(context) ((context)->EFlags)
147 #define EIP_reg(context) ((context)->Eip)
148 #define ESP_reg(context) ((context)->Esp)
150 #define AX_reg(context) (*(WORD*)&EAX_reg(context))
151 #define BX_reg(context) (*(WORD*)&EBX_reg(context))
152 #define CX_reg(context) (*(WORD*)&ECX_reg(context))
153 #define DX_reg(context) (*(WORD*)&EDX_reg(context))
154 #define SI_reg(context) (*(WORD*)&ESI_reg(context))
155 #define DI_reg(context) (*(WORD*)&EDI_reg(context))
156 #define BP_reg(context) (*(WORD*)&EBP_reg(context))
158 #define AL_reg(context) (*(BYTE*)&EAX_reg(context))
159 #define AH_reg(context) (*((BYTE*)&EAX_reg(context)+1))
160 #define BL_reg(context) (*(BYTE*)&EBX_reg(context))
161 #define BH_reg(context) (*((BYTE*)&EBX_reg(context)+1))
162 #define CL_reg(context) (*(BYTE*)&ECX_reg(context))
163 #define CH_reg(context) (*((BYTE*)&ECX_reg(context)+1))
164 #define DL_reg(context) (*(BYTE*)&EDX_reg(context))
165 #define DH_reg(context) (*((BYTE*)&EDX_reg(context)+1))
167 #define IP_reg(context) (*(WORD*)&EIP_reg(context))
168 #define SP_reg(context) (*(WORD*)&ESP_reg(context))
170 #define FL_reg(context) (*(WORD*)&EFL_reg(context))
172 #define SET_CFLAG(context) (EFL_reg(context) |= 0x0001)
173 #define RESET_CFLAG(context) (EFL_reg(context) &= 0xfffffffe)
175 #define ISV86(context) (EFL_reg(context) & 0x00020000)
176 #define V86BASE(context) ((context)->Dr7) /* ugly */
178 #endif /* __WINE__ */
184 #define STATUS_WAIT_0 0x00000000
185 #define STATUS_ABANDONED_WAIT_0 0x00000080
186 #define STATUS_USER_APC 0x000000C0
187 #define STATUS_TIMEOUT 0x00000102
188 #define STATUS_PENDING 0x00000103
189 #define STATUS_DATATYPE_MISALIGNMENT 0x80000002
190 #define STATUS_BREAKPOINT 0x80000003
191 #define STATUS_SINGLE_STEP 0x80000004
192 #define STATUS_ACCESS_VIOLATION 0xC0000005
193 #define STATUS_IN_PAGE_ERROR 0xC0000006
194 #define STATUS_NO_MEMORY 0xC0000017
195 #define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
196 #define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
197 #define STATUS_INVALID_DISPOSITION 0xC0000026
198 #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
199 #define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
200 #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
201 #define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
202 #define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
203 #define STATUS_FLOAT_OVERFLOW 0xC0000091
204 #define STATUS_FLOAT_STACK_CHECK 0xC0000092
205 #define STATUS_FLOAT_UNDERFLOW 0xC0000093
206 #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
207 #define STATUS_INTEGER_OVERFLOW 0xC0000095
208 #define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
209 #define STATUS_STACK_OVERFLOW 0xC00000FD
210 #define STATUS_CONTROL_C_EXIT 0xC000013A
212 #define EXCEPTION_ACCESS_VIOLATION STATUS_ACCESS_VIOLATION
213 #define EXCEPTION_DATATYPE_MISALIGNMENT STATUS_DATATYPE_MISALIGNMENT
214 #define EXCEPTION_BREAKPOINT STATUS_BREAKPOINT
215 #define EXCEPTION_SINGLE_STEP STATUS_SINGLE_STEP
216 #define EXCEPTION_ARRAY_BOUNDS_EXCEEDED STATUS_ARRAY_BOUNDS_EXCEEDED
217 #define EXCEPTION_FLT_DENORMAL_OPERAND STATUS_FLOAT_DENORMAL_OPERAND
218 #define EXCEPTION_FLT_DIVIDE_BY_ZERO STATUS_FLOAT_DIVIDE_BY_ZERO
219 #define EXCEPTION_FLT_INEXACT_RESULT STATUS_FLOAT_INEXACT_RESULT
220 #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION
221 #define EXCEPTION_FLT_OVERFLOW STATUS_FLOAT_OVERFLOW
222 #define EXCEPTION_FLT_STACK_CHECK STATUS_FLOAT_STACK_CHECK
223 #define EXCEPTION_FLT_UNDERFLOW STATUS_FLOAT_UNDERFLOW
224 #define EXCEPTION_INT_DIVIDE_BY_ZERO STATUS_INTEGER_DIVIDE_BY_ZERO
225 #define EXCEPTION_INT_OVERFLOW STATUS_INTEGER_OVERFLOW
226 #define EXCEPTION_PRIV_INSTRUCTION STATUS_PRIVILEGED_INSTRUCTION
227 #define EXCEPTION_IN_PAGE_ERROR STATUS_IN_PAGE_ERROR
229 #define MAXIMUM_WAIT_OBJECTS 64
230 #define MAXIMUM_SUSPEND_COUNT 127
234 * Return values from the actual exception handlers
237 #define ExceptionContinueExecution 0
238 #define ExceptionContinueSearch 1
239 #define ExceptionNestedException 2
240 #define ExceptionCollidedUnwind 3
243 * Return values from filters in except() and from UnhandledExceptionFilter
246 #define EXCEPTION_EXECUTE_HANDLER 1
247 #define EXCEPTION_CONTINUE_SEARCH 0
248 #define EXCEPTION_CONTINUE_EXECUTION -1
251 * From OS/2 2.0 exception handling
252 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
255 #define EH_NONCONTINUABLE 0x01
256 #define EH_UNWINDING 0x02
257 #define EH_EXIT_UNWIND 0x04
258 #define EH_STACK_INVALID 0x08
259 #define EH_NESTED_CALL 0x10
261 #define EXCEPTION_CONTINUABLE 0
262 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
265 * The exception record used by Win32 to give additional information
266 * about exception to exception handlers.
269 #define EXCEPTION_MAXIMUM_PARAMETERS 15
271 typedef struct __EXCEPTION_RECORD
274 DWORD ExceptionFlags
;
275 struct __EXCEPTION_RECORD
*ExceptionRecord
;
277 LPVOID ExceptionAddress
;
278 DWORD NumberParameters
;
279 DWORD ExceptionInformation
[EXCEPTION_MAXIMUM_PARAMETERS
];
280 } EXCEPTION_RECORD
, *PEXCEPTION_RECORD
;
283 * The exception pointers structure passed to exception filters
284 * in except() and the UnhandledExceptionFilter().
287 typedef struct _EXCEPTION_POINTERS
289 PEXCEPTION_RECORD ExceptionRecord
;
290 PCONTEXT ContextRecord
;
291 } EXCEPTION_POINTERS
, *PEXCEPTION_POINTERS
;
294 * function pointer to a exception filter
297 typedef LONG (CALLBACK
*PTOP_LEVEL_EXCEPTION_FILTER
)(PEXCEPTION_POINTERS ExceptionInfo
);
298 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER
;
300 DWORD WINAPI
UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers
);
301 LPTOP_LEVEL_EXCEPTION_FILTER
302 WINAPI
SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter
);
305 * Here follows typedefs for security and tokens.
309 * First a constant for the following typdefs.
312 #define ANYSIZE_ARRAY 1
315 * TOKEN_INFORMATION_CLASS
318 typedef enum _TOKEN_INFORMATION_CLASS
{
327 TokenImpersonationLevel
,
329 } TOKEN_INFORMATION_CLASS
;
335 typedef struct _SID_AND_ATTRIBUTES
{
338 } SID_AND_ATTRIBUTES
;
344 typedef struct _TOKEN_USER
{
345 SID_AND_ATTRIBUTES User
;
352 typedef struct _TOKEN_GROUPS
{
354 SID_AND_ATTRIBUTES Groups
[ANYSIZE_ARRAY
];
358 * LUID_AND_ATTRIBUTES
361 typedef struct _LUID_AND_ATTRIBUTES
{
364 } LUID_AND_ATTRIBUTES
;
370 typedef struct _TOKEN_PRIVILEGES
{
371 DWORD PrivilegeCount
;
372 LUID_AND_ATTRIBUTES Privileges
[ANYSIZE_ARRAY
];
379 typedef struct _TOKEN_OWNER
{
384 * TOKEN_PRIMARY_GROUP
387 typedef struct _TOKEN_PRIMARY_GROUP
{
389 } TOKEN_PRIMARY_GROUP
;
393 * ACL (and PACL LPACL?).
397 are defined in ntddl.h.
398 typedef struct _ACL {
404 } ACL, *PACL; PACL <=> LPACL? */
410 typedef struct _TOKEN_DEFAULT_DACL
{
412 } TOKEN_DEFAULT_DACL
;
418 typedef struct _TOKEN_SOURCE
{
420 LUID SourceIdentifier
;
427 typedef enum tagTOKEN_TYPE
{
433 * SECURITY_IMPERSONATION_LEVEL
436 typedef enum _SECURITY_IMPERSONATION_LEVEL
{
438 SecurityIdentification
,
439 SecurityImpersonation
,
441 } SECURITY_IMPERSONATION_LEVEL
;
448 typedef struct _TOKEN_STATISTICS
{
450 LUID AuthenticationId
;
451 LARGE_INTEGER ExpirationTime
;
452 TOKEN_TYPE TokenType
;
453 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
;
454 DWORD DynamicCharged
;
455 DWORD DynamicAvailable
;
457 DWORD PrivilegeCount
;
462 /* I moved the Language IDs to winnls.h (David Lee Lambert) */
467 #define DELETE 0x00010000
468 #define READ_CONTROL 0x00020000
469 #define WRITE_DAC 0x00040000
470 #define WRITE_OWNER 0x00080000
471 #define SYNCHRONIZE 0x00100000
472 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
474 #define STANDARD_RIGHTS_READ READ_CONTROL
475 #define STANDARD_RIGHTS_WRITE READ_CONTROL
476 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
478 #define STANDARD_RIGHTS_ALL 0x001f0000
480 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
482 #define GENERIC_READ 0x80000000
483 #define GENERIC_WRITE 0x40000000
484 #define GENERIC_EXECUTE 0x20000000
485 #define GENERIC_ALL 0x10000000
487 #define EVENT_MODIFY_STATE 0x0002
488 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
490 #define SEMAPHORE_MODIFY_STATE 0x0002
491 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
493 #define MUTEX_MODIFY_STATE 0x0001
494 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
496 #define PROCESS_TERMINATE 0x0001
497 #define PROCESS_CREATE_THREAD 0x0002
498 #define PROCESS_VM_OPERATION 0x0008
499 #define PROCESS_VM_READ 0x0010
500 #define PROCESS_VM_WRITE 0x0020
501 #define PROCESS_DUP_HANDLE 0x0040
502 #define PROCESS_CREATE_PROCESS 0x0080
503 #define PROCESS_SET_QUOTA 0x0100
504 #define PROCESS_SET_INFORMATION 0x0200
505 #define PROCESS_QUERY_INFORMATION 0x0400
506 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
508 #define THREAD_TERMINATE 0x0001
509 #define THREAD_SUSPEND_RESUME 0x0002
510 #define THREAD_GET_CONTEXT 0x0008
511 #define THREAD_SET_CONTEXT 0x0010
512 #define THREAD_SET_INFORMATION 0x0020
513 #define THREAD_QUERY_INFORMATION 0x0040
514 #define THREAD_SET_THREAD_TOKEN 0x0080
515 #define THREAD_IMPERSONATE 0x0100
516 #define THREAD_DIRECT_IMPERSONATION 0x0200
517 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
519 #define FILE_READ_DATA 0x0001 /* file & pipe */
520 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
521 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
522 #define FILE_ADD_FILE 0x0002 /* directory */
523 #define FILE_APPEND_DATA 0x0004 /* file */
524 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
525 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
526 #define FILE_READ_EA 0x0008 /* file & directory */
527 #define FILE_READ_PROPERTIES FILE_READ_EA
528 #define FILE_WRITE_EA 0x0010 /* file & directory */
529 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
530 #define FILE_EXECUTE 0x0020 /* file */
531 #define FILE_TRAVERSE 0x0020 /* directory */
532 #define FILE_DELETE_CHILD 0x0040 /* directory */
533 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
534 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
535 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
537 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
538 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
540 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
541 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
542 FILE_APPEND_DATA | SYNCHRONIZE)
543 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
544 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
547 /* Registry security values */
548 #define OWNER_SECURITY_INFORMATION 0x00000001
549 #define GROUP_SECURITY_INFORMATION 0x00000002
550 #define DACL_SECURITY_INFORMATION 0x00000004
551 #define SACL_SECURITY_INFORMATION 0x00000008
553 #endif /* __WINE_WINNT_H */