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