9daef60342a6c4580a71623da0ab070b87b608e6
[reactos.git] / reactos / include / ddk / wdm.h
1 #ifndef _WDMDDK_
2 #define _WDMDDK_
3
4 //
5 // Dependencies
6 //
7 #define NT_INCLUDED
8 #include <excpt.h>
9 #include <ntdef.h>
10 #include <ntstatus.h>
11
12
13
14 //
15 // Resource list definitions
16 //
17 typedef int CM_RESOURCE_TYPE;
18
19 #define CmResourceTypeNull 0
20 #define CmResourceTypePort 1
21 #define CmResourceTypeInterrupt 2
22 #define CmResourceTypeMemory 3
23 #define CmResourceTypeDma 4
24 #define CmResourceTypeDeviceSpecific 5
25 #define CmResourceTypeBusNumber 6
26 #define CmResourceTypeNonArbitrated 128
27 #define CmResourceTypeConfigData 128
28 #define CmResourceTypeDevicePrivate 129
29 #define CmResourceTypePcCardConfig 130
30 #define CmResourceTypeMfCardConfig 131
31
32
33
34 //
35 // Global debug flag
36 //
37 extern ULONG NtGlobalFlag;
38
39
40
41 //
42 // Section map options
43 //
44 typedef enum _SECTION_INHERIT {
45 ViewShare = 1,
46 ViewUnmap = 2
47 } SECTION_INHERIT;
48
49 //
50 // Section access rights
51 //
52 #define SECTION_QUERY 0x0001
53 #define SECTION_MAP_WRITE 0x0002
54 #define SECTION_MAP_READ 0x0004
55 #define SECTION_MAP_EXECUTE 0x0008
56 #define SECTION_EXTEND_SIZE 0x0010
57 #define SECTION_MAP_EXECUTE_EXPLICIT 0x0020
58
59 #define SECTION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SECTION_QUERY|\
60 SECTION_MAP_WRITE | \
61 SECTION_MAP_READ | \
62 SECTION_MAP_EXECUTE | \
63 SECTION_EXTEND_SIZE)
64
65 #define SESSION_QUERY_ACCESS 0x0001
66 #define SESSION_MODIFY_ACCESS 0x0002
67
68 #define SESSION_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | \
69 SESSION_QUERY_ACCESS | \
70 SESSION_MODIFY_ACCESS)
71
72
73
74 #define SEGMENT_ALL_ACCESS SECTION_ALL_ACCESS
75
76 #define PAGE_NOACCESS 0x01
77 #define PAGE_READONLY 0x02
78 #define PAGE_READWRITE 0x04
79 #define PAGE_WRITECOPY 0x08
80 #define PAGE_EXECUTE 0x10
81 #define PAGE_EXECUTE_READ 0x20
82 #define PAGE_EXECUTE_READWRITE 0x40
83 #define PAGE_EXECUTE_WRITECOPY 0x80
84 #define PAGE_GUARD 0x100
85 #define PAGE_NOCACHE 0x200
86 #define PAGE_WRITECOMBINE 0x400
87
88 #define MEM_COMMIT 0x1000
89 #define MEM_RESERVE 0x2000
90 #define MEM_DECOMMIT 0x4000
91 #define MEM_RELEASE 0x8000
92 #define MEM_FREE 0x10000
93 #define MEM_PRIVATE 0x20000
94 #define MEM_MAPPED 0x40000
95 #define MEM_RESET 0x80000
96 #define MEM_TOP_DOWN 0x100000
97 #define MEM_LARGE_PAGES 0x20000000
98 #define MEM_4MB_PAGES 0x80000000
99
100 #define SEC_RESERVE 0x4000000
101 #define SEC_LARGE_PAGES 0x80000000
102
103 #define PROCESS_DUP_HANDLE (0x0040)
104
105 #if (NTDDI_VERSION >= NTDDI_VISTA)
106 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
107 0xFFFF)
108 #else
109 #define PROCESS_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
110 0xFFF)
111 #endif
112
113
114
115 //
116 // Processor features
117 //
118 #define PF_FLOATING_POINT_PRECISION_ERRATA 0
119 #define PF_FLOATING_POINT_EMULATED 1
120 #define PF_COMPARE_EXCHANGE_DOUBLE 2
121 #define PF_MMX_INSTRUCTIONS_AVAILABLE 3
122 #define PF_PPC_MOVEMEM_64BIT_OK 4
123 #define PF_ALPHA_BYTE_INSTRUCTIONS 5
124 #define PF_XMMI_INSTRUCTIONS_AVAILABLE 6
125 #define PF_3DNOW_INSTRUCTIONS_AVAILABLE 7
126 #define PF_RDTSC_INSTRUCTION_AVAILABLE 8
127 #define PF_PAE_ENABLED 9
128 #define PF_XMMI64_INSTRUCTIONS_AVAILABLE 10
129 #define PF_SSE_DAZ_MODE_AVAILABLE 11
130 #define PF_NX_ENABLED 12
131 #define PF_SSE3_INSTRUCTIONS_AVAILABLE 13
132 #define PF_COMPARE_EXCHANGE128 14
133 #define PF_COMPARE64_EXCHANGE128 15
134 #define PF_CHANNELS_ENABLED 16
135
136
137
138 //
139 // Intrinsics (note: taken from our winnt.h)
140 // FIXME: 64-bit
141 //
142 #if defined(__GNUC__)
143
144 static __inline__ BOOLEAN
145 InterlockedBitTestAndSet(IN LONG volatile *Base,
146 IN LONG Bit)
147 {
148 #if defined(_M_IX86)
149 LONG OldBit;
150 __asm__ __volatile__("lock "
151 "btsl %2,%1\n\t"
152 "sbbl %0,%0\n\t"
153 :"=r" (OldBit),"+m" (*Base)
154 :"Ir" (Bit)
155 : "memory");
156 return OldBit;
157 #else
158 return (_InterlockedOr(Base, 1 << Bit) >> Bit) & 1;
159 #endif
160 }
161
162 static __inline__ BOOLEAN
163 InterlockedBitTestAndReset(IN LONG volatile *Base,
164 IN LONG Bit)
165 {
166 #if defined(_M_IX86)
167 LONG OldBit;
168 __asm__ __volatile__("lock "
169 "btrl %2,%1\n\t"
170 "sbbl %0,%0\n\t"
171 :"=r" (OldBit),"+m" (*Base)
172 :"Ir" (Bit)
173 : "memory");
174 return OldBit;
175 #else
176 return (_InterlockedAnd(Base, ~(1 << Bit)) >> Bit) & 1;
177 #endif
178 }
179
180 static __inline__ BOOLEAN
181 BitScanReverse(OUT ULONG *Index,
182 IN ULONG Mask)
183 {
184 BOOLEAN BitPosition = 0;
185 #if defined(_M_IX86)
186 __asm__ __volatile__("bsrl %2,%0\n\t"
187 "setnz %1\n\t"
188 :"=&r" (*Index), "=q" (BitPosition)
189 :"rm" (Mask)
190 :"memory");
191 return BitPosition;
192 #else
193 /* Slow implementation for now */
194 for( *Index = 31; *Index; (*Index)-- ) {
195 if( (1<<*Index) & Mask ) {
196 return TRUE;
197 }
198 }
199
200 return FALSE;
201 #endif
202 }
203
204 #endif
205
206
207 #if defined(_M_IX86)
208 #define YieldProcessor() __asm__ __volatile__("pause");
209 #elif defined (_M_AMD64)
210 #define YieldProcessor() __asm__ __volatile__("pause");
211 #elif defined(_M_PPC)
212 #define YieldProcessor() __asm__ __volatile__("nop");
213 #elif defined(_M_MIPS)
214 #define YieldProcessor() __asm__ __volatile__("nop");
215 #elif defined(_M_ARM)
216 #define YieldProcessor()
217 #else
218 #error Unknown architecture
219 #endif
220
221
222
223 //
224 // Slist Header
225 //
226 #ifndef _SLIST_HEADER_
227 #define _SLIST_HEADER_
228
229 #define SLIST_ENTRY SINGLE_LIST_ENTRY
230 #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
231 #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
232
233 typedef union _SLIST_HEADER {
234 ULONGLONG Alignment;
235 struct {
236 SLIST_ENTRY Next;
237 USHORT Depth;
238 USHORT Sequence;
239 } DUMMYSTRUCTNAME;
240 } SLIST_HEADER, *PSLIST_HEADER;
241
242 #endif /* _SLIST_HEADER_ */
243
244
245
246 //
247 // Power States/Levels
248 //
249 typedef enum _SYSTEM_POWER_STATE {
250 PowerSystemUnspecified,
251 PowerSystemWorking,
252 PowerSystemSleeping1,
253 PowerSystemSleeping2,
254 PowerSystemSleeping3,
255 PowerSystemHibernate,
256 PowerSystemShutdown,
257 PowerSystemMaximum
258 } SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
259
260 #define POWER_SYSTEM_MAXIMUM PowerSystemMaximum
261
262 typedef enum _POWER_INFORMATION_LEVEL {
263 SystemPowerPolicyAc,
264 SystemPowerPolicyDc,
265 VerifySystemPolicyAc,
266 VerifySystemPolicyDc,
267 SystemPowerCapabilities,
268 SystemBatteryState,
269 SystemPowerStateHandler,
270 ProcessorStateHandler,
271 SystemPowerPolicyCurrent,
272 AdministratorPowerPolicy,
273 SystemReserveHiberFile,
274 ProcessorInformation,
275 SystemPowerInformation,
276 ProcessorStateHandler2,
277 LastWakeTime,
278 LastSleepTime,
279 SystemExecutionState,
280 SystemPowerStateNotifyHandler,
281 ProcessorPowerPolicyAc,
282 ProcessorPowerPolicyDc,
283 VerifyProcessorPowerPolicyAc,
284 VerifyProcessorPowerPolicyDc,
285 ProcessorPowerPolicyCurrent
286 } POWER_INFORMATION_LEVEL;
287
288 typedef enum {
289 PowerActionNone,
290 PowerActionReserved,
291 PowerActionSleep,
292 PowerActionHibernate,
293 PowerActionShutdown,
294 PowerActionShutdownReset,
295 PowerActionShutdownOff,
296 PowerActionWarmEject
297 } POWER_ACTION, *PPOWER_ACTION;
298
299 typedef enum _DEVICE_POWER_STATE {
300 PowerDeviceUnspecified,
301 PowerDeviceD0,
302 PowerDeviceD1,
303 PowerDeviceD2,
304 PowerDeviceD3,
305 PowerDeviceMaximum
306 } DEVICE_POWER_STATE, *PDEVICE_POWER_STATE;
307
308 #define ES_SYSTEM_REQUIRED 0x00000001
309 #define ES_DISPLAY_REQUIRED 0x00000002
310 #define ES_USER_PRESENT 0x00000004
311 #define ES_CONTINUOUS 0x80000000
312
313 typedef ULONG EXECUTION_STATE;
314
315 typedef enum {
316 LT_DONT_CARE,
317 LT_LOWEST_LATENCY
318 } LATENCY_TIME;
319
320
321
322 //
323 // Access/Security Stuff
324 //
325 typedef ULONG ACCESS_MASK, *PACCESS_MASK;
326 typedef PVOID PACCESS_TOKEN;
327
328 #define DELETE 0x00010000L
329 #define READ_CONTROL 0x00020000L
330 #define WRITE_DAC 0x00040000L
331 #define WRITE_OWNER 0x00080000L
332 #define SYNCHRONIZE 0x00100000L
333 #define STANDARD_RIGHTS_REQUIRED 0x000F0000L
334 #define STANDARD_RIGHTS_READ READ_CONTROL
335 #define STANDARD_RIGHTS_WRITE READ_CONTROL
336 #define STANDARD_RIGHTS_EXECUTE READ_CONTROL
337 #define STANDARD_RIGHTS_ALL 0x001F0000L
338 #define SPECIFIC_RIGHTS_ALL 0x0000FFFFL
339 #define ACCESS_SYSTEM_SECURITY 0x01000000L
340 #define MAXIMUM_ALLOWED 0x02000000L
341 #define GENERIC_READ 0x80000000L
342 #define GENERIC_WRITE 0x40000000L
343 #define GENERIC_EXECUTE 0x20000000L
344 #define GENERIC_ALL 0x10000000L
345
346 typedef struct _GENERIC_MAPPING {
347 ACCESS_MASK GenericRead;
348 ACCESS_MASK GenericWrite;
349 ACCESS_MASK GenericExecute;
350 ACCESS_MASK GenericAll;
351 } GENERIC_MAPPING, *PGENERIC_MAPPING;
352
353 #define ACL_REVISION 2
354 #define ACL_REVISION_DS 4
355
356 #define ACL_REVISION1 1
357 #define ACL_REVISION2 2
358 #define ACL_REVISION3 3
359 #define ACL_REVISION4 4
360 #define MIN_ACL_REVISION ACL_REVISION2
361 #define MAX_ACL_REVISION ACL_REVISION4
362
363 typedef struct _ACL {
364 UCHAR AclRevision;
365 UCHAR Sbz1;
366 USHORT AclSize;
367 USHORT AceCount;
368 USHORT Sbz2;
369 } ACL, *PACL;
370
371
372
373 //
374 // Current security descriptor revision value
375 //
376 #define SECURITY_DESCRIPTOR_REVISION (1)
377 #define SECURITY_DESCRIPTOR_REVISION1 (1)
378
379 //
380 // Privilege attributes
381 //
382 #define SE_PRIVILEGE_ENABLED_BY_DEFAULT (0x00000001L)
383 #define SE_PRIVILEGE_ENABLED (0x00000002L)
384 #define SE_PRIVILEGE_REMOVED (0X00000004L)
385 #define SE_PRIVILEGE_USED_FOR_ACCESS (0x80000000L)
386
387 #define SE_PRIVILEGE_VALID_ATTRIBUTES (SE_PRIVILEGE_ENABLED_BY_DEFAULT | \
388 SE_PRIVILEGE_ENABLED | \
389 SE_PRIVILEGE_REMOVED | \
390 SE_PRIVILEGE_USED_FOR_ACCESS)
391
392 #include <pshpack4.h>
393 typedef struct _LUID_AND_ATTRIBUTES {
394 LUID Luid;
395 ULONG Attributes;
396 } LUID_AND_ATTRIBUTES, *PLUID_AND_ATTRIBUTES;
397 #include <poppack.h>
398 typedef LUID_AND_ATTRIBUTES LUID_AND_ATTRIBUTES_ARRAY[ANYSIZE_ARRAY];
399 typedef LUID_AND_ATTRIBUTES_ARRAY *PLUID_AND_ATTRIBUTES_ARRAY;
400
401
402
403 //
404 // Privilege sets
405 //
406 #define PRIVILEGE_SET_ALL_NECESSARY (1)
407
408 typedef struct _PRIVILEGE_SET {
409 ULONG PrivilegeCount;
410 ULONG Control;
411 LUID_AND_ATTRIBUTES Privilege[ANYSIZE_ARRAY];
412 } PRIVILEGE_SET,*PPRIVILEGE_SET;
413
414 typedef enum _SECURITY_IMPERSONATION_LEVEL {
415 SecurityAnonymous,
416 SecurityIdentification,
417 SecurityImpersonation,
418 SecurityDelegation
419 } SECURITY_IMPERSONATION_LEVEL, * PSECURITY_IMPERSONATION_LEVEL;
420
421 #define SECURITY_MAX_IMPERSONATION_LEVEL SecurityDelegation
422 #define SECURITY_MIN_IMPERSONATION_LEVEL SecurityAnonymous
423 #define DEFAULT_IMPERSONATION_LEVEL SecurityImpersonation
424 #define VALID_IMPERSONATION_LEVEL(Level) (((Level) >= SECURITY_MIN_IMPERSONATION_LEVEL) && ((Level) <= SECURITY_MAX_IMPERSONATION_LEVEL))
425
426 #define SECURITY_DYNAMIC_TRACKING (TRUE)
427 #define SECURITY_STATIC_TRACKING (FALSE)
428
429 typedef BOOLEAN SECURITY_CONTEXT_TRACKING_MODE, *PSECURITY_CONTEXT_TRACKING_MODE;
430
431 typedef struct _SECURITY_QUALITY_OF_SERVICE {
432 ULONG Length;
433 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
434 SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode;
435 BOOLEAN EffectiveOnly;
436 } SECURITY_QUALITY_OF_SERVICE, *PSECURITY_QUALITY_OF_SERVICE;
437
438 typedef struct _SE_IMPERSONATION_STATE {
439 PACCESS_TOKEN Token;
440 BOOLEAN CopyOnOpen;
441 BOOLEAN EffectiveOnly;
442 SECURITY_IMPERSONATION_LEVEL Level;
443 } SE_IMPERSONATION_STATE, *PSE_IMPERSONATION_STATE;
444
445 #define OWNER_SECURITY_INFORMATION (0x00000001L)
446 #define GROUP_SECURITY_INFORMATION (0x00000002L)
447 #define DACL_SECURITY_INFORMATION (0x00000004L)
448 #define SACL_SECURITY_INFORMATION (0x00000008L)
449 #define LABEL_SECURITY_INFORMATION (0x00000010L)
450
451 #define PROTECTED_DACL_SECURITY_INFORMATION (0x80000000L)
452 #define PROTECTED_SACL_SECURITY_INFORMATION (0x40000000L)
453 #define UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000L)
454 #define UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000L)
455
456
457
458 //
459 // Registry Access Rights
460 //
461 #define KEY_QUERY_VALUE (0x0001)
462 #define KEY_SET_VALUE (0x0002)
463 #define KEY_CREATE_SUB_KEY (0x0004)
464 #define KEY_ENUMERATE_SUB_KEYS (0x0008)
465 #define KEY_NOTIFY (0x0010)
466 #define KEY_CREATE_LINK (0x0020)
467 #define KEY_WOW64_32KEY (0x0200)
468 #define KEY_WOW64_64KEY (0x0100)
469 #define KEY_WOW64_RES (0x0300)
470
471 #define KEY_READ ((STANDARD_RIGHTS_READ |\
472 KEY_QUERY_VALUE |\
473 KEY_ENUMERATE_SUB_KEYS |\
474 KEY_NOTIFY) \
475 & \
476 (~SYNCHRONIZE))
477
478 #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
479 KEY_SET_VALUE |\
480 KEY_CREATE_SUB_KEY) \
481 & \
482 (~SYNCHRONIZE))
483
484 #define KEY_EXECUTE ((KEY_READ) \
485 & \
486 (~SYNCHRONIZE))
487
488 #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
489 KEY_QUERY_VALUE |\
490 KEY_SET_VALUE |\
491 KEY_CREATE_SUB_KEY |\
492 KEY_ENUMERATE_SUB_KEYS |\
493 KEY_NOTIFY |\
494 KEY_CREATE_LINK) \
495 & \
496 (~SYNCHRONIZE))
497
498 //
499 // Registry Open/Create Options
500 //
501 #define REG_OPTION_RESERVED (0x00000000L)
502 #define REG_OPTION_NON_VOLATILE (0x00000000L)
503 #define REG_OPTION_VOLATILE (0x00000001L)
504 #define REG_OPTION_CREATE_LINK (0x00000002L)
505 #define REG_OPTION_BACKUP_RESTORE (0x00000004L)
506 #define REG_OPTION_OPEN_LINK (0x00000008L)
507
508 #define REG_LEGAL_OPTION \
509 (REG_OPTION_RESERVED |\
510 REG_OPTION_NON_VOLATILE |\
511 REG_OPTION_VOLATILE |\
512 REG_OPTION_CREATE_LINK |\
513 REG_OPTION_BACKUP_RESTORE |\
514 REG_OPTION_OPEN_LINK)
515
516 //
517 // Key creation/open disposition
518 //
519 #define REG_CREATED_NEW_KEY (0x00000001L)
520 #define REG_OPENED_EXISTING_KEY (0x00000002L)
521
522 //
523 // Key restore & hive load flags
524 //
525 #define REG_WHOLE_HIVE_VOLATILE (0x00000001L)
526 #define REG_REFRESH_HIVE (0x00000002L)
527 #define REG_NO_LAZY_FLUSH (0x00000004L)
528 #define REG_FORCE_RESTORE (0x00000008L)
529 #define REG_APP_HIVE (0x00000010L)
530 #define REG_PROCESS_PRIVATE (0x00000020L)
531 #define REG_START_JOURNAL (0x00000040L)
532 #define REG_HIVE_EXACT_FILE_GROWTH (0x00000080L)
533 #define REG_HIVE_NO_RM (0x00000100L)
534 #define REG_HIVE_SINGLE_LOG (0x00000200L)
535
536 //
537 // Unload Flags
538 //
539 #define REG_FORCE_UNLOAD 1
540
541 //
542 // Notify Filter Values
543 //
544 #define REG_NOTIFY_CHANGE_NAME (0x00000001L)
545 #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
546 #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L)
547 #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
548
549 #define REG_LEGAL_CHANGE_FILTER \
550 (REG_NOTIFY_CHANGE_NAME |\
551 REG_NOTIFY_CHANGE_ATTRIBUTES |\
552 REG_NOTIFY_CHANGE_LAST_SET |\
553 REG_NOTIFY_CHANGE_SECURITY)
554
555
556
557 //
558 // Thread Access Rights
559 //
560 #define THREAD_TERMINATE (0x0001)
561 #define THREAD_SUSPEND_RESUME (0x0002)
562 #define THREAD_ALERT (0x0004)
563 #define THREAD_GET_CONTEXT (0x0008)
564 #define THREAD_SET_CONTEXT (0x0010)
565 #define THREAD_SET_INFORMATION (0x0020)
566 #define THREAD_SET_LIMITED_INFORMATION (0x0400)
567 #define THREAD_QUERY_LIMITED_INFORMATION (0x0800)
568 #if (NTDDI_VERSION >= NTDDI_VISTA)
569 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
570 0xFFFF)
571 #else
572 #define THREAD_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
573 0x3FF)
574 #endif
575
576 //
577 // Service Start Types
578 //
579 #define SERVICE_BOOT_START 0x00000000
580 #define SERVICE_SYSTEM_START 0x00000001
581 #define SERVICE_AUTO_START 0x00000002
582 #define SERVICE_DEMAND_START 0x00000003
583 #define SERVICE_DISABLED 0x00000004
584
585
586
587 //
588 // Architecture Defined Contexts
589 //
590 #if defined(_M_IX86)
591 #define SIZE_OF_80387_REGISTERS 80
592 #define CONTEXT_i386 0x10000
593 #define CONTEXT_i486 0x10000
594 #define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
595 #define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
596 #define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
597 #define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
598 #define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
599 #define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
600 #define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
601 #define MAXIMUM_SUPPORTED_EXTENSION 512
602
603 #define EXCEPTION_READ_FAULT 0
604 #define EXCEPTION_WRITE_FAULT 1
605 #define EXCEPTION_EXECUTE_FAULT 8
606
607 typedef struct _FLOATING_SAVE_AREA {
608 ULONG ControlWord;
609 ULONG StatusWord;
610 ULONG TagWord;
611 ULONG ErrorOffset;
612 ULONG ErrorSelector;
613 ULONG DataOffset;
614 ULONG DataSelector;
615 UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
616 ULONG Cr0NpxState;
617 } FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
618
619 typedef struct _CONTEXT {
620 ULONG ContextFlags;
621 ULONG Dr0;
622 ULONG Dr1;
623 ULONG Dr2;
624 ULONG Dr3;
625 ULONG Dr6;
626 ULONG Dr7;
627 FLOATING_SAVE_AREA FloatSave;
628 ULONG SegGs;
629 ULONG SegFs;
630 ULONG SegEs;
631 ULONG SegDs;
632 ULONG Edi;
633 ULONG Esi;
634 ULONG Ebx;
635 ULONG Edx;
636 ULONG Ecx;
637 ULONG Eax;
638 ULONG Ebp;
639 ULONG Eip;
640 ULONG SegCs;
641 ULONG EFlags;
642 ULONG Esp;
643 ULONG SegSs;
644 UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
645 } CONTEXT, *PCONTEXT;
646
647 #elif defined(_M_AMD64)
648 #error FIXME-TODO: 64-bit
649 #elif defined(_M_ARM)
650
651 //
652 // FIXME: Move to armddk.h?
653 //
654
655 /* The following flags control the contents of the CONTEXT structure. */
656
657 #define CONTEXT_ARM 0x0000040
658 #define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
659 #define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
660
661 #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
662
663 typedef struct _CONTEXT {
664 /* The flags values within this flag control the contents of
665 a CONTEXT record.
666
667 If the context record is used as an input parameter, then
668 for each portion of the context record controlled by a flag
669 whose value is set, it is assumed that that portion of the
670 context record contains valid context. If the context record
671 is being used to modify a thread's context, then only that
672 portion of the threads context will be modified.
673
674 If the context record is used as an IN OUT parameter to capture
675 the context of a thread, then only those portions of the thread's
676 context corresponding to set flags will be returned.
677
678 The context record is never used as an OUT only parameter. */
679
680 ULONG ContextFlags;
681
682 /* This section is specified/returned if the ContextFlags word contains
683 the flag CONTEXT_INTEGER. */
684 ULONG R0;
685 ULONG R1;
686 ULONG R2;
687 ULONG R3;
688 ULONG R4;
689 ULONG R5;
690 ULONG R6;
691 ULONG R7;
692 ULONG R8;
693 ULONG R9;
694 ULONG R10;
695 ULONG R11;
696 ULONG R12;
697
698 ULONG Sp;
699 ULONG Lr;
700 ULONG Pc;
701 ULONG Psr;
702 } CONTEXT, *PCONTEXT;
703
704 #else
705 #error "Undefined processor architecture"
706 #endif
707
708
709
710 //
711 // Exception Records
712 //
713 #define EXCEPTION_NONCONTINUABLE 1
714 #define EXCEPTION_MAXIMUM_PARAMETERS 15
715
716 typedef struct _EXCEPTION_RECORD {
717 NTSTATUS ExceptionCode;
718 ULONG ExceptionFlags;
719 struct _EXCEPTION_RECORD *ExceptionRecord;
720 PVOID ExceptionAddress;
721 ULONG NumberParameters;
722 ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
723 } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
724
725 typedef struct _EXCEPTION_RECORD32 {
726 NTSTATUS ExceptionCode;
727 ULONG ExceptionFlags;
728 ULONG ExceptionRecord;
729 ULONG ExceptionAddress;
730 ULONG NumberParameters;
731 ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
732 } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
733
734 typedef struct _EXCEPTION_RECORD64 {
735 NTSTATUS ExceptionCode;
736 ULONG ExceptionFlags;
737 ULONG64 ExceptionRecord;
738 ULONG64 ExceptionAddress;
739 ULONG NumberParameters;
740 ULONG __unusedAlignment;
741 ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
742 } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
743
744 typedef struct _EXCEPTION_POINTERS {
745 PEXCEPTION_RECORD ExceptionRecord;
746 PCONTEXT ContextRecord;
747 } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
748
749
750
751 //
752 // Process Qoutas
753 //
754 typedef struct _QUOTA_LIMITS {
755 SIZE_T PagedPoolLimit;
756 SIZE_T NonPagedPoolLimit;
757 SIZE_T MinimumWorkingSetSize;
758 SIZE_T MaximumWorkingSetSize;
759 SIZE_T PagefileLimit;
760 LARGE_INTEGER TimeLimit;
761 } QUOTA_LIMITS, *PQUOTA_LIMITS;
762
763 #define QUOTA_LIMITS_HARDWS_MIN_ENABLE 0x00000001
764 #define QUOTA_LIMITS_HARDWS_MIN_DISABLE 0x00000002
765 #define QUOTA_LIMITS_HARDWS_MAX_ENABLE 0x00000004
766 #define QUOTA_LIMITS_HARDWS_MAX_DISABLE 0x00000008
767 #define QUOTA_LIMITS_USE_DEFAULT_LIMITS 0x00000010
768
769
770
771 #endif // _WDMDDK_