A couple of header fixes to get all the FreeLDR-loaded boot drivers to compile and...
[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 // User Shared Data in Kernel-Mode
60 //
61 #define KI_USER_SHARED_DATA 0xffdf0000
62
63 //
64 // Physical memory offset of KUSER_SHARED_DATA
65 //
66 #define KI_USER_SHARED_DATA_PHYSICAL 0x41000
67
68 //
69 // Quantum values and decrements
70 //
71 #define MAX_QUANTUM 0x7F
72 #define WAIT_QUANTUM_DECREMENT 1
73 #define CLOCK_QUANTUM_DECREMENT 3
74
75 //
76 // Kernel Feature Bits
77 //
78 #define KF_V86_VIS 0x00000001
79 #define KF_RDTSC 0x00000002
80 #define KF_CR4 0x00000004
81 #define KF_CMOV 0x00000008
82 #define KF_GLOBAL_PAGE 0x00000010
83 #define KF_LARGE_PAGE 0x00000020
84 #define KF_MTRR 0x00000040
85 #define KF_CMPXCHG8B 0x00000080
86 #define KF_MMX 0x00000100
87 #define KF_WORKING_PTE 0x00000200
88 #define KF_PAT 0x00000400
89 #define KF_FXSR 0x00000800
90 #define KF_FAST_SYSCALL 0x00001000
91 #define KF_XMMI 0x00002000
92 #define KF_3DNOW 0x00004000
93 #define KF_AMDK6MTRR 0x00008000
94 #define KF_XMMI64 0x00010000
95 #define KF_DTS 0x00020000
96 #define KF_NX_BIT 0x20000000
97 #define KF_NX_DISABLED 0x40000000
98 #define KF_NX_ENABLED 0x80000000
99
100 //
101 // Internal Exception Codes
102 //
103 #define KI_EXCEPTION_INTERNAL 0x10000000
104 #define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
105
106 //
107 // Number of dispatch codes supported by KINTERRUPT
108 //
109 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
110 #define KINTERRUPT_DISPATCH_CODES 135
111 #else
112 #define KINTERRUPT_DISPATCH_CODES 106
113 #endif
114
115 //
116 // Get KPCR
117 //
118 #define KeGetPcr() PCR
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 // CPU Cache Types
551 //
552 typedef enum _PROCESSOR_CACHE_TYPE
553 {
554 CacheUnified,
555 CacheInstruction,
556 CacheData,
557 CacheTrace,
558 } PROCESSOR_CACHE_TYPE;
559
560 //
561 // PRCB DPC Data
562 //
563 typedef struct _KDPC_DATA
564 {
565 LIST_ENTRY DpcListHead;
566 ULONG DpcLock;
567 volatile ULONG DpcQueueDepth;
568 ULONG DpcCount;
569 } KDPC_DATA, *PKDPC_DATA;
570
571 //
572 // Per-Processor Lookaside List
573 //
574 typedef struct _PP_LOOKASIDE_LIST
575 {
576 struct _GENERAL_LOOKASIDE *P;
577 struct _GENERAL_LOOKASIDE *L;
578 } PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST;
579
580 //
581 // CPU Cache Descriptor
582 //
583 typedef struct _CACHE_DESCRIPTOR
584 {
585 UCHAR Level;
586 UCHAR Associativity;
587 USHORT LineSize;
588 ULONG Size;
589 PROCESSOR_CACHE_TYPE Type;
590 } CACHE_DESCRIPTOR, *PCACHE_DESCRIPTOR;
591
592 //
593 // Architectural Types
594 //
595 #include <arch/ketypes.h>
596
597 //
598 // Kernel Memory Node
599 //
600 #include <pshpack1.h>
601 typedef struct _KNODE
602 {
603 SLIST_HEADER DeadStackList;
604 SLIST_HEADER PfnDereferenceSListHead;
605 KAFFINITY ProcessorMask;
606 ULONG Color;
607 UCHAR Seed;
608 UCHAR NodeNumber;
609 ULONG Flags;
610 ULONG MmShiftedColor;
611 ULONG FreeCount[2];
612 struct _SINGLE_LIST_ENTRY *PfnDeferredList;
613 } KNODE, *PKNODE;
614 #include <poppack.h>
615
616 //
617 // Kernel Profile Object
618 //
619 typedef struct _KPROFILE
620 {
621 CSHORT Type;
622 CSHORT Size;
623 LIST_ENTRY ProfileListEntry;
624 struct _KPROCESS *Process;
625 PVOID RangeBase;
626 PVOID RangeLimit;
627 ULONG BucketShift;
628 PVOID Buffer;
629 ULONG Segment;
630 KAFFINITY Affinity;
631 KPROFILE_SOURCE Source;
632 BOOLEAN Started;
633 } KPROFILE, *PKPROFILE;
634
635 //
636 // Kernel Interrupt Object
637 //
638 typedef struct _KINTERRUPT
639 {
640 CSHORT Type;
641 CSHORT Size;
642 LIST_ENTRY InterruptListEntry;
643 PKSERVICE_ROUTINE ServiceRoutine;
644 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
645 PKSERVICE_ROUTINE MessageServiceRoutine;
646 ULONG MessageIndex;
647 #endif
648 PVOID ServiceContext;
649 KSPIN_LOCK SpinLock;
650 ULONG TickCount;
651 PKSPIN_LOCK ActualLock;
652 PKINTERRUPT_ROUTINE DispatchAddress;
653 ULONG Vector;
654 KIRQL Irql;
655 KIRQL SynchronizeIrql;
656 BOOLEAN FloatingSave;
657 BOOLEAN Connected;
658 CCHAR Number;
659 BOOLEAN ShareVector;
660 KINTERRUPT_MODE Mode;
661 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
662 KINTERRUPT_POLARITY Polarity;
663 #endif
664 ULONG ServiceCount;
665 ULONG DispatchCount;
666 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
667 ULONGLONG Rsvd1;
668 #endif
669 ULONG DispatchCode[KINTERRUPT_DISPATCH_CODES];
670 } KINTERRUPT, *PKINTERRUPT;
671
672 //
673 // Kernel Event Pair Object
674 //
675 typedef struct _KEVENT_PAIR
676 {
677 CSHORT Type;
678 CSHORT Size;
679 KEVENT LowEvent;
680 KEVENT HighEvent;
681 } KEVENT_PAIR, *PKEVENT_PAIR;
682
683 //
684 // Kernel No Execute Options
685 //
686 typedef struct _KEXECUTE_OPTIONS
687 {
688 UCHAR ExecuteDisable:1;
689 UCHAR ExecuteEnable:1;
690 UCHAR DisableThunkEmulation:1;
691 UCHAR Permanent:1;
692 UCHAR ExecuteDispatchEnable:1;
693 UCHAR ImageDispatchEnable:1;
694 UCHAR Spare:2;
695 } KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
696
697 //
698 // Kernel Thread (KTHREAD)
699 //
700 typedef struct _KTHREAD
701 {
702 DISPATCHER_HEADER DispatcherHeader;
703 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
704 ULONGLONG CycleTime;
705 ULONG HighCycleTime;
706 ULONGLONG QuantumTarget;
707 #else
708 LIST_ENTRY MutantListHead;
709 #endif
710 PVOID InitialStack;
711 ULONG_PTR StackLimit;
712 PVOID KernelStack;
713 KSPIN_LOCK ThreadLock;
714 union
715 {
716 KAPC_STATE ApcState;
717 struct
718 {
719 UCHAR ApcStateFill[23];
720 UCHAR ApcQueueable;
721 volatile UCHAR NextProcessor;
722 volatile UCHAR DeferredProcessor;
723 UCHAR AdjustReason;
724 SCHAR AdjustIncrement;
725 };
726 };
727 KSPIN_LOCK ApcQueueLock;
728 ULONG ContextSwitches;
729 volatile UCHAR State;
730 UCHAR NpxState;
731 KIRQL WaitIrql;
732 KPROCESSOR_MODE WaitMode;
733 LONG_PTR WaitStatus;
734 union
735 {
736 PKWAIT_BLOCK WaitBlockList;
737 PKGATE GateObject;
738 };
739 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
740 union
741 {
742 struct
743 {
744 ULONG KernelStackResident:1;
745 ULONG ReadyTransition:1;
746 ULONG ProcessReadyQueue:1;
747 ULONG WaitNext:1;
748 ULONG SystemAffinityActive:1;
749 ULONG Alertable:1;
750 ULONG GdiFlushActive:1;
751 ULONG Reserved:25;
752 };
753 LONG MiscFlags;
754 };
755 #else
756 BOOLEAN Alertable;
757 BOOLEAN WaitNext;
758 #endif
759 UCHAR WaitReason;
760 SCHAR Priority;
761 BOOLEAN EnableStackSwap;
762 volatile UCHAR SwapBusy;
763 BOOLEAN Alerted[MaximumMode];
764 union
765 {
766 LIST_ENTRY WaitListEntry;
767 SINGLE_LIST_ENTRY SwapListEntry;
768 };
769 PKQUEUE Queue;
770 ULONG WaitTime;
771 union
772 {
773 struct
774 {
775 SHORT KernelApcDisable;
776 SHORT SpecialApcDisable;
777 };
778 ULONG CombinedApcDisable;
779 };
780 struct _TEB *Teb;
781 union
782 {
783 KTIMER Timer;
784 struct
785 {
786 UCHAR TimerFill[40];
787 union
788 {
789 struct
790 {
791 LONG AutoAlignment:1;
792 LONG DisableBoost:1;
793 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
794 LONG EtwStackTrace1ApcInserted:1;
795 LONG EtwStackTrace2ApcInserted:1;
796 LONG CycleChargePending:1;
797 LONG ReservedFlags:27;
798 #else
799 LONG ReservedFlags:30;
800 #endif
801 };
802 LONG ThreadFlags;
803 };
804 };
805 };
806 union
807 {
808 KWAIT_BLOCK WaitBlock[THREAD_WAIT_OBJECTS + 1];
809 struct
810 {
811 UCHAR WaitBlockFill0[23];
812 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
813 UCHAR IdealProcessor;
814 #else
815 BOOLEAN SystemAffinityActive;
816 #endif
817 };
818 struct
819 {
820 UCHAR WaitBlockFill1[47];
821 CCHAR PreviousMode;
822 };
823 struct
824 {
825 UCHAR WaitBlockFill2[71];
826 UCHAR ResourceIndex;
827 };
828 struct
829 {
830 UCHAR WaitBlockFill3[95];
831 UCHAR LargeStack;
832 };
833 };
834 LIST_ENTRY QueueListEntry;
835 PKTRAP_FRAME TrapFrame;
836 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
837 PVOID FirstArgument;
838 #endif
839 PVOID CallbackStack;
840 PVOID ServiceTable;
841 UCHAR ApcStateIndex;
842 #if (NTDDI_VERSION < NTDDI_LONGHORN)
843 UCHAR IdealProcessor;
844 #endif
845 BOOLEAN Preempted;
846 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
847 BOOLEAN CalloutActive;
848 #else
849 BOOLEAN ProcessReadyQueue;
850 BOOLEAN KernelStackResident;
851 #endif
852 SCHAR BasePriority;
853 SCHAR PriorityDecrement;
854 CHAR Saturation;
855 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
856 ULONG SystemCallNumber;
857 ULONG Spare2;
858 #endif
859 KAFFINITY UserAffinity;
860 struct _KPROCESS *Process;
861 KAFFINITY Affinity;
862 PKAPC_STATE ApcStatePointer[2];
863 union
864 {
865 KAPC_STATE SavedApcState;
866 struct
867 {
868 UCHAR SavedApcStateFill[23];
869 CCHAR FreezeCount;
870 CCHAR SuspendCount;
871 UCHAR UserIdealProcessor;
872 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
873 union
874 {
875 struct
876 {
877 UCHAR ReservedBits0:1;
878 UCHAR SegmentsPresent:1;
879 UCHAR Reservedbits1:1;
880 };
881 UCHAR NestedStateFlags;
882 };
883 #else
884 UCHAR CalloutActive;
885 #endif
886 UCHAR Iopl;
887 };
888 };
889 PVOID Win32Thread;
890 PVOID StackBase;
891 union
892 {
893 KAPC SuspendApc;
894 struct
895 {
896 UCHAR SuspendApcFill0[1];
897 SCHAR Quantum;
898 };
899 struct
900 {
901 UCHAR SuspendApcFill1[3];
902 UCHAR QuantumReset;
903 };
904 struct
905 {
906 UCHAR SuspendApcFill2[4];
907 ULONG KernelTime;
908 };
909 struct
910 {
911 UCHAR SuspendApcFill3[36];
912 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
913 PKPRCB WaitPrcb;
914 #else
915 PVOID TlsArray;
916 #endif
917 };
918 struct
919 {
920 UCHAR SuspendApcFill4[40];
921 PVOID LegoData;
922 };
923 struct
924 {
925 UCHAR SuspendApcFill5[47];
926 UCHAR PowerState;
927 ULONG UserTime;
928 };
929 };
930 union
931 {
932 KSEMAPHORE SuspendSemaphore;
933 struct
934 {
935 UCHAR SuspendSemaphorefill[20];
936 ULONG SListFaultCount;
937 };
938 };
939 LIST_ENTRY ThreadListEntry;
940 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
941 LIST_ENTRY MutantListHead;
942 #endif
943 PVOID SListFaultAddress;
944 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
945 PVOID MdlForLockedteb;
946 #endif
947 } KTHREAD, *PKTHREAD;
948
949 #define ASSERT_THREAD(object) \
950 ASSERT((((object)->DispatcherHeader.Type & KOBJECT_TYPE_MASK) == ThreadObject))
951
952 //
953 // Kernel Process (KPROCESS)
954 //
955 typedef struct _KPROCESS
956 {
957 DISPATCHER_HEADER Header;
958 LIST_ENTRY ProfileListHead;
959 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
960 ULONG DirectoryTableBase;
961 ULONG Unused0;
962 #else
963 LARGE_INTEGER DirectoryTableBase;
964 #endif
965 #if defined(_M_IX86)
966 KGDTENTRY LdtDescriptor;
967 KIDTENTRY Int21Descriptor;
968 USHORT IopmOffset;
969 UCHAR Iopl;
970 UCHAR Unused;
971 #endif
972 volatile ULONG ActiveProcessors;
973 ULONG KernelTime;
974 ULONG UserTime;
975 LIST_ENTRY ReadyListHead;
976 SINGLE_LIST_ENTRY SwapListEntry;
977 PVOID VdmTrapcHandler;
978 LIST_ENTRY ThreadListHead;
979 KSPIN_LOCK ProcessLock;
980 KAFFINITY Affinity;
981 union
982 {
983 struct
984 {
985 LONG AutoAlignment:1;
986 LONG DisableBoost:1;
987 LONG DisableQuantum:1;
988 LONG ReservedFlags:29;
989 };
990 LONG ProcessFlags;
991 };
992 SCHAR BasePriority;
993 SCHAR QuantumReset;
994 UCHAR State;
995 UCHAR ThreadSeed;
996 UCHAR PowerState;
997 UCHAR IdealNode;
998 UCHAR Visited;
999 union
1000 {
1001 KEXECUTE_OPTIONS Flags;
1002 UCHAR ExecuteOptions;
1003 };
1004 ULONG StackCount;
1005 LIST_ENTRY ProcessListEntry;
1006 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
1007 ULONGLONG CycleTime;
1008 #endif
1009 } KPROCESS, *PKPROCESS;
1010
1011 #define ASSERT_PROCESS(object) \
1012 ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ProcessObject))
1013
1014 //
1015 // System Service Table Descriptor
1016 //
1017 typedef struct _KSERVICE_TABLE_DESCRIPTOR
1018 {
1019 PULONG_PTR Base;
1020 PULONG Count;
1021 ULONG Limit;
1022 #if defined(_IA64_)
1023 LONG TableBaseGpOffset;
1024 #endif
1025 PUCHAR Number;
1026 } KSERVICE_TABLE_DESCRIPTOR, *PKSERVICE_TABLE_DESCRIPTOR;
1027
1028 //
1029 // Exported Loader Parameter Block
1030 //
1031 extern struct _LOADER_PARAMETER_BLOCK NTSYSAPI *KeLoaderBlock;
1032
1033 //
1034 // Exported Hardware Data
1035 //
1036 extern KAFFINITY NTSYSAPI KeActiveProcessors;
1037 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
1038 extern volatile CCHAR NTSYSAPI KeNumberProcessors;
1039 #else
1040 #if (NTDDI_VERSION >= NTDDI_WINXP)
1041 extern CCHAR NTSYSAPI KeNumberProcessors;
1042 #else
1043 //extern PCCHAR KeNumberProcessors;
1044 extern NTSYSAPI CCHAR KeNumberProcessors; //FIXME: Note to Alex: I won't fix this atm, since I prefer to discuss this with you first.
1045 #endif
1046 #endif
1047 extern ULONG NTSYSAPI KiDmaIoCoherency;
1048 extern ULONG NTSYSAPI KeMaximumIncrement;
1049 extern ULONG NTSYSAPI KeMinimumIncrement;
1050 extern ULONG NTSYSAPI KeDcacheFlushCount;
1051 extern ULONG NTSYSAPI KeIcacheFlushCount;
1052
1053 //
1054 // Exported System Service Descriptor Tables
1055 //
1056 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTable[SSDT_MAX_ENTRIES];
1057 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES];
1058
1059 #endif // !NTOS_MODE_USER
1060
1061 #endif // _KETYPES_H