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