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