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