Release 20000227.
[wine.git] / include / winnt.h
blob0812239e2a508f79be67de359067ebf176878f58
1 /*
2 * Win32 definitions for Windows NT
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_WINNT_H
8 #define __WINE_WINNT_H
10 #include "windef.h"
12 #include "pshpack1.h"
13 /* Defines */
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
31 /* dwProcessorType */
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
58 #define MINCHAR 0x80
59 #define MAXCHAR 0x7f
60 #define MINSHORT 0x8000
61 #define MAXSHORT 0x7fff
62 #define MINLONG 0x80000000
63 #define MAXLONG 0x7fffffff
64 #define MAXBYTE 0xff
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)))
74 /* Types */
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. */
80 #ifndef __WINE__
81 # ifdef UNICODE
82 typedef LPWSTR LPTSTR;
83 typedef LPCWSTR LPCTSTR;
84 #define __TEXT(string) L##string /*probably wrong */
85 # else /* UNICODE */
86 typedef LPSTR LPTSTR;
87 typedef LPCSTR LPCTSTR;
88 #define __TEXT(string) string
89 # endif /* UNICODE */
90 #endif /* __WINE__ */
91 #define TEXT(quote) __TEXT(quote)
93 typedef BYTE BOOLEAN;
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;
105 /* Heap flags */
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 */
120 #define HEAP_WINE_SHARED 0x08000000 /* Not a Win32 flag */
122 /* Processor feature flags. */
123 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
124 #define PF_FLOATING_POINT_EMULATED 1
125 #define PF_COMPARE_EXCHANGE_DOUBLE 2
126 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
127 #define PF_PPC_MOVEMEM_64BIT_OK 4
128 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
131 /* The Win32 register context */
133 /* CONTEXT is the CPU-dependent context; it should be used */
134 /* wherever a platform-specific context is needed (e.g. exception */
135 /* handling, Win32 register functions). */
137 /* CONTEXT86 is the i386-specific context; it should be used */
138 /* wherever only a 386 context makes sense (e.g. DOS interrupts, */
139 /* Win16 register functions), so that this code can be compiled */
140 /* on all platforms. */
142 #define SIZE_OF_80387_REGISTERS 80
144 typedef struct _FLOATING_SAVE_AREA
146 DWORD ControlWord;
147 DWORD StatusWord;
148 DWORD TagWord;
149 DWORD ErrorOffset;
150 DWORD ErrorSelector;
151 DWORD DataOffset;
152 DWORD DataSelector;
153 BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
154 DWORD Cr0NpxState;
155 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
157 typedef struct _CONTEXT86
159 DWORD ContextFlags;
161 /* These are selected by CONTEXT_DEBUG_REGISTERS */
162 DWORD Dr0;
163 DWORD Dr1;
164 DWORD Dr2;
165 DWORD Dr3;
166 DWORD Dr6;
167 DWORD Dr7;
169 /* These are selected by CONTEXT_FLOATING_POINT */
170 FLOATING_SAVE_AREA FloatSave;
172 /* These are selected by CONTEXT_SEGMENTS */
173 DWORD SegGs;
174 DWORD SegFs;
175 DWORD SegEs;
176 DWORD SegDs;
178 /* These are selected by CONTEXT_INTEGER */
179 DWORD Edi;
180 DWORD Esi;
181 DWORD Ebx;
182 DWORD Edx;
183 DWORD Ecx;
184 DWORD Eax;
186 /* These are selected by CONTEXT_CONTROL */
187 DWORD Ebp;
188 DWORD Eip;
189 DWORD SegCs;
190 DWORD EFlags;
191 DWORD Esp;
192 DWORD SegSs;
193 } CONTEXT86;
195 #define CONTEXT_X86 0x00010000
196 #define CONTEXT_i386 CONTEXT_X86
197 #define CONTEXT_i486 CONTEXT_X86
199 #define CONTEXT86_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
200 #define CONTEXT86_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
201 #define CONTEXT86_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
202 #define CONTEXT86_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
203 #define CONTEXT86_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
204 #define CONTEXT86_FULL (CONTEXT86_CONTROL | CONTEXT86_INTEGER | CONTEXT86_SEGMENTS)
206 /* i386 context definitions */
207 #ifdef __i386__
209 #define CONTEXT_CONTROL CONTEXT86_CONTROL
210 #define CONTEXT_INTEGER CONTEXT86_INTEGER
211 #define CONTEXT_SEGMENTS CONTEXT86_SEGMENTS
212 #define CONTEXT_FLOATING_POINT CONTEXT86_FLOATING_POINT
213 #define CONTEXT_DEBUG_REGISTERS CONTEXT86_DEBUG_REGISTERS
214 #define CONTEXT_FULL CONTEXT86_FULL
216 typedef CONTEXT86 CONTEXT;
218 #endif /* __i386__ */
220 /* Alpha context definitions */
221 #ifdef _ALPHA_
223 #define CONTEXT_ALPHA 0x00020000
225 #define CONTEXT_CONTROL (CONTEXT_ALPHA | 0x00000001L)
226 #define CONTEXT_FLOATING_POINT (CONTEXT_ALPHA | 0x00000002L)
227 #define CONTEXT_INTEGER (CONTEXT_ALPHA | 0x00000004L)
228 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
230 typedef struct _CONTEXT
232 /* selected by CONTEXT_FLOATING_POINT */
233 ULONGLONG FltF0;
234 ULONGLONG FltF1;
235 ULONGLONG FltF2;
236 ULONGLONG FltF3;
237 ULONGLONG FltF4;
238 ULONGLONG FltF5;
239 ULONGLONG FltF6;
240 ULONGLONG FltF7;
241 ULONGLONG FltF8;
242 ULONGLONG FltF9;
243 ULONGLONG FltF10;
244 ULONGLONG FltF11;
245 ULONGLONG FltF12;
246 ULONGLONG FltF13;
247 ULONGLONG FltF14;
248 ULONGLONG FltF15;
249 ULONGLONG FltF16;
250 ULONGLONG FltF17;
251 ULONGLONG FltF18;
252 ULONGLONG FltF19;
253 ULONGLONG FltF20;
254 ULONGLONG FltF21;
255 ULONGLONG FltF22;
256 ULONGLONG FltF23;
257 ULONGLONG FltF24;
258 ULONGLONG FltF25;
259 ULONGLONG FltF26;
260 ULONGLONG FltF27;
261 ULONGLONG FltF28;
262 ULONGLONG FltF29;
263 ULONGLONG FltF30;
264 ULONGLONG FltF31;
266 /* selected by CONTEXT_INTEGER */
267 ULONGLONG IntV0;
268 ULONGLONG IntT0;
269 ULONGLONG IntT1;
270 ULONGLONG IntT2;
271 ULONGLONG IntT3;
272 ULONGLONG IntT4;
273 ULONGLONG IntT5;
274 ULONGLONG IntT6;
275 ULONGLONG IntT7;
276 ULONGLONG IntS0;
277 ULONGLONG IntS1;
278 ULONGLONG IntS2;
279 ULONGLONG IntS3;
280 ULONGLONG IntS4;
281 ULONGLONG IntS5;
282 ULONGLONG IntFp;
283 ULONGLONG IntA0;
284 ULONGLONG IntA1;
285 ULONGLONG IntA2;
286 ULONGLONG IntA3;
287 ULONGLONG IntA4;
288 ULONGLONG IntA5;
289 ULONGLONG IntT8;
290 ULONGLONG IntT9;
291 ULONGLONG IntT10;
292 ULONGLONG IntT11;
293 ULONGLONG IntRa;
294 ULONGLONG IntT12;
295 ULONGLONG IntAt;
296 ULONGLONG IntGp;
297 ULONGLONG IntSp;
298 ULONGLONG IntZero;
300 /* selected by CONTEXT_FLOATING_POINT */
301 ULONGLONG Fpcr;
302 ULONGLONG SoftFpcr;
304 /* selected by CONTEXT_CONTROL */
305 ULONGLONG Fir;
306 DWORD Psr;
307 DWORD ContextFlags;
308 DWORD Fill[4];
309 } CONTEXT;
311 #define _QUAD_PSR_OFFSET HighSoftFpcr
312 #define _QUAD_FLAGS_OFFSET HighFir
314 #endif /* _ALPHA_ */
316 /* Mips context definitions */
317 #ifdef _MIPS_
319 #define CONTEXT_R4000 0x00010000
321 #define CONTEXT_CONTROL (CONTEXT_R4000 | 0x00000001)
322 #define CONTEXT_FLOATING_POINT (CONTEXT_R4000 | 0x00000002)
323 #define CONTEXT_INTEGER (CONTEXT_R4000 | 0x00000004)
325 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
327 typedef struct _CONTEXT
329 DWORD Argument[4];
330 /* These are selected by CONTEXT_FLOATING_POINT */
331 DWORD FltF0;
332 DWORD FltF1;
333 DWORD FltF2;
334 DWORD FltF3;
335 DWORD FltF4;
336 DWORD FltF5;
337 DWORD FltF6;
338 DWORD FltF7;
339 DWORD FltF8;
340 DWORD FltF9;
341 DWORD FltF10;
342 DWORD FltF11;
343 DWORD FltF12;
344 DWORD FltF13;
345 DWORD FltF14;
346 DWORD FltF15;
347 DWORD FltF16;
348 DWORD FltF17;
349 DWORD FltF18;
350 DWORD FltF19;
351 DWORD FltF20;
352 DWORD FltF21;
353 DWORD FltF22;
354 DWORD FltF23;
355 DWORD FltF24;
356 DWORD FltF25;
357 DWORD FltF26;
358 DWORD FltF27;
359 DWORD FltF28;
360 DWORD FltF29;
361 DWORD FltF30;
362 DWORD FltF31;
364 /* These are selected by CONTEXT_INTEGER */
365 DWORD IntZero;
366 DWORD IntAt;
367 DWORD IntV0;
368 DWORD IntV1;
369 DWORD IntA0;
370 DWORD IntA1;
371 DWORD IntA2;
372 DWORD IntA3;
373 DWORD IntT0;
374 DWORD IntT1;
375 DWORD IntT2;
376 DWORD IntT3;
377 DWORD IntT4;
378 DWORD IntT5;
379 DWORD IntT6;
380 DWORD IntT7;
381 DWORD IntS0;
382 DWORD IntS1;
383 DWORD IntS2;
384 DWORD IntS3;
385 DWORD IntS4;
386 DWORD IntS5;
387 DWORD IntS6;
388 DWORD IntS7;
389 DWORD IntT8;
390 DWORD IntT9;
391 DWORD IntK0;
392 DWORD IntK1;
393 DWORD IntGp;
394 DWORD IntSp;
395 DWORD IntS8;
396 DWORD IntRa;
397 DWORD IntLo;
398 DWORD IntHi;
400 /* These are selected by CONTEXT_FLOATING_POINT */
401 DWORD Fsr;
403 /* These are selected by CONTEXT_CONTROL */
404 DWORD Fir;
405 DWORD Psr;
407 DWORD ContextFlags;
408 DWORD Fill[2];
409 } CONTEXT;
411 #endif /* _MIPS_ */
413 /* PowerPC context definitions */
414 #ifdef __PPC__
416 #define CONTEXT_CONTROL 0x0001
417 #define CONTEXT_FLOATING_POINT 0x0002
418 #define CONTEXT_INTEGER 0x0004
419 #define CONTEXT_DEBUG_REGISTERS 0x0008
420 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
422 typedef struct
424 /* These are selected by CONTEXT_FLOATING_POINT */
425 double Fpr0;
426 double Fpr1;
427 double Fpr2;
428 double Fpr3;
429 double Fpr4;
430 double Fpr5;
431 double Fpr6;
432 double Fpr7;
433 double Fpr8;
434 double Fpr9;
435 double Fpr10;
436 double Fpr11;
437 double Fpr12;
438 double Fpr13;
439 double Fpr14;
440 double Fpr15;
441 double Fpr16;
442 double Fpr17;
443 double Fpr18;
444 double Fpr19;
445 double Fpr20;
446 double Fpr21;
447 double Fpr22;
448 double Fpr23;
449 double Fpr24;
450 double Fpr25;
451 double Fpr26;
452 double Fpr27;
453 double Fpr28;
454 double Fpr29;
455 double Fpr30;
456 double Fpr31;
457 double Fpscr;
459 /* These are selected by CONTEXT_INTEGER */
460 DWORD Gpr0;
461 DWORD Gpr1;
462 DWORD Gpr2;
463 DWORD Gpr3;
464 DWORD Gpr4;
465 DWORD Gpr5;
466 DWORD Gpr6;
467 DWORD Gpr7;
468 DWORD Gpr8;
469 DWORD Gpr9;
470 DWORD Gpr10;
471 DWORD Gpr11;
472 DWORD Gpr12;
473 DWORD Gpr13;
474 DWORD Gpr14;
475 DWORD Gpr15;
476 DWORD Gpr16;
477 DWORD Gpr17;
478 DWORD Gpr18;
479 DWORD Gpr19;
480 DWORD Gpr20;
481 DWORD Gpr21;
482 DWORD Gpr22;
483 DWORD Gpr23;
484 DWORD Gpr24;
485 DWORD Gpr25;
486 DWORD Gpr26;
487 DWORD Gpr27;
488 DWORD Gpr28;
489 DWORD Gpr29;
490 DWORD Gpr30;
491 DWORD Gpr31;
493 DWORD Cr;
494 DWORD Xer;
496 /* These are selected by CONTEXT_CONTROL */
497 DWORD Msr;
498 DWORD Iar;
499 DWORD Lr;
500 DWORD Ctr;
502 DWORD ContextFlags;
503 DWORD Fill[3];
505 /* These are selected by CONTEXT_DEBUG_REGISTERS */
506 DWORD Dr0;
507 DWORD Dr1;
508 DWORD Dr2;
509 DWORD Dr3;
510 DWORD Dr4;
511 DWORD Dr5;
512 DWORD Dr6;
513 DWORD Dr7;
514 } CONTEXT;
516 typedef struct _STACK_FRAME_HEADER
518 DWORD BackChain;
519 DWORD GlueSaved1;
520 DWORD GlueSaved2;
521 DWORD Reserved1;
522 DWORD Spare1;
523 DWORD Spare2;
525 DWORD Parameter0;
526 DWORD Parameter1;
527 DWORD Parameter2;
528 DWORD Parameter3;
529 DWORD Parameter4;
530 DWORD Parameter5;
531 DWORD Parameter6;
532 DWORD Parameter7;
533 } STACK_FRAME_HEADER,*PSTACK_FRAME_HEADER;
535 #endif /* __PPC__ */
537 #ifdef __sparc__
540 * FIXME:
542 * There is no official CONTEXT structure defined for the SPARC
543 * architecture, so I just made one up.
545 * This structure is valid only for 32-bit SPARC architectures,
546 * not for 64-bit SPARC.
548 * Note that this structure contains only the 'top-level' registers;
549 * the rest of the register window chain is not visible.
551 * The layout follows the Solaris 'prgregset_t' structure.
555 #define CONTEXT_SPARC 0x10000000
557 #define CONTEXT_CONTROL (CONTEXT_SPARC | 0x00000001)
558 #define CONTEXT_FLOATING_POINT (CONTEXT_SPARC | 0x00000002)
559 #define CONTEXT_INTEGER (CONTEXT_SPARC | 0x00000004)
561 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER)
563 typedef struct _CONTEXT
565 DWORD ContextFlags;
567 /* These are selected by CONTEXT_INTEGER */
568 DWORD g0;
569 DWORD g1;
570 DWORD g2;
571 DWORD g3;
572 DWORD g4;
573 DWORD g5;
574 DWORD g6;
575 DWORD g7;
576 DWORD o0;
577 DWORD o1;
578 DWORD o2;
579 DWORD o3;
580 DWORD o4;
581 DWORD o5;
582 DWORD o6;
583 DWORD o7;
584 DWORD l0;
585 DWORD l1;
586 DWORD l2;
587 DWORD l3;
588 DWORD l4;
589 DWORD l5;
590 DWORD l6;
591 DWORD l7;
592 DWORD i0;
593 DWORD i1;
594 DWORD i2;
595 DWORD i3;
596 DWORD i4;
597 DWORD i5;
598 DWORD i6;
599 DWORD i7;
601 /* These are selected by CONTEXT_CONTROL */
602 DWORD psr;
603 DWORD pc;
604 DWORD npc;
605 DWORD y;
606 DWORD wim;
607 DWORD tbr;
609 /* FIXME: floating point registers missing */
611 } CONTEXT;
613 #endif
615 #if !defined(CONTEXT_FULL) && !defined(RC_INVOKED)
616 #error You need to define a CONTEXT for your CPU
617 #endif
619 typedef CONTEXT *PCONTEXT;
620 typedef HANDLE *PHANDLE;
622 #ifdef __WINE__
624 /* Macros for easier access to i386 context registers */
626 #define EAX_reg(context) ((context)->Eax)
627 #define EBX_reg(context) ((context)->Ebx)
628 #define ECX_reg(context) ((context)->Ecx)
629 #define EDX_reg(context) ((context)->Edx)
630 #define ESI_reg(context) ((context)->Esi)
631 #define EDI_reg(context) ((context)->Edi)
632 #define EBP_reg(context) ((context)->Ebp)
634 #define CS_reg(context) ((context)->SegCs)
635 #define DS_reg(context) ((context)->SegDs)
636 #define ES_reg(context) ((context)->SegEs)
637 #define FS_reg(context) ((context)->SegFs)
638 #define GS_reg(context) ((context)->SegGs)
639 #define SS_reg(context) ((context)->SegSs)
641 #define EFL_reg(context) ((context)->EFlags)
642 #define EIP_reg(context) ((context)->Eip)
643 #define ESP_reg(context) ((context)->Esp)
645 #define AX_reg(context) (*(WORD*)&EAX_reg(context))
646 #define BX_reg(context) (*(WORD*)&EBX_reg(context))
647 #define CX_reg(context) (*(WORD*)&ECX_reg(context))
648 #define DX_reg(context) (*(WORD*)&EDX_reg(context))
649 #define SI_reg(context) (*(WORD*)&ESI_reg(context))
650 #define DI_reg(context) (*(WORD*)&EDI_reg(context))
651 #define BP_reg(context) (*(WORD*)&EBP_reg(context))
653 #define AL_reg(context) (*(BYTE*)&EAX_reg(context))
654 #define AH_reg(context) (*((BYTE*)&EAX_reg(context)+1))
655 #define BL_reg(context) (*(BYTE*)&EBX_reg(context))
656 #define BH_reg(context) (*((BYTE*)&EBX_reg(context)+1))
657 #define CL_reg(context) (*(BYTE*)&ECX_reg(context))
658 #define CH_reg(context) (*((BYTE*)&ECX_reg(context)+1))
659 #define DL_reg(context) (*(BYTE*)&EDX_reg(context))
660 #define DH_reg(context) (*((BYTE*)&EDX_reg(context)+1))
662 #define SET_CFLAG(context) (EFL_reg(context) |= 0x0001)
663 #define RESET_CFLAG(context) (EFL_reg(context) &= ~0x0001)
664 #define SET_ZFLAG(context) (EFL_reg(context) |= 0x0040)
665 #define RESET_ZFLAG(context) (EFL_reg(context) &= ~0x0040)
667 #define ISV86(context) (EFL_reg(context) & 0x00020000)
668 #define V86BASE(context) ((context)->Dr7) /* ugly */
671 /* Macros to retrieve the current context */
673 #ifdef __i386__
675 #ifdef NEED_UNDERSCORE_PREFIX
676 # define __ASM_NAME(name) "_" name
677 #else
678 # define __ASM_NAME(name) name
679 #endif
681 #ifdef __GNUC__
682 # define __ASM_GLOBAL_FUNC(name,code) \
683 __asm__( ".align 4\n\t" \
684 ".globl " __ASM_NAME(#name) "\n\t" \
685 ".type " __ASM_NAME(#name) ",@function\n" \
686 __ASM_NAME(#name) ":\n\t" \
687 code );
688 #else /* __GNUC__ */
689 # define __ASM_GLOBAL_FUNC(name,code) \
690 void __asm_dummy_##name(void) { \
691 asm( ".align 4\n\t" \
692 ".globl " __ASM_NAME(#name) "\n\t" \
693 ".type " __ASM_NAME(#name) ",@function\n" \
694 __ASM_NAME(#name) ":\n\t" \
695 code ); \
697 #endif /* __GNUC__ */
699 #define _DEFINE_REGS_ENTRYPOINT( name, fn, args ) \
700 __ASM_GLOBAL_FUNC( name, \
701 "call " __ASM_NAME("CALL32_Regs") "\n\t" \
702 ".long " __ASM_NAME(#fn) "\n\t" \
703 ".byte " #args ", " #args )
704 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
705 _DEFINE_REGS_ENTRYPOINT( name, fn, 0 )
706 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
707 _DEFINE_REGS_ENTRYPOINT( name, fn, 4 )
708 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
709 _DEFINE_REGS_ENTRYPOINT( name, fn, 8 )
710 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
711 _DEFINE_REGS_ENTRYPOINT( name, fn, 12 )
712 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
713 _DEFINE_REGS_ENTRYPOINT( name, fn, 16 )
715 #endif /* __i386__ */
717 #ifdef __sparc__
718 /* FIXME: use getcontext() to retrieve full context */
719 #define _GET_CONTEXT \
720 CONTEXT context; \
721 do { memset(&context, 0, sizeof(CONTEXT)); \
722 context.ContextFlags = CONTEXT_CONTROL; \
723 context.pc = (DWORD)__builtin_return_address(0); \
724 } while (0)
726 #define DEFINE_REGS_ENTRYPOINT_0( name, fn ) \
727 void WINAPI name ( void ) \
728 { _GET_CONTEXT; fn( &context ); }
729 #define DEFINE_REGS_ENTRYPOINT_1( name, fn, t1 ) \
730 void WINAPI name ( t1 a1 ) \
731 { _GET_CONTEXT; fn( a1, &context ); }
732 #define DEFINE_REGS_ENTRYPOINT_2( name, fn, t1, t2 ) \
733 void WINAPI name ( t1 a1, t2 a2 ) \
734 { _GET_CONTEXT; fn( a1, a2, &context ); }
735 #define DEFINE_REGS_ENTRYPOINT_3( name, fn, t1, t2, t3 ) \
736 void WINAPI name ( t1 a1, t2 a2, t3 a3 ) \
737 { _GET_CONTEXT; fn( a1, a2, a3, &context ); }
738 #define DEFINE_REGS_ENTRYPOINT_4( name, fn, t1, t2, t3, t4 ) \
739 void WINAPI name ( t1 a1, t2 a2, t3 a3, t4 a4 ) \
740 { _GET_CONTEXT; fn( a1, a2, a3, a4, &context ); }
742 #endif /* __sparc__ */
744 #ifndef DEFINE_REGS_ENTRYPOINT_0
745 #error You need to define DEFINE_REGS_ENTRYPOINT macros for your CPU
746 #endif
748 #ifdef __i386__
749 # define GET_IP(context) ((LPVOID)(context)->Eip)
750 #endif
751 #ifdef __sparc__
752 # define GET_IP(context) ((LPVOID)(context)->pc)
753 #endif
755 #if !defined(GET_IP) && !defined(RC_INVOKED)
756 # error You must define GET_IP for this CPU
757 #endif
759 #endif /* __WINE__ */
762 * Exception codes
765 #define STATUS_SUCCESS 0x00000000
766 #define STATUS_WAIT_0 0x00000000
767 #define STATUS_ABANDONED_WAIT_0 0x00000080
768 #define STATUS_USER_APC 0x000000C0
769 #define STATUS_TIMEOUT 0x00000102
770 #define STATUS_PENDING 0x00000103
772 #define STATUS_GUARD_PAGE_VIOLATION 0x80000001
773 #define STATUS_DATATYPE_MISALIGNMENT 0x80000002
774 #define STATUS_BREAKPOINT 0x80000003
775 #define STATUS_SINGLE_STEP 0x80000004
776 #define STATUS_BUFFER_OVERFLOW 0x80000005
777 #define STATUS_NO_MORE_FILES 0x80000006
778 #define STATUS_WAKE_SYSTEM_DEBUGGER 0x80000007
780 #define STATUS_HANDLES_CLOSED 0x8000000A
781 #define STATUS_NO_INHERITANCE 0x8000000B
782 #define STATUS_GUID_SUBSTITUTION_MADE 0x8000000C
783 #define STATUS_PARTIAL_COPY 0x8000000D
784 #define STATUS_DEVICE_PAPER_EMPTY 0x8000000E
785 #define STATUS_DEVICE_POWERED_OFF 0x8000000F
786 #define STATUS_DEVICE_OFF_LINE 0x80000010
787 #define STATUS_DEVICE_BUSY 0x80000011
788 #define STATUS_NO_MORE_EAS 0x80000012
789 #define STATUS_INVALID_EA_NAME 0x80000013
790 #define STATUS_EA_LIST_INCONSISTENT 0x80000014
791 #define STATUS_INVALID_EA_FLAG 0x80000015
792 #define STATUS_VERIFY_REQUIRED 0x80000016
793 #define STATUS_EXTRANEOUS_INFORMATION 0x80000017
794 #define STATUS_RXACT_COMMIT_NECESSARY 0x80000018
795 #define STATUS_NO_MORE_ENTRIES 0x8000001A
796 #define STATUS_FILEMARK_DETECTED 0x8000001B
797 #define STATUS_MEDIA_CHANGED 0x8000001C
798 #define STATUS_BUS_RESET 0x8000001D
799 #define STATUS_END_OF_MEDIA 0x8000001E
800 #define STATUS_BEGINNING_OF_MEDIA 0x8000001F
801 #define STATUS_MEDIA_CHECK 0x80000020
802 #define STATUS_SETMARK_DETECTED 0x80000021
803 #define STATUS_NO_DATA_DETECTED 0x80000022
804 #define STATUS_REDIRECTOR_HAS_OPEN_HANDLES 0x80000023
805 #define STATUS_SERVER_HAS_OPEN_HANDLES 0x80000024
806 #define STATUS_ALREADY_DISCONNECTED 0x80000025
807 #define STATUS_LONGJUMP 0x80000026
809 #define STATUS_UNSUCCESSFUL 0xC0000001
810 #define STATUS_NOT_IMPLEMENTED 0xC0000002
811 #define STATUS_INVALID_INFO_CLASS 0xC0000003
812 #define STATUS_INFO_LENGTH_MISMATCH 0xC0000004
813 #define STATUS_ACCESS_VIOLATION 0xC0000005
814 #define STATUS_IN_PAGE_ERROR 0xC0000006
815 #define STATUS_PAGEFILE_QUOTA 0xC0000007
816 #define STATUS_INVALID_HANDLE 0xC0000008
817 #define STATUS_BAD_INITIAL_STACK 0xC0000009
818 #define STATUS_BAD_INITIAL_PC 0xC000000A
819 #define STATUS_INVALID_CID 0xC000000B
820 #define STATUS_TIMER_NOT_CANCELED 0xC000000C
821 #define STATUS_INVALID_PARAMETER 0xC000000D
822 #define STATUS_NO_SUCH_DEVICE 0xC000000E
823 #define STATUS_NO_SUCH_FILE 0xC000000F
824 #define STATUS_INVALID_DEVICE_REQUEST 0xC0000010
825 #define STATUS_END_OF_FILE 0xC0000011
826 #define STATUS_WRONG_VOLUME 0xC0000012
827 #define STATUS_NO_MEDIA_IN_DEVICE 0xC0000013
828 #define STATUS_UNRECOGNIZED_MEDIA 0xC0000014
829 #define STATUS_NONEXISTENT_SECTOR 0xC0000015
830 #define STATUS_MORE_PROCESSING_REQUIRED 0xC0000016
831 #define STATUS_NO_MEMORY 0xC0000017
832 #define STATUS_CONFLICTING_ADDRESSES 0xC0000018
833 #define STATUS_NOT_MAPPED_VIEW 0xC0000019
834 #define STATUS_UNABLE_TO_FREE_VM 0xC000001A
835 #define STATUS_UNABLE_TO_DELETE_SECTION 0xC000001B
836 #define STATUS_INVALID_SYSTEM_SERVICE 0xC000001C
837 #define STATUS_ILLEGAL_INSTRUCTION 0xC000001D
838 #define STATUS_INVALID_LOCK_SEQUENCE 0xC000001E
839 #define STATUS_INVALID_VIEW_SIZE 0xC000001F
840 #define STATUS_INVALID_FILE_FOR_SECTION 0xC0000020
841 #define STATUS_ALREADY_COMMITTED 0xC0000021
842 #define STATUS_ACCESS_DENIED 0xC0000022
843 #define STATUS_BUFFER_TOO_SMALL 0xC0000023
844 #define STATUS_OBJECT_TYPE_MISMATCH 0xC0000024
845 #define STATUS_NONCONTINUABLE_EXCEPTION 0xC0000025
846 #define STATUS_INVALID_DISPOSITION 0xC0000026
847 #define STATUS_UNWIND 0xC0000027
848 #define STATUS_BAD_STACK 0xC0000028
849 #define STATUS_INVALID_UNWIND_TARGET 0xC0000029
850 #define STATUS_NOT_LOCKED 0xC000002A
851 #define STATUS_PARITY_ERROR 0xC000002B
852 #define STATUS_UNABLE_TO_DECOMMIT_VM 0xC000002C
853 #define STATUS_NOT_COMMITTED 0xC000002D
854 #define STATUS_INVALID_PORT_ATTRIBUTES 0xC000002E
855 #define STATUS_PORT_MESSAGE_TOO_LONG 0xC000002F
856 #define STATUS_INVALID_PARAMETER_MIX 0xC0000030
857 #define STATUS_INVALID_QUOTA_LOWER 0xC0000031
858 #define STATUS_DISK_CORRUPT_ERROR 0xC0000032
859 #define STATUS_OBJECT_NAME_INVALID 0xC0000033
860 #define STATUS_OBJECT_NAME_NOT_FOUND 0xC0000034
861 #define STATUS_OBJECT_NAME_COLLISION 0xC0000035
862 #define STATUS_PORT_DISCONNECTED 0xC0000037
863 #define STATUS_DEVICE_ALREADY_ATTACHED 0xC0000038
864 #define STATUS_OBJECT_PATH_INVALID 0xC0000039
865 #define STATUS_OBJECT_PATH_NOT_FOUND 0xC000003A
866 #define STATUS_PATH_SYNTAX_BAD 0xC000003B
867 #define STATUS_DATA_OVERRUN 0xC000003C
868 #define STATUS_DATA_LATE_ERROR 0xC000003D
869 #define STATUS_DATA_ERROR 0xC000003E
870 #define STATUS_CRC_ERROR 0xC000003F
871 #define STATUS_SECTION_TOO_BIG 0xC0000040
872 #define STATUS_PORT_CONNECTION_REFUSED 0xC0000041
873 #define STATUS_INVALID_PORT_HANDLE 0xC0000042
874 #define STATUS_SHARING_VIOLATION 0xC0000043
875 #define STATUS_QUOTA_EXCEEDED 0xC0000044
876 #define STATUS_INVALID_PAGE_PROTECTION 0xC0000045
877 #define STATUS_MUTANT_NOT_OWNED 0xC0000046
878 #define STATUS_SEMAPHORE_LIMIT_EXCEEDED 0xC0000047
879 #define STATUS_PORT_ALREADY_SET 0xC0000048
880 #define STATUS_SUSPEND_COUNT_EXCEEDED 0xC000004A
881 #define STATUS_LOCK_NOT_GRANTED 0xC0000054 /* FIXME: not sure */
882 #define STATUS_FILE_LOCK_CONFLICT 0xC0000055 /* FIXME: not sure */
883 #define STATUS_UNKNOWN_REVISION 0xC0000058
884 #define STATUS_INVALID_SECURITY_DESCR 0xC0000079
885 #define STATUS_DISK_FULL 0xC000007F
886 #define STATUS_SECTION_NOT_EXTENDED 0xC0000087
887 #define STATUS_ARRAY_BOUNDS_EXCEEDED 0xC000008C
888 #define STATUS_FLOAT_DENORMAL_OPERAND 0xC000008D
889 #define STATUS_FLOAT_DIVIDE_BY_ZERO 0xC000008E
890 #define STATUS_FLOAT_INEXACT_RESULT 0xC000008F
891 #define STATUS_FLOAT_INVALID_OPERATION 0xC0000090
892 #define STATUS_FLOAT_OVERFLOW 0xC0000091
893 #define STATUS_FLOAT_STACK_CHECK 0xC0000092
894 #define STATUS_FLOAT_UNDERFLOW 0xC0000093
895 #define STATUS_INTEGER_DIVIDE_BY_ZERO 0xC0000094
896 #define STATUS_INTEGER_OVERFLOW 0xC0000095
897 #define STATUS_PRIVILEGED_INSTRUCTION 0xC0000096
898 #define STATUS_MEDIA_WRITE_PROTECTED 0XC00000A2
899 #define STATUS_INVALID_PARAMETER_2 0xC00000F0
900 #define STATUS_STACK_OVERFLOW 0xC00000FD
901 #define STATUS_DIRECTORY_NOT_EMPTY 0xC0000101
902 #define STATUS_TOO_MANY_OPENED_FILES 0xC000011F
903 #define STATUS_CONTROL_C_EXIT 0xC000013A
904 #define STATUS_PIPE_BROKEN 0xC000014B
905 #define STATUS_NOT_REGISTRY_FILE 0xC000015C
906 #define STATUS_PARTITION_FAILURE 0xC0000172
907 #define STATUS_INVALID_BLOCK_LENGTH 0xC0000173
908 #define STATUS_DEVICE_NOT_PARTITIONED 0xC0000174
909 #define STATUS_UNABLE_TO_LOCK_MEDIA 0xC0000175
910 #define STATUS_UNABLE_TO_UNLOAD_MEDIA 0xC0000176
911 #define STATUS_EOM_OVERFLOW 0xC0000177
912 #define STATUS_NO_MEDIA 0xC0000178
913 #define STATUS_NO_SUCH_MEMBER 0xC000017A
914 #define STATUS_INVALID_MEMBER 0xC000017B
915 #define STATUS_KEY_DELETED 0xC000017C
916 #define STATUS_NO_LOG_SPACE 0xC000017D
917 #define STATUS_TOO_MANY_SIDS 0xC000017E
918 #define STATUS_LM_CROSS_ENCRYPTION_REQUIRED 0xC000017F
919 #define STATUS_KEY_HAS_CHILDREN 0xC0000180
920 #define STATUS_CHILD_MUST_BE_VOLATILE 0xC0000181
921 #define STATUS_DEVICE_CONFIGURATION_ERROR0xC0000182
922 #define STATUS_DRIVER_INTERNAL_ERROR 0xC0000183
923 #define STATUS_INVALID_DEVICE_STATE 0xC0000184
924 #define STATUS_IO_DEVICE_ERROR 0xC0000185
925 #define STATUS_DEVICE_PROTOCOL_ERROR 0xC0000186
926 #define STATUS_BACKUP_CONTROLLER 0xC0000187
927 #define STATUS_LOG_FILE_FULL 0xC0000188
928 #define STATUS_TOO_LATE 0xC0000189
929 #define STATUS_NO_TRUST_LSA_SECRET 0xC000018A
930 #define STATUS_NO_TRUST_SAM_ACCOUNT 0xC000018B
931 #define STATUS_TRUSTED_DOMAIN_FAILURE 0xC000018C
932 #define STATUS_TRUSTED_RELATIONSHIP_FAILURE 0xC000018D
933 #define STATUS_EVENTLOG_FILE_CORRUPT 0xC000018E
934 #define STATUS_EVENTLOG_CANT_START 0xC000018F
935 #define STATUS_TRUST_FAILURE 0xC0000190
936 #define STATUS_MUTANT_LIMIT_EXCEEDED 0xC0000191
937 #define STATUS_NETLOGON_NOT_STARTED 0xC0000192
938 #define STATUS_ACCOUNT_EXPIRED 0xC0000193
939 #define STATUS_POSSIBLE_DEADLOCK 0xC0000194
940 #define STATUS_NETWORK_CREDENTIAL_CONFLICT 0xC0000195
941 #define STATUS_REMOTE_SESSION_LIMIT 0xC0000196
942 #define STATUS_EVENTLOG_FILE_CHANGED 0xC0000197
943 #define STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT 0xC0000198
944 #define STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT 0xC0000199
945 #define STATUS_NOLOGON_SERVER_TRUST_ACCOUNT 0xC000019A
946 #define STATUS_DOMAIN_TRUST_INCONSISTENT 0xC000019B
947 #define STATUS_FS_DRIVER_REQUIRED 0xC000019C
949 #define STATUS_RESOURCE_LANG_NOT_FOUND 0xC0000204
951 #define MAXIMUM_WAIT_OBJECTS 64
952 #define MAXIMUM_SUSPEND_COUNT 127
956 * Return values from the actual exception handlers
959 #define ExceptionContinueExecution 0
960 #define ExceptionContinueSearch 1
961 #define ExceptionNestedException 2
962 #define ExceptionCollidedUnwind 3
965 * Return values from filters in except() and from UnhandledExceptionFilter
968 #define EXCEPTION_EXECUTE_HANDLER 1
969 #define EXCEPTION_CONTINUE_SEARCH 0
970 #define EXCEPTION_CONTINUE_EXECUTION -1
973 * From OS/2 2.0 exception handling
974 * Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD
977 #define EH_NONCONTINUABLE 0x01
978 #define EH_UNWINDING 0x02
979 #define EH_EXIT_UNWIND 0x04
980 #define EH_STACK_INVALID 0x08
981 #define EH_NESTED_CALL 0x10
983 #define EXCEPTION_CONTINUABLE 0
984 #define EXCEPTION_NONCONTINUABLE EH_NONCONTINUABLE
987 * The exception record used by Win32 to give additional information
988 * about exception to exception handlers.
991 #define EXCEPTION_MAXIMUM_PARAMETERS 15
993 typedef struct __EXCEPTION_RECORD
995 DWORD ExceptionCode;
996 DWORD ExceptionFlags;
997 struct __EXCEPTION_RECORD *ExceptionRecord;
999 LPVOID ExceptionAddress;
1000 DWORD NumberParameters;
1001 DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
1002 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
1005 * The exception pointers structure passed to exception filters
1006 * in except() and the UnhandledExceptionFilter().
1009 typedef struct _EXCEPTION_POINTERS
1011 PEXCEPTION_RECORD ExceptionRecord;
1012 PCONTEXT ContextRecord;
1013 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
1017 * The exception frame, used for registering exception handlers
1018 * Win32 cares only about this, but compilers generally emit
1019 * larger exception frames for their own use.
1022 struct __EXCEPTION_FRAME;
1024 typedef DWORD (*PEXCEPTION_HANDLER)(PEXCEPTION_RECORD,struct __EXCEPTION_FRAME*,
1025 PCONTEXT,struct __EXCEPTION_FRAME **);
1027 typedef struct __EXCEPTION_FRAME
1029 struct __EXCEPTION_FRAME *Prev;
1030 PEXCEPTION_HANDLER Handler;
1031 } EXCEPTION_FRAME, *PEXCEPTION_FRAME;
1033 #include "poppack.h"
1036 * function pointer to a exception filter
1039 typedef LONG (CALLBACK *PTOP_LEVEL_EXCEPTION_FILTER)(PEXCEPTION_POINTERS ExceptionInfo);
1040 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
1042 DWORD WINAPI UnhandledExceptionFilter( PEXCEPTION_POINTERS epointers );
1043 LPTOP_LEVEL_EXCEPTION_FILTER
1044 WINAPI SetUnhandledExceptionFilter( LPTOP_LEVEL_EXCEPTION_FILTER filter );
1046 /* status values for ContinueDebugEvent */
1047 #define DBG_CONTINUE 0x00010002
1048 #define DBG_TERMINATE_THREAD 0x40010003
1049 #define DBG_TERMINATE_PROCESS 0x40010004
1050 #define DBG_CONTROL_C 0x40010005
1051 #define DBG_CONTROL_BREAK 0x40010008
1052 #define DBG_EXCEPTION_NOT_HANDLED 0x80010001
1054 typedef struct _NT_TIB
1056 struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;
1057 PVOID StackBase;
1058 PVOID StackLimit;
1059 PVOID SubSystemTib;
1060 union {
1061 PVOID FiberData;
1062 DWORD Version;
1063 } DUMMYUNIONNAME;
1064 PVOID ArbitraryUserPointer;
1065 struct _NT_TIB *Self;
1066 } NT_TIB, *PNT_TIB;
1068 struct _TEB;
1070 #if defined(__i386__) && defined(__GNUC__)
1071 extern inline struct _TEB * WINAPI NtCurrentTeb(void)
1073 struct _TEB *teb;
1074 __asm__(".byte 0x64\n\tmovl (0x18),%0" : "=r" (teb));
1075 return teb;
1077 #else
1078 extern struct _TEB * WINAPI NtCurrentTeb(void);
1079 #endif
1082 * Here follows typedefs for security and tokens.
1086 * First a constant for the following typdefs.
1089 #define ANYSIZE_ARRAY 1
1091 /* FIXME: Orphan. What does it point to? */
1092 typedef PVOID PACCESS_TOKEN;
1095 * TOKEN_INFORMATION_CLASS
1098 typedef enum _TOKEN_INFORMATION_CLASS {
1099 TokenUser = 1,
1100 TokenGroups,
1101 TokenPrivileges,
1102 TokenOwner,
1103 TokenPrimaryGroup,
1104 TokenDefaultDacl,
1105 TokenSource,
1106 TokenType,
1107 TokenImpersonationLevel,
1108 TokenStatistics
1109 } TOKEN_INFORMATION_CLASS;
1111 #ifndef _SECURITY_DEFINED
1112 #define _SECURITY_DEFINED
1114 #include "pshpack1.h"
1116 typedef DWORD ACCESS_MASK, *PACCESS_MASK;
1118 typedef struct _GENERIC_MAPPING {
1119 ACCESS_MASK GenericRead;
1120 ACCESS_MASK GenericWrite;
1121 ACCESS_MASK GenericExecute;
1122 ACCESS_MASK GenericAll;
1123 } GENERIC_MAPPING, *PGENERIC_MAPPING;
1125 #ifndef SID_IDENTIFIER_AUTHORITY_DEFINED
1126 #define SID_IDENTIFIER_AUTHORITY_DEFINED
1127 typedef struct {
1128 BYTE Value[6];
1129 } SID_IDENTIFIER_AUTHORITY,*PSID_IDENTIFIER_AUTHORITY,*LPSID_IDENTIFIER_AUTHORITY;
1130 #endif /* !defined(SID_IDENTIFIER_AUTHORITY_DEFINED) */
1132 #ifndef SID_DEFINED
1133 #define SID_DEFINED
1134 typedef struct _SID {
1135 BYTE Revision;
1136 BYTE SubAuthorityCount;
1137 SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
1138 DWORD SubAuthority[1];
1139 } SID,*PSID;
1140 #endif /* !defined(SID_DEFINED) */
1142 #define SID_REVISION (1) /* Current revision */
1143 #define SID_MAX_SUB_AUTHORITIES (15) /* current max subauths */
1144 #define SID_RECOMMENDED_SUB_AUTHORITIES (1) /* recommended subauths */
1148 * ACL
1151 #define ACL_REVISION1 1
1152 #define ACL_REVISION2 2
1153 #define ACL_REVISION3 3
1154 #define ACL_REVISION4 4
1156 #define MIN_ACL_REVISION ACL_REVISION2
1157 #define MAX_ACL_REVISION ACL_REVISION4
1159 typedef struct _ACL {
1160 BYTE AclRevision;
1161 BYTE Sbz1;
1162 WORD AclSize;
1163 WORD AceCount;
1164 WORD Sbz2;
1165 } ACL, *PACL;
1167 /* SECURITY_DESCRIPTOR */
1168 #define SECURITY_DESCRIPTOR_REVISION 1
1169 #define SECURITY_DESCRIPTOR_REVISION1 1
1172 #define SE_OWNER_DEFAULTED 0x0001
1173 #define SE_GROUP_DEFAULTED 0x0002
1174 #define SE_DACL_PRESENT 0x0004
1175 #define SE_DACL_DEFAULTED 0x0008
1176 #define SE_SACL_PRESENT 0x0010
1177 #define SE_SACL_DEFAULTED 0x0020
1178 #define SE_SELF_RELATIVE 0x8000
1180 typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION;
1181 typedef WORD SECURITY_DESCRIPTOR_CONTROL, *PSECURITY_DESCRIPTOR_CONTROL;
1183 /* The security descriptor structure */
1184 typedef struct {
1185 BYTE Revision;
1186 BYTE Sbz1;
1187 SECURITY_DESCRIPTOR_CONTROL Control;
1188 DWORD Owner;
1189 DWORD Group;
1190 DWORD Sacl;
1191 DWORD Dacl;
1192 } SECURITY_DESCRIPTOR_RELATIVE, *PISECURITY_DESCRIPTOR_RELATIVE;
1194 typedef struct {
1195 BYTE Revision;
1196 BYTE Sbz1;
1197 SECURITY_DESCRIPTOR_CONTROL Control;
1198 PSID Owner;
1199 PSID Group;
1200 PACL Sacl;
1201 PACL Dacl;
1202 } SECURITY_DESCRIPTOR, *PSECURITY_DESCRIPTOR;
1204 #define SECURITY_DESCRIPTOR_MIN_LENGTH (sizeof(SECURITY_DESCRIPTOR))
1206 #include "poppack.h"
1208 #endif /* _SECURITY_DEFINED */
1210 #include "pshpack1.h"
1213 * SID_AND_ATTRIBUTES
1216 typedef struct _SID_AND_ATTRIBUTES {
1217 PSID Sid;
1218 DWORD Attributes;
1219 } SID_AND_ATTRIBUTES ;
1221 /* security entities */
1222 #define SECURITY_NULL_RID (0x00000000L)
1223 #define SECURITY_WORLD_RID (0x00000000L)
1224 #define SECURITY_LOCAL_RID (0X00000000L)
1226 #define SECURITY_NULL_SID_AUTHORITY {0,0,0,0,0,0}
1228 /* S-1-1 */
1229 #define SECURITY_WORLD_SID_AUTHORITY {0,0,0,0,0,1}
1231 /* S-1-2 */
1232 #define SECURITY_LOCAL_SID_AUTHORITY {0,0,0,0,0,2}
1234 /* S-1-3 */
1235 #define SECURITY_CREATOR_SID_AUTHORITY {0,0,0,0,0,3}
1236 #define SECURITY_CREATOR_OWNER_RID (0x00000000L)
1237 #define SECURITY_CREATOR_GROUP_RID (0x00000001L)
1238 #define SECURITY_CREATOR_OWNER_SERVER_RID (0x00000002L)
1239 #define SECURITY_CREATOR_GROUP_SERVER_RID (0x00000003L)
1241 /* S-1-4 */
1242 #define SECURITY_NON_UNIQUE_AUTHORITY {0,0,0,0,0,4}
1244 /* S-1-5 */
1245 #define SECURITY_NT_AUTHORITY {0,0,0,0,0,5}
1246 #define SECURITY_DIALUP_RID 0x00000001L
1247 #define SECURITY_NETWORK_RID 0x00000002L
1248 #define SECURITY_BATCH_RID 0x00000003L
1249 #define SECURITY_INTERACTIVE_RID 0x00000004L
1250 #define SECURITY_LOGON_IDS_RID 0x00000005L
1251 #define SECURITY_SERVICE_RID 0x00000006L
1252 #define SECURITY_ANONYMOUS_LOGON_RID 0x00000007L
1253 #define SECURITY_PROXY_RID 0x00000008L
1254 #define SECURITY_ENTERPRISE_CONTROLLERS_RID 0x00000009L
1255 #define SECURITY_PRINCIPAL_SELF_RID 0x0000000AL
1256 #define SECURITY_AUTHENTICATED_USER_RID 0x0000000BL
1257 #define SECURITY_RESTRICTED_CODE_RID 0x0000000CL
1258 #define SECURITY_TERMINAL_SERVER_RID 0x0000000DL
1259 #define SECURITY_LOCAL_SYSTEM_RID 0x00000012L
1260 #define SECURITY_NT_NON_UNIQUE 0x00000015L
1261 #define SECURITY_BUILTIN_DOMAIN_RID 0x00000020L
1263 #define DOMAIN_GROUP_RID_ADMINS 0x00000200L
1264 #define DOMAIN_GROUP_RID_USERS 0x00000201L
1265 #define DOMAIN_GROUP_RID_GUESTS 0x00000202L
1267 #define DOMAIN_ALIAS_RID_ADMINS 0x00000220L
1268 #define DOMAIN_ALIAS_RID_USERS 0x00000221L
1269 #define DOMAIN_ALIAS_RID_GUESTS 0x00000222L
1271 #define SECURITY_SERVER_LOGON_RID SECURITY_ENTERPRISE_CONTROLLERS_RID
1273 #define SECURITY_LOGON_IDS_RID_COUNT (3L)
1276 * TOKEN_USER
1279 typedef struct _TOKEN_USER {
1280 SID_AND_ATTRIBUTES User;
1281 } TOKEN_USER;
1284 * TOKEN_GROUPS
1287 typedef struct _TOKEN_GROUPS {
1288 DWORD GroupCount;
1289 SID_AND_ATTRIBUTES Groups[ANYSIZE_ARRAY];
1290 } TOKEN_GROUPS;
1293 * LUID_AND_ATTRIBUTES
1296 typedef union _LARGE_INTEGER {
1297 struct {
1298 DWORD LowPart;
1299 LONG HighPart;
1300 } DUMMYSTRUCTNAME;
1301 LONGLONG QuadPart;
1302 } LARGE_INTEGER, *LPLARGE_INTEGER, *PLARGE_INTEGER;
1304 typedef union _ULARGE_INTEGER {
1305 struct {
1306 DWORD LowPart;
1307 LONG HighPart;
1308 } DUMMYSTRUCTNAME;
1309 LONGLONG QuadPart;
1310 } ULARGE_INTEGER, *LPULARGE_INTEGER, *PULARGE_INTEGER;
1313 * Locally Unique Identifier
1316 typedef LARGE_INTEGER LUID,*PLUID;
1318 typedef struct _LUID_AND_ATTRIBUTES {
1319 LUID Luid;
1320 DWORD Attributes;
1321 } LUID_AND_ATTRIBUTES;
1324 * PRIVILEGE_SET
1327 typedef struct _PRIVILEGE_SET {
1328 DWORD PrivilegeCount;
1329 DWORD Control;
1330 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
1331 } PRIVILEGE_SET, *PPRIVILEGE_SET;
1334 * TOKEN_PRIVILEGES
1337 typedef struct _TOKEN_PRIVILEGES {
1338 DWORD PrivilegeCount;
1339 LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY];
1340 } TOKEN_PRIVILEGES, *PTOKEN_PRIVILEGES;
1343 * TOKEN_OWNER
1346 typedef struct _TOKEN_OWNER {
1347 PSID Owner;
1348 } TOKEN_OWNER;
1351 * TOKEN_PRIMARY_GROUP
1354 typedef struct _TOKEN_PRIMARY_GROUP {
1355 PSID PrimaryGroup;
1356 } TOKEN_PRIMARY_GROUP;
1360 * TOKEN_DEFAULT_DACL
1363 typedef struct _TOKEN_DEFAULT_DACL {
1364 PACL DefaultDacl;
1365 } TOKEN_DEFAULT_DACL;
1368 * TOKEN_SOURCEL
1371 typedef struct _TOKEN_SOURCE {
1372 char Sourcename[8];
1373 LUID SourceIdentifier;
1374 } TOKEN_SOURCE;
1377 * TOKEN_TYPE
1380 typedef enum tagTOKEN_TYPE {
1381 TokenPrimary = 1,
1382 TokenImpersonation
1383 } TOKEN_TYPE;
1386 * SECURITY_IMPERSONATION_LEVEL
1389 typedef enum _SECURITY_IMPERSONATION_LEVEL {
1390 SecurityAnonymous,
1391 SecurityIdentification,
1392 SecurityImpersonation,
1393 SecurityDelegation
1394 } SECURITY_IMPERSONATION_LEVEL, *PSECURITY_IMPERSONATION_LEVEL;
1397 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE,
1398 * PSECURITY_CONTEXT_TRACKING_MODE;
1400 * Quality of Service
1403 typedef struct _SECURITY_QUALITY_OF_SERVICE {
1404 DWORD Length;
1405 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
1406 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
1407 BOOL EffectiveOnly;
1408 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
1411 * TOKEN_STATISTICS
1414 typedef struct _TOKEN_STATISTICS {
1415 LUID TokenId;
1416 LUID AuthenticationId;
1417 LARGE_INTEGER ExpirationTime;
1418 TOKEN_TYPE TokenType;
1419 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
1420 DWORD DynamicCharged;
1421 DWORD DynamicAvailable;
1422 DWORD GroupCount;
1423 DWORD PrivilegeCount;
1424 LUID ModifiedId;
1425 } TOKEN_STATISTICS;
1428 * ACLs of NT
1431 #define ACL_REVISION 2
1433 #define ACL_REVISION1 1
1434 #define ACL_REVISION2 2
1436 /* ACEs, directly starting after an ACL */
1437 typedef struct _ACE_HEADER {
1438 BYTE AceType;
1439 BYTE AceFlags;
1440 WORD AceSize;
1441 } ACE_HEADER,*PACE_HEADER;
1443 /* AceType */
1444 #define ACCESS_ALLOWED_ACE_TYPE 0
1445 #define ACCESS_DENIED_ACE_TYPE 1
1446 #define SYSTEM_AUDIT_ACE_TYPE 2
1447 #define SYSTEM_ALARM_ACE_TYPE 3
1449 /* inherit AceFlags */
1450 #define OBJECT_INHERIT_ACE 0x01
1451 #define CONTAINER_INHERIT_ACE 0x02
1452 #define NO_PROPAGATE_INHERIT_ACE 0x04
1453 #define INHERIT_ONLY_ACE 0x08
1454 #define VALID_INHERIT_FLAGS 0x0F
1456 /* AceFlags mask for what events we (should) audit */
1457 #define SUCCESSFUL_ACCESS_ACE_FLAG 0x40
1458 #define FAILED_ACCESS_ACE_FLAG 0x80
1460 /* different ACEs depending on AceType
1461 * SidStart marks the begin of a SID
1462 * so the thing finally looks like this:
1463 * 0: ACE_HEADER
1464 * 4: ACCESS_MASK
1465 * 8... : SID
1467 typedef struct _ACCESS_ALLOWED_ACE {
1468 ACE_HEADER Header;
1469 DWORD Mask;
1470 DWORD SidStart;
1471 } ACCESS_ALLOWED_ACE,*PACCESS_ALLOWED_ACE;
1473 typedef struct _ACCESS_DENIED_ACE {
1474 ACE_HEADER Header;
1475 DWORD Mask;
1476 DWORD SidStart;
1477 } ACCESS_DENIED_ACE,*PACCESS_DENIED_ACE;
1479 typedef struct _SYSTEM_AUDIT_ACE {
1480 ACE_HEADER Header;
1481 DWORD Mask;
1482 DWORD SidStart;
1483 } SYSTEM_AUDIT_ACE,*PSYSTEM_AUDIT_ACE;
1485 typedef struct _SYSTEM_ALARM_ACE {
1486 ACE_HEADER Header;
1487 DWORD Mask;
1488 DWORD SidStart;
1489 } SYSTEM_ALARM_ACE,*PSYSTEM_ALARM_ACE;
1491 typedef enum tagSID_NAME_USE {
1492 SidTypeUser = 1,
1493 SidTypeGroup,
1494 SidTypeDomain,
1495 SidTypeAlias,
1496 SidTypeWellKnownGroup,
1497 SidTypeDeletedAccount,
1498 SidTypeInvalid,
1499 SidTypeUnknown
1500 } SID_NAME_USE,*PSID_NAME_USE;
1502 /* Access rights */
1504 #define DELETE 0x00010000
1505 #define READ_CONTROL 0x00020000
1506 #define WRITE_DAC 0x00040000
1507 #define WRITE_OWNER 0x00080000
1508 #define SYNCHRONIZE 0x00100000
1509 #define STANDARD_RIGHTS_REQUIRED 0x000f0000
1511 #define STANDARD_RIGHTS_READ READ_CONTROL
1512 #define STANDARD_RIGHTS_WRITE READ_CONTROL
1513 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
1515 #define STANDARD_RIGHTS_ALL 0x001f0000
1517 #define SPECIFIC_RIGHTS_ALL 0x0000ffff
1519 #define GENERIC_READ 0x80000000
1520 #define GENERIC_WRITE 0x40000000
1521 #define GENERIC_EXECUTE 0x20000000
1522 #define GENERIC_ALL 0x10000000
1524 #define MAXIMUM_ALLOWED 0x02000000
1525 #define ACCESS_SYSTEM_SECURITY 0x01000000
1527 #define EVENT_MODIFY_STATE 0x0002
1528 #define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
1530 #define SEMAPHORE_MODIFY_STATE 0x0002
1531 #define SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
1533 #define MUTEX_MODIFY_STATE 0x0001
1534 #define MUTEX_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1)
1536 #define PROCESS_TERMINATE 0x0001
1537 #define PROCESS_CREATE_THREAD 0x0002
1538 #define PROCESS_VM_OPERATION 0x0008
1539 #define PROCESS_VM_READ 0x0010
1540 #define PROCESS_VM_WRITE 0x0020
1541 #define PROCESS_DUP_HANDLE 0x0040
1542 #define PROCESS_CREATE_PROCESS 0x0080
1543 #define PROCESS_SET_QUOTA 0x0100
1544 #define PROCESS_SET_INFORMATION 0x0200
1545 #define PROCESS_QUERY_INFORMATION 0x0400
1546 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0xfff)
1548 #define THREAD_TERMINATE 0x0001
1549 #define THREAD_SUSPEND_RESUME 0x0002
1550 #define THREAD_GET_CONTEXT 0x0008
1551 #define THREAD_SET_CONTEXT 0x0010
1552 #define THREAD_SET_INFORMATION 0x0020
1553 #define THREAD_QUERY_INFORMATION 0x0040
1554 #define THREAD_SET_THREAD_TOKEN 0x0080
1555 #define THREAD_IMPERSONATE 0x0100
1556 #define THREAD_DIRECT_IMPERSONATION 0x0200
1557 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3ff)
1559 #define THREAD_BASE_PRIORITY_LOWRT 15
1560 #define THREAD_BASE_PRIORITY_MAX 2
1561 #define THREAD_BASE_PRIORITY_MIN -2
1562 #define THREAD_BASE_PRIORITY_IDLE -15
1564 #define FILE_READ_DATA 0x0001 /* file & pipe */
1565 #define FILE_LIST_DIRECTORY 0x0001 /* directory */
1566 #define FILE_WRITE_DATA 0x0002 /* file & pipe */
1567 #define FILE_ADD_FILE 0x0002 /* directory */
1568 #define FILE_APPEND_DATA 0x0004 /* file */
1569 #define FILE_ADD_SUBDIRECTORY 0x0004 /* directory */
1570 #define FILE_CREATE_PIPE_INSTANCE 0x0004 /* named pipe */
1571 #define FILE_READ_EA 0x0008 /* file & directory */
1572 #define FILE_READ_PROPERTIES FILE_READ_EA
1573 #define FILE_WRITE_EA 0x0010 /* file & directory */
1574 #define FILE_WRITE_PROPERTIES FILE_WRITE_EA
1575 #define FILE_EXECUTE 0x0020 /* file */
1576 #define FILE_TRAVERSE 0x0020 /* directory */
1577 #define FILE_DELETE_CHILD 0x0040 /* directory */
1578 #define FILE_READ_ATTRIBUTES 0x0080 /* all */
1579 #define FILE_WRITE_ATTRIBUTES 0x0100 /* all */
1580 #define FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
1582 #define FILE_GENERIC_READ (STANDARD_RIGHTS_READ | FILE_READ_DATA | \
1583 FILE_READ_ATTRIBUTES | FILE_READ_EA | \
1584 SYNCHRONIZE)
1585 #define FILE_GENERIC_WRITE (STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | \
1586 FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | \
1587 FILE_APPEND_DATA | SYNCHRONIZE)
1588 #define FILE_GENERIC_EXECUTE (STANDARD_RIGHTS_EXECUTE | FILE_EXECUTE | \
1589 FILE_READ_ATTRIBUTES | SYNCHRONIZE)
1592 /* File attribute flags
1594 #define FILE_SHARE_READ 0x00000001L
1595 #define FILE_SHARE_WRITE 0x00000002L
1596 #define FILE_SHARE_DELETE 0x00000004L
1597 #define FILE_ATTRIBUTE_READONLY 0x00000001L
1598 #define FILE_ATTRIBUTE_HIDDEN 0x00000002L
1599 #define FILE_ATTRIBUTE_SYSTEM 0x00000004L
1600 #define FILE_ATTRIBUTE_LABEL 0x00000008L /* Not in Windows API */
1601 #define FILE_ATTRIBUTE_DIRECTORY 0x00000010L
1602 #define FILE_ATTRIBUTE_ARCHIVE 0x00000020L
1603 #define FILE_ATTRIBUTE_NORMAL 0x00000080L
1604 #define FILE_ATTRIBUTE_TEMPORARY 0x00000100L
1605 #define FILE_ATTRIBUTE_ATOMIC_WRITE 0x00000200L
1606 #define FILE_ATTRIBUTE_XACTION_WRITE 0x00000400L
1607 #define FILE_ATTRIBUTE_COMPRESSED 0x00000800L
1608 #define FILE_ATTRIBUTE_OFFLINE 0x00001000L
1610 /* File alignments (NT) */
1611 #define FILE_BYTE_ALIGNMENT 0x00000000
1612 #define FILE_WORD_ALIGNMENT 0x00000001
1613 #define FILE_LONG_ALIGNMENT 0x00000003
1614 #define FILE_QUAD_ALIGNMENT 0x00000007
1615 #define FILE_OCTA_ALIGNMENT 0x0000000f
1616 #define FILE_32_BYTE_ALIGNMENT 0x0000001f
1617 #define FILE_64_BYTE_ALIGNMENT 0x0000003f
1618 #define FILE_128_BYTE_ALIGNMENT 0x0000007f
1619 #define FILE_256_BYTE_ALIGNMENT 0x000000ff
1620 #define FILE_512_BYTE_ALIGNMENT 0x000001ff
1622 /* Registry security values */
1623 #define OWNER_SECURITY_INFORMATION 0x00000001
1624 #define GROUP_SECURITY_INFORMATION 0x00000002
1625 #define DACL_SECURITY_INFORMATION 0x00000004
1626 #define SACL_SECURITY_INFORMATION 0x00000008
1628 #define RtlEqualMemory(Destination, Source, Length) (!memcmp((Destination),(Source),(Length)))
1629 #define RtlMoveMemory(Destination, Source, Length) memmove((Destination),(Source),(Length))
1630 #define RtlCopyMemory(Destination, Source, Length) memcpy((Destination),(Source),(Length))
1631 #define RtlFillMemory(Destination, Length, Fill) memset((Destination),(Fill),(Length))
1632 #define RtlZeroMemory(Destination, Length) memset((Destination),0,(Length))
1634 #include "poppack.h"
1636 #endif /* __WINE_WINNT_H */