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