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