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