[CMAKE]: Use some CMAKE magic to have widl defined as a "host tool", and make the...
[reactos.git] / include / ndk / ketypes.h
1 /*++ NDK Version: 0098
2
3 Copyright (c) Alex Ionescu. All rights reserved.
4
5 Header Name:
6
7 lpctypes.h
8
9 Abstract:
10
11 Type definitions for the Loader.
12
13 Author:
14
15 Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16
17 --*/
18
19 #ifndef _KETYPES_H
20 #define _KETYPES_H
21
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26 #ifndef NTOS_MODE_USER
27 #include <haltypes.h>
28 #include <potypes.h>
29 #include <ifssupp.h>
30 #endif
31
32 //
33 // Context Record Flags
34 //
35 #define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
36
37 //
38 // Maximum System Descriptor Table Entries
39 //
40 #define SSDT_MAX_ENTRIES 2
41
42 //
43 // Processor Architectures
44 //
45 #define PROCESSOR_ARCHITECTURE_INTEL 0
46 #define PROCESSOR_ARCHITECTURE_MIPS 1
47 #define PROCESSOR_ARCHITECTURE_ALPHA 2
48 #define PROCESSOR_ARCHITECTURE_PPC 3
49 #define PROCESSOR_ARCHITECTURE_SHX 4
50 #define PROCESSOR_ARCHITECTURE_ARM 5
51 #define PROCESSOR_ARCHITECTURE_IA64 6
52 #define PROCESSOR_ARCHITECTURE_ALPHA64 7
53 #define PROCESSOR_ARCHITECTURE_MSIL 8
54 #define PROCESSOR_ARCHITECTURE_AMD64 9
55 #define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
56
57 //
58 // Object Type Mask for Kernel Dispatcher Objects
59 //
60 #define KOBJECT_TYPE_MASK 0x7F
61 #define KOBJECT_LOCK_BIT 0x80
62
63 //
64 // Dispatcher Priority increments
65 //
66 #define THREAD_ALERT_INCREMENT 2
67
68 //
69 // Physical memory offset of KUSER_SHARED_DATA
70 //
71 #define KI_USER_SHARED_DATA_PHYSICAL 0x41000
72
73 //
74 // Quantum values and decrements
75 //
76 #define MAX_QUANTUM 0x7F
77 #define WAIT_QUANTUM_DECREMENT 1
78 #define CLOCK_QUANTUM_DECREMENT 3
79
80 //
81 // Kernel Feature Bits
82 //
83 #define KF_V86_VIS 0x00000001
84 #define KF_RDTSC 0x00000002
85 #define KF_CR4 0x00000004
86 #define KF_CMOV 0x00000008
87 #define KF_GLOBAL_PAGE 0x00000010
88 #define KF_LARGE_PAGE 0x00000020
89 #define KF_MTRR 0x00000040
90 #define KF_CMPXCHG8B 0x00000080
91 #define KF_MMX 0x00000100
92 #define KF_WORKING_PTE 0x00000200
93 #define KF_PAT 0x00000400
94 #define KF_FXSR 0x00000800
95 #define KF_FAST_SYSCALL 0x00001000
96 #define KF_XMMI 0x00002000
97 #define KF_3DNOW 0x00004000
98 #define KF_AMDK6MTRR 0x00008000
99 #define KF_XMMI64 0x00010000
100 #define KF_DTS 0x00020000
101 #define KF_NX_BIT 0x20000000
102 #define KF_NX_DISABLED 0x40000000
103 #define KF_NX_ENABLED 0x80000000
104
105 //
106 // Internal Exception Codes
107 //
108 #define KI_EXCEPTION_INTERNAL 0x10000000
109 #define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
110
111 //
112 // Number of dispatch codes supported by KINTERRUPT
113 //
114 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
115 #define KINTERRUPT_DISPATCH_CODES 135
116 #else
117 #define KINTERRUPT_DISPATCH_CODES 106
118 #endif
119
120 #ifdef NTOS_MODE_USER
121
122 //
123 // KPROCESSOR_MODE Type
124 //
125 typedef CCHAR KPROCESSOR_MODE;
126
127 //
128 // Dereferencable pointer to KUSER_SHARED_DATA in User-Mode
129 //
130 #define SharedUserData ((KUSER_SHARED_DATA *CONST)USER_SHARED_DATA)
131
132 //
133 // Maximum WOW64 Entries in KUSER_SHARED_DATA
134 //
135 #define MAX_WOW64_SHARED_ENTRIES 16
136
137 //
138 // Maximum Processor Features supported in KUSER_SHARED_DATA
139 //
140 #define PROCESSOR_FEATURE_MAX 64
141
142 //
143 // Event Types
144 //
145 typedef enum _EVENT_TYPE
146 {
147 NotificationEvent,
148 SynchronizationEvent
149 } EVENT_TYPE;
150
151 //
152 // Timer Types
153 //
154 typedef enum _TIMER_TYPE
155 {
156 NotificationTimer,
157 SynchronizationTimer
158 } TIMER_TYPE;
159
160 //
161 // Wait Types
162 //
163 typedef enum _WAIT_TYPE
164 {
165 WaitAll,
166 WaitAny
167 } WAIT_TYPE;
168
169 //
170 // Processor Execution Modes
171 //
172 typedef enum _MODE
173 {
174 KernelMode,
175 UserMode,
176 MaximumMode
177 } MODE;
178
179 //
180 // Wait Reasons
181 //
182 typedef enum _KWAIT_REASON
183 {
184 Executive,
185 FreePage,
186 PageIn,
187 PoolAllocation,
188 DelayExecution,
189 Suspended,
190 UserRequest,
191 WrExecutive,
192 WrFreePage,
193 WrPageIn,
194 WrPoolAllocation,
195 WrDelayExecution,
196 WrSuspended,
197 WrUserRequest,
198 WrEventPair,
199 WrQueue,
200 WrLpcReceive,
201 WrLpcReply,
202 WrVirtualMemory,
203 WrPageOut,
204 WrRendezvous,
205 Spare2,
206 WrGuardedMutex,
207 Spare4,
208 Spare5,
209 Spare6,
210 WrKernel,
211 WrResource,
212 WrPushLock,
213 WrMutex,
214 WrQuantumEnd,
215 WrDispatchInt,
216 WrPreempted,
217 WrYieldExecution,
218 MaximumWaitReason
219 } KWAIT_REASON;
220
221 //
222 // Profiling Sources
223 //
224 typedef enum _KPROFILE_SOURCE
225 {
226 ProfileTime,
227 ProfileAlignmentFixup,
228 ProfileTotalIssues,
229 ProfilePipelineDry,
230 ProfileLoadInstructions,
231 ProfilePipelineFrozen,
232 ProfileBranchInstructions,
233 ProfileTotalNonissues,
234 ProfileDcacheMisses,
235 ProfileIcacheMisses,
236 ProfileCacheMisses,
237 ProfileBranchMispredictions,
238 ProfileStoreInstructions,
239 ProfileFpInstructions,
240 ProfileIntegerInstructions,
241 Profile2Issue,
242 Profile3Issue,
243 Profile4Issue,
244 ProfileSpecialInstructions,
245 ProfileTotalCycles,
246 ProfileIcacheIssues,
247 ProfileDcacheAccesses,
248 ProfileMemoryBarrierCycles,
249 ProfileLoadLinkedIssues,
250 ProfileMaximum
251 } KPROFILE_SOURCE;
252
253 //
254 // NT Product and Architecture Types
255 //
256 typedef enum _NT_PRODUCT_TYPE
257 {
258 NtProductWinNt = 1,
259 NtProductLanManNt,
260 NtProductServer
261 } NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
262
263 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
264 {
265 StandardDesign,
266 NEC98x86,
267 EndAlternatives
268 } ALTERNATIVE_ARCHITECTURE_TYPE;
269
270 #endif
271
272 //
273 // Thread States
274 //
275 typedef enum _KTHREAD_STATE
276 {
277 Initialized,
278 Ready,
279 Running,
280 Standby,
281 Terminated,
282 Waiting,
283 Transition,
284 DeferredReady,
285 #if (NTDDI_VERSION >= NTDDI_WS03)
286 GateWait
287 #endif
288 } KTHREAD_STATE, *PKTHREAD_STATE;
289
290 //
291 // Kernel Object Types
292 //
293 typedef enum _KOBJECTS
294 {
295 EventNotificationObject = 0,
296 EventSynchronizationObject = 1,
297 MutantObject = 2,
298 ProcessObject = 3,
299 QueueObject = 4,
300 SemaphoreObject = 5,
301 ThreadObject = 6,
302 GateObject = 7,
303 TimerNotificationObject = 8,
304 TimerSynchronizationObject = 9,
305 Spare2Object = 10,
306 Spare3Object = 11,
307 Spare4Object = 12,
308 Spare5Object = 13,
309 Spare6Object = 14,
310 Spare7Object = 15,
311 Spare8Object = 16,
312 Spare9Object = 17,
313 ApcObject = 18,
314 DpcObject = 19,
315 DeviceQueueObject = 20,
316 EventPairObject = 21,
317 InterruptObject = 22,
318 ProfileObject = 23,
319 ThreadedDpcObject = 24,
320 MaximumKernelObject = 25
321 } KOBJECTS;
322
323 //
324 // Adjust reasons
325 //
326 typedef enum _ADJUST_REASON
327 {
328 AdjustNone = 0,
329 AdjustUnwait = 1,
330 AdjustBoost = 2
331 } ADJUST_REASON;
332
333 //
334 // Continue Status
335 //
336 typedef enum _KCONTINUE_STATUS
337 {
338 ContinueError = 0,
339 ContinueSuccess,
340 ContinueProcessorReselected,
341 ContinueNextProcessor
342 } KCONTINUE_STATUS;
343
344 //
345 // Process States
346 //
347 typedef enum _KPROCESS_STATE
348 {
349 ProcessInMemory,
350 ProcessOutOfMemory,
351 ProcessInTransition,
352 ProcessInSwap,
353 ProcessOutSwap,
354 } KPROCESS_STATE, *PKPROCESS_STATE;
355
356 //
357 // NtVdmControl Classes
358 //
359 typedef enum _VDMSERVICECLASS
360 {
361 VdmStartExecution = 0,
362 VdmQueueInterrupt = 1,
363 VdmDelayInterrupt = 2,
364 VdmInitialize = 3,
365 VdmFeatures = 4,
366 VdmSetInt21Handler = 5,
367 VdmQueryDir = 6,
368 VdmPrinterDirectIoOpen = 7,
369 VdmPrinterDirectIoClose = 8,
370 VdmPrinterInitialize = 9,
371 VdmSetLdtEntries = 10,
372 VdmSetProcessLdtInfo = 11,
373 VdmAdlibEmulation = 12,
374 VdmPMCliControl = 13,
375 VdmQueryVdmProcess = 14,
376 } VDMSERVICECLASS;
377
378 #ifdef NTOS_MODE_USER
379
380 //
381 // APC Normal Routine
382 //
383 typedef VOID
384 (NTAPI *PKNORMAL_ROUTINE)(
385 IN PVOID NormalContext,
386 IN PVOID SystemArgument1,
387 IN PVOID SystemArgument2
388 );
389
390 //
391 // Timer Routine
392 //
393 typedef VOID
394 (NTAPI *PTIMER_APC_ROUTINE)(
395 IN PVOID TimerContext,
396 IN ULONG TimerLowValue,
397 IN LONG TimerHighValue
398 );
399
400 //
401 // System Time Structure
402 //
403 typedef struct _KSYSTEM_TIME
404 {
405 ULONG LowPart;
406 LONG High1Time;
407 LONG High2Time;
408 } KSYSTEM_TIME, *PKSYSTEM_TIME;
409
410 //
411 // Shared Kernel User Data
412 //
413 typedef struct _KUSER_SHARED_DATA
414 {
415 ULONG TickCountLowDeprecated;
416 ULONG TickCountMultiplier;
417 volatile KSYSTEM_TIME InterruptTime;
418 volatile KSYSTEM_TIME SystemTime;
419 volatile KSYSTEM_TIME TimeZoneBias;
420 USHORT ImageNumberLow;
421 USHORT ImageNumberHigh;
422 WCHAR NtSystemRoot[260];
423 ULONG MaxStackTraceDepth;
424 ULONG CryptoExponent;
425 ULONG TimeZoneId;
426 ULONG LargePageMinimum;
427 ULONG Reserved2[7];
428 NT_PRODUCT_TYPE NtProductType;
429 BOOLEAN ProductTypeIsValid;
430 ULONG NtMajorVersion;
431 ULONG NtMinorVersion;
432 BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
433 ULONG Reserved1;
434 ULONG Reserved3;
435 volatile ULONG TimeSlip;
436 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
437 LARGE_INTEGER SystemExpirationDate;
438 ULONG SuiteMask;
439 BOOLEAN KdDebuggerEnabled;
440 #if (NTDDI_VERSION >= NTDDI_WINXPSP2)
441 UCHAR NXSupportPolicy;
442 #endif
443 volatile ULONG ActiveConsoleId;
444 volatile ULONG DismountCount;
445 ULONG ComPlusPackage;
446 ULONG LastSystemRITEventTickCount;
447 ULONG NumberOfPhysicalPages;
448 BOOLEAN SafeBootMode;
449 ULONG TraceLogging;
450 ULONG Fill0;
451 ULONGLONG TestRetInstruction;
452 ULONG SystemCall;
453 ULONG SystemCallReturn;
454 ULONGLONG SystemCallPad[3];
455 union {
456 volatile KSYSTEM_TIME TickCount;
457 volatile ULONG64 TickCountQuad;
458 };
459 ULONG Cookie;
460 #if (NTDDI_VERSION >= NTDDI_WS03)
461 LONGLONG ConsoleSessionForegroundProcessId;
462 ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
463 #endif
464 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
465 USHORT UserModeGlobalLogger[8];
466 ULONG HeapTracingPid[2];
467 ULONG CritSecTracingPid[2];
468 union
469 {
470 ULONG SharedDataFlags;
471 struct
472 {
473 ULONG DbgErrorPortPresent:1;
474 ULONG DbgElevationEnabled:1;
475 ULONG DbgVirtEnabled:1;
476 ULONG DbgInstallerDetectEnabled:1;
477 ULONG SpareBits:28;
478 };
479 };
480 ULONG ImageFileExecutionOptions;
481 KAFFINITY ActiveProcessorAffinity;
482 #endif
483 } KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
484
485 //
486 // VDM Structures
487 //
488 #include "pshpack1.h"
489 typedef struct _VdmVirtualIca
490 {
491 LONG ica_count[8];
492 LONG ica_int_line;
493 LONG ica_cpu_int;
494 USHORT ica_base;
495 USHORT ica_hipiri;
496 USHORT ica_mode;
497 UCHAR ica_master;
498 UCHAR ica_irr;
499 UCHAR ica_isr;
500 UCHAR ica_imr;
501 UCHAR ica_ssr;
502 } VDMVIRTUALICA, *PVDMVIRTUALICA;
503 #include "poppack.h"
504
505 typedef struct _VdmIcaUserData
506 {
507 PVOID pIcaLock;
508 PVDMVIRTUALICA pIcaMaster;
509 PVDMVIRTUALICA pIcaSlave;
510 PULONG pDelayIrq;
511 PULONG pUndelayIrq;
512 PULONG pDelayIret;
513 PULONG pIretHooked;
514 PULONG pAddrIretBopTable;
515 PHANDLE phWowIdleEvent;
516 PLARGE_INTEGER pIcaTimeout;
517 PHANDLE phMainThreadSuspended;
518 } VDMICAUSERDATA, *PVDMICAUSERDATA;
519
520 typedef struct _VDM_INITIALIZE_DATA
521 {
522 PVOID TrapcHandler;
523 PVDMICAUSERDATA IcaUserData;
524 } VDM_INITIALIZE_DATA, *PVDM_INITIALIZE_DATA;
525
526 #else
527
528 //
529 // System Thread Start Routine
530 //
531 typedef
532 VOID
533 (NTAPI *PKSYSTEM_ROUTINE)(
534 PKSTART_ROUTINE StartRoutine,
535 PVOID StartContext
536 );
537
538 //
539 // APC Environment Types
540 //
541 typedef enum _KAPC_ENVIRONMENT
542 {
543 OriginalApcEnvironment,
544 AttachedApcEnvironment,
545 CurrentApcEnvironment,
546 InsertApcEnvironment
547 } KAPC_ENVIRONMENT;
548
549 //
550 // PRCB DPC Data
551 //
552 typedef struct _KDPC_DATA
553 {
554 LIST_ENTRY DpcListHead;
555 ULONG_PTR DpcLock;
556 volatile ULONG DpcQueueDepth;
557 ULONG DpcCount;
558 } KDPC_DATA, *PKDPC_DATA;
559
560 //
561 // Per-Processor Lookaside List
562 //
563 typedef struct _PP_LOOKASIDE_LIST
564 {
565 struct _GENERAL_LOOKASIDE *P;
566 struct _GENERAL_LOOKASIDE *L;
567 } PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST;
568
569 //
570 // Architectural Types
571 //
572 #include <arch/ketypes.h>
573
574 //
575 // Kernel Memory Node
576 //
577 #include <pshpack1.h>
578 typedef struct _KNODE
579 {
580 SLIST_HEADER DeadStackList;
581 SLIST_HEADER PfnDereferenceSListHead;
582 KAFFINITY ProcessorMask;
583 ULONG Color;
584 UCHAR Seed;
585 UCHAR NodeNumber;
586 ULONG Flags;
587 ULONG MmShiftedColor;
588 ULONG FreeCount[2];
589 struct _SINGLE_LIST_ENTRY *PfnDeferredList;
590 } KNODE, *PKNODE;
591 #include <poppack.h>
592
593 //
594 // Kernel Profile Object
595 //
596 typedef struct _KPROFILE
597 {
598 CSHORT Type;
599 CSHORT Size;
600 LIST_ENTRY ProfileListEntry;
601 struct _KPROCESS *Process;
602 PVOID RangeBase;
603 PVOID RangeLimit;
604 ULONG BucketShift;
605 PVOID Buffer;
606 ULONG_PTR Segment;
607 KAFFINITY Affinity;
608 KPROFILE_SOURCE Source;
609 BOOLEAN Started;
610 } KPROFILE, *PKPROFILE;
611
612 //
613 // Kernel Interrupt Object
614 //
615 typedef struct _KINTERRUPT
616 {
617 CSHORT Type;
618 CSHORT Size;
619 LIST_ENTRY InterruptListEntry;
620 PKSERVICE_ROUTINE ServiceRoutine;
621 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
622 PKSERVICE_ROUTINE MessageServiceRoutine;
623 ULONG MessageIndex;
624 #endif
625 PVOID ServiceContext;
626 KSPIN_LOCK SpinLock;
627 ULONG TickCount;
628 PKSPIN_LOCK ActualLock;
629 PKINTERRUPT_ROUTINE DispatchAddress;
630 ULONG Vector;
631 KIRQL Irql;
632 KIRQL SynchronizeIrql;
633 BOOLEAN FloatingSave;
634 BOOLEAN Connected;
635 CCHAR Number;
636 BOOLEAN ShareVector;
637 KINTERRUPT_MODE Mode;
638 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
639 KINTERRUPT_POLARITY Polarity;
640 #endif
641 ULONG ServiceCount;
642 ULONG DispatchCount;
643 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
644 ULONGLONG Rsvd1;
645 #endif
646 ULONG DispatchCode[KINTERRUPT_DISPATCH_CODES];
647 } KINTERRUPT;
648
649 //
650 // Kernel Event Pair Object
651 //
652 typedef struct _KEVENT_PAIR
653 {
654 CSHORT Type;
655 CSHORT Size;
656 KEVENT LowEvent;
657 KEVENT HighEvent;
658 } KEVENT_PAIR, *PKEVENT_PAIR;
659
660 //
661 // Kernel No Execute Options
662 //
663 typedef struct _KEXECUTE_OPTIONS
664 {
665 UCHAR ExecuteDisable:1;
666 UCHAR ExecuteEnable:1;
667 UCHAR DisableThunkEmulation:1;
668 UCHAR Permanent:1;
669 UCHAR ExecuteDispatchEnable:1;
670 UCHAR ImageDispatchEnable:1;
671 UCHAR Spare:2;
672 } KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
673
674 //
675 // Kernel Thread (KTHREAD)
676 //
677 typedef struct _KTHREAD
678 {
679 DISPATCHER_HEADER DispatcherHeader;
680 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
681 ULONGLONG CycleTime;
682 ULONG HighCycleTime;
683 ULONGLONG QuantumTarget;
684 #else
685 LIST_ENTRY MutantListHead;
686 #endif
687 PVOID InitialStack;
688 ULONG_PTR StackLimit;
689 PVOID KernelStack;
690 KSPIN_LOCK ThreadLock;
691 union
692 {
693 KAPC_STATE ApcState;
694 struct
695 {
696 UCHAR ApcStateFill[23];
697 UCHAR ApcQueueable;
698 volatile UCHAR NextProcessor;
699 volatile UCHAR DeferredProcessor;
700 UCHAR AdjustReason;
701 SCHAR AdjustIncrement;
702 };
703 };
704 KSPIN_LOCK ApcQueueLock;
705 ULONG ContextSwitches;
706 volatile UCHAR State;
707 UCHAR NpxState;
708 KIRQL WaitIrql;
709 KPROCESSOR_MODE WaitMode;
710 LONG_PTR WaitStatus;
711 union
712 {
713 PKWAIT_BLOCK WaitBlockList;
714 PKGATE GateObject;
715 };
716 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
717 union
718 {
719 struct
720 {
721 ULONG KernelStackResident:1;
722 ULONG ReadyTransition:1;
723 ULONG ProcessReadyQueue:1;
724 ULONG WaitNext:1;
725 ULONG SystemAffinityActive:1;
726 ULONG Alertable:1;
727 ULONG GdiFlushActive:1;
728 ULONG Reserved:25;
729 };
730 LONG MiscFlags;
731 };
732 #else
733 BOOLEAN Alertable;
734 BOOLEAN WaitNext;
735 #endif
736 UCHAR WaitReason;
737 SCHAR Priority;
738 BOOLEAN EnableStackSwap;
739 volatile UCHAR SwapBusy;
740 BOOLEAN Alerted[MaximumMode];
741 union
742 {
743 LIST_ENTRY WaitListEntry;
744 SINGLE_LIST_ENTRY SwapListEntry;
745 };
746 PKQUEUE Queue;
747 ULONG WaitTime;
748 union
749 {
750 struct
751 {
752 SHORT KernelApcDisable;
753 SHORT SpecialApcDisable;
754 };
755 ULONG CombinedApcDisable;
756 };
757 struct _TEB *Teb;
758 union
759 {
760 KTIMER Timer;
761 struct
762 {
763 UCHAR TimerFill[40];
764 union
765 {
766 struct
767 {
768 LONG AutoAlignment:1;
769 LONG DisableBoost:1;
770 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
771 LONG EtwStackTrace1ApcInserted:1;
772 LONG EtwStackTrace2ApcInserted:1;
773 LONG CycleChargePending:1;
774 LONG ReservedFlags:27;
775 #else
776 LONG ReservedFlags:30;
777 #endif
778 };
779 LONG ThreadFlags;
780 };
781 };
782 };
783 union
784 {
785 KWAIT_BLOCK WaitBlock[THREAD_WAIT_OBJECTS + 1];
786 struct
787 {
788 UCHAR WaitBlockFill0[23];
789 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
790 UCHAR IdealProcessor;
791 #else
792 BOOLEAN SystemAffinityActive;
793 #endif
794 };
795 struct
796 {
797 UCHAR WaitBlockFill1[47];
798 CCHAR PreviousMode;
799 };
800 struct
801 {
802 UCHAR WaitBlockFill2[71];
803 UCHAR ResourceIndex;
804 };
805 struct
806 {
807 UCHAR WaitBlockFill3[95];
808 UCHAR LargeStack;
809 };
810 };
811 LIST_ENTRY QueueListEntry;
812 PKTRAP_FRAME TrapFrame;
813 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
814 PVOID FirstArgument;
815 #endif
816 PVOID CallbackStack;
817 PVOID ServiceTable;
818 UCHAR ApcStateIndex;
819 #if (NTDDI_VERSION < NTDDI_LONGHORN)
820 UCHAR IdealProcessor;
821 #endif
822 BOOLEAN Preempted;
823 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
824 BOOLEAN CalloutActive;
825 #else
826 BOOLEAN ProcessReadyQueue;
827 BOOLEAN KernelStackResident;
828 #endif
829 SCHAR BasePriority;
830 SCHAR PriorityDecrement;
831 CHAR Saturation;
832 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
833 ULONG SystemCallNumber;
834 ULONG Spare2;
835 #endif
836 KAFFINITY UserAffinity;
837 struct _KPROCESS *Process;
838 KAFFINITY Affinity;
839 PKAPC_STATE ApcStatePointer[2];
840 union
841 {
842 KAPC_STATE SavedApcState;
843 struct
844 {
845 UCHAR SavedApcStateFill[23];
846 CCHAR FreezeCount;
847 CCHAR SuspendCount;
848 UCHAR UserIdealProcessor;
849 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
850 union
851 {
852 struct
853 {
854 UCHAR ReservedBits0:1;
855 UCHAR SegmentsPresent:1;
856 UCHAR Reservedbits1:1;
857 };
858 UCHAR NestedStateFlags;
859 };
860 #else
861 UCHAR CalloutActive;
862 #endif
863 UCHAR Iopl;
864 };
865 };
866 PVOID Win32Thread;
867 PVOID StackBase;
868 union
869 {
870 KAPC SuspendApc;
871 struct
872 {
873 UCHAR SuspendApcFill0[1];
874 SCHAR Quantum;
875 };
876 struct
877 {
878 UCHAR SuspendApcFill1[3];
879 UCHAR QuantumReset;
880 };
881 struct
882 {
883 UCHAR SuspendApcFill2[4];
884 ULONG KernelTime;
885 };
886 struct
887 {
888 UCHAR SuspendApcFill3[36];
889 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
890 PKPRCB WaitPrcb;
891 #else
892 PVOID TlsArray;
893 #endif
894 };
895 struct
896 {
897 UCHAR SuspendApcFill4[40];
898 PVOID LegoData;
899 };
900 struct
901 {
902 UCHAR SuspendApcFill5[47];
903 UCHAR PowerState;
904 ULONG UserTime;
905 };
906 };
907 union
908 {
909 KSEMAPHORE SuspendSemaphore;
910 struct
911 {
912 UCHAR SuspendSemaphorefill[20];
913 ULONG SListFaultCount;
914 };
915 };
916 LIST_ENTRY ThreadListEntry;
917 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
918 LIST_ENTRY MutantListHead;
919 #endif
920 PVOID SListFaultAddress;
921 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
922 PVOID MdlForLockedteb;
923 #endif
924 } KTHREAD;
925
926 #define ASSERT_THREAD(object) \
927 ASSERT((((object)->DispatcherHeader.Type & KOBJECT_TYPE_MASK) == ThreadObject))
928
929 //
930 // Kernel Process (KPROCESS)
931 //
932 typedef struct _KPROCESS
933 {
934 DISPATCHER_HEADER Header;
935 LIST_ENTRY ProfileListHead;
936 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
937 ULONG DirectoryTableBase;
938 ULONG Unused0;
939 #else
940 ULONG DirectoryTableBase[2];
941 #endif
942 #if defined(_M_IX86)
943 KGDTENTRY LdtDescriptor;
944 KIDTENTRY Int21Descriptor;
945 USHORT IopmOffset;
946 UCHAR Iopl;
947 UCHAR Unused;
948 #endif
949 volatile ULONG ActiveProcessors;
950 ULONG KernelTime;
951 ULONG UserTime;
952 LIST_ENTRY ReadyListHead;
953 SINGLE_LIST_ENTRY SwapListEntry;
954 PVOID VdmTrapcHandler;
955 LIST_ENTRY ThreadListHead;
956 KSPIN_LOCK ProcessLock;
957 KAFFINITY Affinity;
958 union
959 {
960 struct
961 {
962 LONG AutoAlignment:1;
963 LONG DisableBoost:1;
964 LONG DisableQuantum:1;
965 LONG ReservedFlags:29;
966 };
967 LONG ProcessFlags;
968 };
969 SCHAR BasePriority;
970 SCHAR QuantumReset;
971 UCHAR State;
972 UCHAR ThreadSeed;
973 UCHAR PowerState;
974 UCHAR IdealNode;
975 UCHAR Visited;
976 union
977 {
978 KEXECUTE_OPTIONS Flags;
979 UCHAR ExecuteOptions;
980 };
981 ULONG StackCount;
982 LIST_ENTRY ProcessListEntry;
983 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
984 ULONGLONG CycleTime;
985 #endif
986 } KPROCESS;
987
988 #define ASSERT_PROCESS(object) \
989 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ProcessObject))
990
991 //
992 // System Service Table Descriptor
993 //
994 typedef struct _KSERVICE_TABLE_DESCRIPTOR
995 {
996 PULONG_PTR Base;
997 PULONG Count;
998 ULONG Limit;
999 #if defined(_IA64_)
1000 LONG TableBaseGpOffset;
1001 #endif
1002 PUCHAR Number;
1003 } KSERVICE_TABLE_DESCRIPTOR, *PKSERVICE_TABLE_DESCRIPTOR;
1004
1005 //
1006 // Exported Loader Parameter Block
1007 //
1008 extern struct _LOADER_PARAMETER_BLOCK NTSYSAPI *KeLoaderBlock;
1009
1010 //
1011 // Exported Hardware Data
1012 //
1013 extern KAFFINITY NTSYSAPI KeActiveProcessors;
1014 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
1015 extern volatile CCHAR NTSYSAPI KeNumberProcessors;
1016 #else
1017 #if (NTDDI_VERSION >= NTDDI_WINXP)
1018 extern CCHAR NTSYSAPI KeNumberProcessors;
1019 #else
1020 //extern PCCHAR KeNumberProcessors;
1021 extern NTSYSAPI CCHAR KeNumberProcessors; //FIXME: Note to Alex: I won't fix this atm, since I prefer to discuss this with you first.
1022 #endif
1023 #endif
1024 extern ULONG NTSYSAPI KiDmaIoCoherency;
1025 extern ULONG NTSYSAPI KeMaximumIncrement;
1026 extern ULONG NTSYSAPI KeMinimumIncrement;
1027 extern ULONG NTSYSAPI KeDcacheFlushCount;
1028 extern ULONG NTSYSAPI KeIcacheFlushCount;
1029
1030 //
1031 // Exported System Service Descriptor Tables
1032 //
1033 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTable[SSDT_MAX_ENTRIES];
1034 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES];
1035
1036 #endif // !NTOS_MODE_USER
1037
1038 #endif // _KETYPES_H