Add a nice little KIDT_ACCESS structure for setting IDT entries in a pretty way
[reactos.git] / reactos / include / ndk / ketypes.h
1 /*
2 * PROJECT: ReactOS Native Headers
3 * FILE: include/ndk/ketypes.h
4 * PURPOSE: Definitions for Kernel Types not defined in DDK/IFS
5 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
6 * UPDATE HISTORY:
7 * Created 06/10/04
8 */
9 #ifndef _KETYPES_H
10 #define _KETYPES_H
11
12 /* DEPENDENCIES **************************************************************/
13 #include "haltypes.h"
14 #include "potypes.h"
15 #include "mmtypes.h"
16 #include <arc/arc.h>
17
18 /* CONSTANTS *****************************************************************/
19 #define SSDT_MAX_ENTRIES 4
20 #define PROCESSOR_FEATURE_MAX 64
21
22 #define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
23
24 #define THREAD_WAIT_OBJECTS 4
25
26 /* X86 80386 Segment Types */
27 #define I386_TSS 0x9
28 #define I386_ACTIVE_TSS 0xB
29 #define I386_CALL_GATE 0xC
30 #define I386_INTERRUPT_GATE 0xE
31 #define I386_TRAP_GATE 0xF
32
33 /* EXPORTED DATA *************************************************************/
34 extern CHAR NTOSAPI KeNumberProcessors;
35 extern LOADER_PARAMETER_BLOCK NTOSAPI KeLoaderBlock;
36 extern ULONG NTOSAPI KeDcacheFlushCount;
37 extern ULONG NTOSAPI KeIcacheFlushCount;
38 extern KAFFINITY NTOSAPI KeActiveProcessors;
39 extern ULONG NTOSAPI KiDmaIoCoherency; /* RISC Architectures only */
40 extern ULONG NTOSAPI KeMaximumIncrement;
41 extern ULONG NTOSAPI KeMinimumIncrement;
42 extern ULONG NTOSAPI NtBuildNumber;
43 extern SSDT_ENTRY NTOSAPI KeServiceDescriptorTable[SSDT_MAX_ENTRIES];
44 extern SSDT_ENTRY NTOSAPI KeServiceDescriptorTableShadow[SSDT_MAX_ENTRIES];
45
46 /* ENUMERATIONS **************************************************************/
47
48 /* TYPES *********************************************************************/
49
50 typedef struct _CONFIGURATION_COMPONENT_DATA
51 {
52 struct _CONFIGURATION_COMPONENT_DATA *Parent;
53 struct _CONFIGURATION_COMPONENT_DATA *Child;
54 struct _CONFIGURATION_COMPONENT_DATA *Sibling;
55 CONFIGURATION_COMPONENT Component;
56 } CONFIGURATION_COMPONENT_DATA, *PCONFIGURATION_COMPONENT_DATA;
57
58 typedef enum _KAPC_ENVIRONMENT
59 {
60 OriginalApcEnvironment,
61 AttachedApcEnvironment,
62 CurrentApcEnvironment
63 } KAPC_ENVIRONMENT;
64
65 typedef struct _KDPC_DATA
66 {
67 LIST_ENTRY DpcListHead;
68 ULONG DpcLock;
69 ULONG DpcQueueDepth;
70 ULONG DpcCount;
71 } KDPC_DATA, *PKDPC_DATA;
72
73 /* We don't want to force NTIFS usage only for a single structure */
74 #ifndef _NTIFS_
75 typedef struct _KAPC_STATE
76 {
77 LIST_ENTRY ApcListHead[2];
78 PKPROCESS Process;
79 BOOLEAN KernelApcInProgress;
80 BOOLEAN KernelApcPending;
81 BOOLEAN UserApcPending;
82 } KAPC_STATE, *PKAPC_STATE, *RESTRICTED_POINTER PRKAPC_STATE;
83 #endif
84
85 /* FIXME: Most of these should go to i386 directory */
86 typedef struct _FNSAVE_FORMAT
87 {
88 ULONG ControlWord;
89 ULONG StatusWord;
90 ULONG TagWord;
91 ULONG ErrorOffset;
92 ULONG ErrorSelector;
93 ULONG DataOffset;
94 ULONG DataSelector;
95 UCHAR RegisterArea[80];
96 } FNSAVE_FORMAT, *PFNSAVE_FORMAT;
97
98 typedef struct _FXSAVE_FORMAT
99 {
100 USHORT ControlWord;
101 USHORT StatusWord;
102 USHORT TagWord;
103 USHORT ErrorOpcode;
104 ULONG ErrorOffset;
105 ULONG ErrorSelector;
106 ULONG DataOffset;
107 ULONG DataSelector;
108 ULONG MXCsr;
109 ULONG MXCsrMask;
110 UCHAR RegisterArea[128];
111 UCHAR Reserved3[128];
112 UCHAR Reserved4[224];
113 UCHAR Align16Byte[8];
114 } FXSAVE_FORMAT, *PFXSAVE_FORMAT;
115
116 typedef struct _FX_SAVE_AREA
117 {
118 union
119 {
120 FNSAVE_FORMAT FnArea;
121 FXSAVE_FORMAT FxArea;
122 } U;
123 ULONG NpxSavedCpu;
124 ULONG Cr0NpxState;
125 } FX_SAVE_AREA, *PFX_SAVE_AREA;
126
127 typedef struct _KTRAP_FRAME
128 {
129 PVOID DebugEbp;
130 PVOID DebugEip;
131 PVOID DebugArgMark;
132 PVOID DebugPointer;
133 PVOID TempCs;
134 PVOID TempEip;
135 ULONG Dr0;
136 ULONG Dr1;
137 ULONG Dr2;
138 ULONG Dr3;
139 ULONG Dr6;
140 ULONG Dr7;
141 USHORT Gs;
142 USHORT Reserved1;
143 USHORT Es;
144 USHORT Reserved2;
145 USHORT Ds;
146 USHORT Reserved3;
147 ULONG Edx;
148 ULONG Ecx;
149 ULONG Eax;
150 ULONG PreviousMode;
151 PVOID ExceptionList;
152 USHORT Fs;
153 USHORT Reserved4;
154 ULONG Edi;
155 ULONG Esi;
156 ULONG Ebx;
157 ULONG Ebp;
158 ULONG ErrorCode;
159 ULONG Eip;
160 ULONG Cs;
161 ULONG Eflags;
162 ULONG Esp;
163 USHORT Ss;
164 USHORT Reserved5;
165 USHORT V86_Es;
166 USHORT Reserved6;
167 USHORT V86_Ds;
168 USHORT Reserved7;
169 USHORT V86_Fs;
170 USHORT Reserved8;
171 USHORT V86_Gs;
172 USHORT Reserved9;
173 } KTRAP_FRAME, *PKTRAP_FRAME;
174
175 /* FIXME: Win32k uses windows.h! */
176 #ifndef __WIN32K__
177 typedef struct _LDT_ENTRY
178 {
179 WORD LimitLow;
180 WORD BaseLow;
181 union
182 {
183 struct
184 {
185 BYTE BaseMid;
186 BYTE Flags1;
187 BYTE Flags2;
188 BYTE BaseHi;
189 } Bytes;
190 struct
191 {
192 DWORD BaseMid : 8;
193 DWORD Type : 5;
194 DWORD Dpl : 2;
195 DWORD Pres : 1;
196 DWORD LimitHi : 4;
197 DWORD Sys : 1;
198 DWORD Reserved_0 : 1;
199 DWORD Default_Big : 1;
200 DWORD Granularity : 1;
201 DWORD BaseHi : 8;
202 } Bits;
203 } HighWord;
204 } LDT_ENTRY, *PLDT_ENTRY, *LPLDT_ENTRY;
205 #endif
206
207 typedef struct _KGDTENTRY
208 {
209 USHORT LimitLow;
210 USHORT BaseLow;
211 union
212 {
213 struct
214 {
215 UCHAR BaseMid;
216 UCHAR Flags1;
217 UCHAR Flags2;
218 UCHAR BaseHi;
219 } Bytes;
220 struct
221 {
222 ULONG BaseMid : 8;
223 ULONG Type : 5;
224 ULONG Dpl : 2;
225 ULONG Pres : 1;
226 ULONG LimitHi : 4;
227 ULONG Sys : 1;
228 ULONG Reserved_0 : 1;
229 ULONG Default_Big : 1;
230 ULONG Granularity : 1;
231 ULONG BaseHi : 8;
232 } Bits;
233 } HighWord;
234 } KGDTENTRY, *PKGDTENTRY;
235
236 typedef struct _KIDT_ACCESS
237 {
238 union
239 {
240 struct
241 {
242 UCHAR Reserved;
243 UCHAR SegmentType:4;
244 UCHAR SystemSegmentFlag:1;
245 UCHAR Dpl:2;
246 UCHAR Present:1;
247 };
248 USHORT Value;
249 };
250 } KIDT_ACCESS, *PKIDT_ACCESS;
251
252 typedef struct _KIDTENTRY
253 {
254 USHORT Offset;
255 USHORT Selector;
256 USHORT Access;
257 USHORT ExtendedOffset;
258 } KIDTENTRY, *PKIDTENTRY;
259
260 typedef struct _HARDWARE_PTE_X86
261 {
262 ULONG Valid : 1;
263 ULONG Write : 1;
264 ULONG Owner : 1;
265 ULONG WriteThrough : 1;
266 ULONG CacheDisable : 1;
267 ULONG Accessed : 1;
268 ULONG Dirty : 1;
269 ULONG LargePage : 1;
270 ULONG Global : 1;
271 ULONG CopyOnWrite : 1;
272 ULONG Prototype : 1;
273 ULONG reserved : 1;
274 ULONG PageFrameNumber : 20;
275 } HARDWARE_PTE_X86, *PHARDWARE_PTE_X86;
276
277 typedef struct _DESCRIPTOR
278 {
279 WORD Pad;
280 WORD Limit;
281 DWORD Base;
282 } KDESCRIPTOR, *PKDESCRIPTOR;
283
284 typedef struct _KSPECIAL_REGISTERS
285 {
286 DWORD Cr0;
287 DWORD Cr2;
288 DWORD Cr3;
289 DWORD Cr4;
290 DWORD KernelDr0;
291 DWORD KernelDr1;
292 DWORD KernelDr2;
293 DWORD KernelDr3;
294 DWORD KernelDr6;
295 DWORD KernelDr7;
296 KDESCRIPTOR Gdtr;
297 KDESCRIPTOR Idtr;
298 WORD Tr;
299 WORD Ldtr;
300 DWORD Reserved[6];
301 } KSPECIAL_REGISTERS, *PKSPECIAL_REGISTERS;
302
303 #pragma pack(push,4)
304
305 typedef struct _KPROCESSOR_STATE
306 {
307 PCONTEXT ContextFrame;
308 KSPECIAL_REGISTERS SpecialRegisters;
309 } KPROCESSOR_STATE;
310
311 /* Processor Control Block */
312 typedef struct _KPRCB
313 {
314 USHORT MinorVersion;
315 USHORT MajorVersion;
316 struct _KTHREAD *CurrentThread;
317 struct _KTHREAD *NextThread;
318 struct _KTHREAD *IdleThread;
319 UCHAR Number;
320 UCHAR Reserved;
321 USHORT BuildType;
322 ULONG SetMember;
323 UCHAR CpuType;
324 UCHAR CpuID;
325 USHORT CpuStep;
326 KPROCESSOR_STATE ProcessorState;
327 ULONG KernelReserved[16];
328 ULONG HalReserved[16];
329 UCHAR PrcbPad0[92];
330 PVOID LockQueue[33]; // Used for Queued Spinlocks
331 struct _KTHREAD *NpxThread;
332 ULONG InterruptCount;
333 ULONG KernelTime;
334 ULONG UserTime;
335 ULONG DpcTime;
336 ULONG DebugDpcTime;
337 ULONG InterruptTime;
338 ULONG AdjustDpcThreshold;
339 ULONG PageColor;
340 UCHAR SkipTick;
341 UCHAR DebuggerSavedIRQL;
342 UCHAR Spare1[6];
343 struct _KNODE *ParentNode;
344 ULONG MultiThreadProcessorSet;
345 struct _KPRCB *MultiThreadSetMaster;
346 ULONG ThreadStartCount[2];
347 ULONG CcFastReadNoWait;
348 ULONG CcFastReadWait;
349 ULONG CcFastReadNotPossible;
350 ULONG CcCopyReadNoWait;
351 ULONG CcCopyReadWait;
352 ULONG CcCopyReadNoWaitMiss;
353 ULONG KeAlignmentFixupCount;
354 ULONG KeContextSwitches;
355 ULONG KeDcacheFlushCount;
356 ULONG KeExceptionDispatchCount;
357 ULONG KeFirstLevelTbFills;
358 ULONG KeFloatingEmulationCount;
359 ULONG KeIcacheFlushCount;
360 ULONG KeSecondLevelTbFills;
361 ULONG KeSystemCalls;
362 ULONG IoReadOperationCount;
363 ULONG IoWriteOperationCount;
364 ULONG IoOtherOperationCount;
365 LARGE_INTEGER IoReadTransferCount;
366 LARGE_INTEGER IoWriteTransferCount;
367 LARGE_INTEGER IoOtherTransferCount;
368 ULONG SpareCounter1[8];
369 PP_LOOKASIDE_LIST PPLookasideList[16];
370 PP_LOOKASIDE_LIST PPNPagedLookasideList[32];
371 PP_LOOKASIDE_LIST PPPagedLookasideList[32];
372 ULONG PacketBarrier;
373 ULONG ReverseStall;
374 PVOID IpiFrame;
375 UCHAR PrcbPad2[52];
376 PVOID CurrentPacket[3];
377 ULONG TargetSet;
378 ULONG_PTR WorkerRoutine;
379 ULONG IpiFrozen;
380 UCHAR PrcbPad3[40];
381 ULONG RequestSummary;
382 struct _KPRCB *SignalDone;
383 UCHAR PrcbPad4[56];
384 struct _KDPC_DATA DpcData[2];
385 PVOID DpcStack;
386 ULONG MaximumDpcQueueDepth;
387 ULONG DpcRequestRate;
388 ULONG MinimumDpcRate;
389 UCHAR DpcInterruptRequested;
390 UCHAR DpcThreadRequested;
391 UCHAR DpcRoutineActive;
392 UCHAR DpcThreadActive;
393 ULONG PrcbLock;
394 ULONG DpcLastCount;
395 ULONG TimerHand;
396 ULONG TimerRequest;
397 PVOID DpcThread;
398 struct _KEVENT *DpcEvent;
399 UCHAR ThreadDpcEnable;
400 BOOLEAN QuantumEnd;
401 UCHAR PrcbPad50;
402 UCHAR IdleSchedule;
403 ULONG DpcSetEventRequest;
404 UCHAR PrcbPad5[18];
405 LONG TickOffset;
406 struct _KDPC* CallDpc;
407 ULONG PrcbPad7[8];
408 LIST_ENTRY WaitListHead;
409 ULONG ReadySummary;
410 ULONG SelectNextLast;
411 LIST_ENTRY DispatcherReadyListHead[32];
412 SINGLE_LIST_ENTRY DeferredReadyListHead;
413 ULONG PrcbPad72[11];
414 PVOID ChainedInterruptList;
415 LONG LookasideIrpFloat;
416 LONG MmPageFaultCount;
417 LONG MmCopyOnWriteCount;
418 LONG MmTransitionCount;
419 LONG MmCacheTransitionCount;
420 LONG MmDemandZeroCount;
421 LONG MmPageReadCount;
422 LONG MmPageReadIoCount;
423 LONG MmCacheReadCount;
424 LONG MmCacheIoCount;
425 LONG MmDirtyPagesWriteCount;
426 LONG MmDirtyWriteIoCount;
427 LONG MmMappedPagesWriteCount;
428 LONG MmMappedWriteIoCount;
429 ULONG SpareFields0[1];
430 CHAR VendorString[13];
431 UCHAR InitialApicId;
432 UCHAR LogicalProcessorsPerPhysicalProcessor;
433 ULONG MHz;
434 ULONG FeatureBits;
435 LARGE_INTEGER UpdateSignature;
436 LARGE_INTEGER IsrTime;
437 LARGE_INTEGER SpareField1;
438 FX_SAVE_AREA NpxSaveArea;
439 PROCESSOR_POWER_STATE PowerState;
440 } KPRCB, *PKPRCB;
441
442 /*
443 * This is the complete, internal KPCR structure
444 */
445 typedef struct _KIPCR
446 {
447 KPCR_TIB Tib; /* 00 */
448 struct _KPCR *Self; /* 1C */
449 struct _KPRCB *Prcb; /* 20 */
450 KIRQL Irql; /* 24 */
451 ULONG IRR; /* 28 */
452 ULONG IrrActive; /* 2C */
453 ULONG IDR; /* 30 */
454 PVOID KdVersionBlock; /* 34 */
455 PUSHORT IDT; /* 38 */
456 PUSHORT GDT; /* 3C */
457 struct _KTSS *TSS; /* 40 */
458 USHORT MajorVersion; /* 44 */
459 USHORT MinorVersion; /* 46 */
460 KAFFINITY SetMember; /* 48 */
461 ULONG StallScaleFactor; /* 4C */
462 UCHAR SparedUnused; /* 50 */
463 UCHAR Number; /* 51 */
464 UCHAR Reserved; /* 52 */
465 UCHAR L2CacheAssociativity; /* 53 */
466 ULONG VdmAlert; /* 54 */
467 ULONG KernelReserved[14]; /* 58 */
468 ULONG L2CacheSize; /* 90 */
469 ULONG HalReserved[16]; /* 94 */
470 ULONG InterruptMode; /* D4 */
471 UCHAR KernelReserved2[0x48]; /* D8 */
472 KPRCB PrcbData; /* 120 */
473 } KIPCR, *PKIPCR;
474
475 #pragma pack(pop)
476
477 #include <pshpack1.h>
478
479 typedef struct _KTSSNOIOPM
480 {
481 USHORT PreviousTask;
482 USHORT Reserved1;
483 ULONG Esp0;
484 USHORT Ss0;
485 USHORT Reserved2;
486 ULONG Esp1;
487 USHORT Ss1;
488 USHORT Reserved3;
489 ULONG Esp2;
490 USHORT Ss2;
491 USHORT Reserved4;
492 ULONG Cr3;
493 ULONG Eip;
494 ULONG Eflags;
495 ULONG Eax;
496 ULONG Ecx;
497 ULONG Edx;
498 ULONG Ebx;
499 ULONG Esp;
500 ULONG Ebp;
501 ULONG Esi;
502 ULONG Edi;
503 USHORT Es;
504 USHORT Reserved5;
505 USHORT Cs;
506 USHORT Reserved6;
507 USHORT Ss;
508 USHORT Reserved7;
509 USHORT Ds;
510 USHORT Reserved8;
511 USHORT Fs;
512 USHORT Reserved9;
513 USHORT Gs;
514 USHORT Reserved10;
515 USHORT Ldt;
516 USHORT Reserved11;
517 USHORT Trap;
518 USHORT IoMapBase;
519 /* no interrupt redirection map */
520 UCHAR IoBitmap[1];
521 } KTSSNOIOPM;
522
523 typedef struct _KTSS
524 {
525 USHORT PreviousTask;
526 USHORT Reserved1;
527 ULONG Esp0;
528 USHORT Ss0;
529 USHORT Reserved2;
530 ULONG Esp1;
531 USHORT Ss1;
532 USHORT Reserved3;
533 ULONG Esp2;
534 USHORT Ss2;
535 USHORT Reserved4;
536 ULONG Cr3;
537 ULONG Eip;
538 ULONG Eflags;
539 ULONG Eax;
540 ULONG Ecx;
541 ULONG Edx;
542 ULONG Ebx;
543 ULONG Esp;
544 ULONG Ebp;
545 ULONG Esi;
546 ULONG Edi;
547 USHORT Es;
548 USHORT Reserved5;
549 USHORT Cs;
550 USHORT Reserved6;
551 USHORT Ss;
552 USHORT Reserved7;
553 USHORT Ds;
554 USHORT Reserved8;
555 USHORT Fs;
556 USHORT Reserved9;
557 USHORT Gs;
558 USHORT Reserved10;
559 USHORT Ldt;
560 USHORT Reserved11;
561 USHORT Trap;
562 USHORT IoMapBase;
563 /* no interrupt redirection map */
564 UCHAR IoBitmap[8193];
565 } KTSS;
566
567 #include <poppack.h>
568
569 /* i386 Doesn't have Exception Frames */
570 typedef struct _KEXCEPTION_FRAME
571 {
572
573 } KEXCEPTION_FRAME, *PKEXCEPTION_FRAME;
574
575 typedef struct _KNODE
576 {
577 SLIST_HEADER DeadStackList;
578 SLIST_HEADER PfnDereferenceSListHead;
579 ULONG ProcessorMask;
580 ULONG Color;
581 UCHAR Seed;
582 UCHAR NodeNumber;
583 ULONG Flags;
584 ULONG MmShiftedColor;
585 ULONG FreeCount[2];
586 struct _SINGLE_LIST_ENTRY *PfnDeferredList;
587 } KNODE, *PKNODE;
588
589 typedef struct _KPROFILE
590 {
591 CSHORT Type;
592 CSHORT Size;
593 LIST_ENTRY ListEntry;
594 PVOID RegionStart;
595 PVOID RegionEnd;
596 ULONG BucketShift;
597 PVOID Buffer;
598 CSHORT Source;
599 ULONG Affinity;
600 BOOLEAN Active;
601 struct _KPROCESS *Process;
602 } KPROFILE, *PKPROFILE;
603
604 typedef struct _KINTERRUPT
605 {
606 CSHORT Type;
607 CSHORT Size;
608 LIST_ENTRY InterruptListEntry;
609 PKSERVICE_ROUTINE ServiceRoutine;
610 PVOID ServiceContext;
611 KSPIN_LOCK SpinLock;
612 ULONG TickCount;
613 PKSPIN_LOCK ActualLock;
614 PVOID DispatchAddress;
615 ULONG Vector;
616 KIRQL Irql;
617 KIRQL SynchronizeIrql;
618 BOOLEAN FloatingSave;
619 BOOLEAN Connected;
620 CHAR Number;
621 UCHAR ShareVector;
622 KINTERRUPT_MODE Mode;
623 ULONG ServiceCount;
624 ULONG DispatchCount;
625 ULONG DispatchCode[106];
626 } KINTERRUPT, *PKINTERRUPT;
627
628 typedef struct _KEVENT_PAIR
629 {
630 CSHORT Type;
631 CSHORT Size;
632 KEVENT LowEvent;
633 KEVENT HighEvent;
634 } KEVENT_PAIR, *PKEVENT_PAIR;
635
636 typedef struct _KEXECUTE_OPTIONS
637 {
638 UCHAR ExecuteDisable:1;
639 UCHAR ExecuteEnable:1;
640 UCHAR DisableThunkEmulation:1;
641 UCHAR Permanent:1;
642 UCHAR ExecuteDispatchEnable:1;
643 UCHAR ImageDispatchEnable:1;
644 UCHAR Spare:2;
645 } KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
646
647 typedef enum _KOBJECTS
648 {
649 EventNotificationObject = 0,
650 EventSynchronizationObject = 1,
651 MutantObject = 2,
652 ProcessObject = 3,
653 QueueObject = 4,
654 SemaphoreObject = 5,
655 ThreadObject = 6,
656 GateObject = 7,
657 TimerNotificationObject = 8,
658 TimerSynchronizationObject = 9,
659 Spare2Object = 10,
660 Spare3Object = 11,
661 Spare4Object = 12,
662 Spare5Object = 13,
663 Spare6Object = 14,
664 Spare7Object = 15,
665 Spare8Object = 16,
666 Spare9Object = 17,
667 ApcObject = 18,
668 DpcObject = 19,
669 DeviceQueueObject = 20,
670 EventPairObject = 21,
671 InterruptObject = 22,
672 ProfileObject = 23,
673 ThreadedDpcObject = 24,
674 MaximumKernelObject = 25
675 } KOBJECTS;
676
677 #include <pshpack1.h>
678
679 typedef struct _KTHREAD
680 {
681 /* For waiting on thread exit */
682 DISPATCHER_HEADER DispatcherHeader; /* 00 */
683
684 /* List of mutants owned by the thread */
685 LIST_ENTRY MutantListHead; /* 10 */
686 PVOID InitialStack; /* 18 */
687 ULONG_PTR StackLimit; /* 1C */
688
689 /* Pointer to the thread's environment block in user memory */
690 struct _TEB *Teb; /* 20 */
691
692 /* Pointer to the thread's TLS array */
693 PVOID TlsArray; /* 24 */
694 PVOID KernelStack; /* 28 */
695 UCHAR DebugActive; /* 2C */
696
697 /* Thread state (one of THREAD_STATE_xxx constants below) */
698 UCHAR State; /* 2D */
699 BOOLEAN Alerted[2]; /* 2E */
700 UCHAR Iopl; /* 30 */
701 UCHAR NpxState; /* 31 */
702 CHAR Saturation; /* 32 */
703 CHAR Priority; /* 33 */
704 KAPC_STATE ApcState; /* 34 */
705 ULONG ContextSwitches; /* 4C */
706 LONG WaitStatus; /* 50 */
707 KIRQL WaitIrql; /* 54 */
708 CHAR WaitMode; /* 55 */
709 UCHAR WaitNext; /* 56 */
710 UCHAR WaitReason; /* 57 */
711 union /* 58 */
712 {
713 PKWAIT_BLOCK WaitBlockList; /* 58 */
714 PKGATE GateObject; /* 58 */
715 }; /* 58 */
716 LIST_ENTRY WaitListEntry; /* 5C */
717 ULONG WaitTime; /* 64 */
718 CHAR BasePriority; /* 68 */
719 UCHAR DecrementCount; /* 69 */
720 UCHAR PriorityDecrement; /* 6A */
721 CHAR Quantum; /* 6B */
722 KWAIT_BLOCK WaitBlock[4]; /* 6C */
723 PVOID LegoData; /* CC */
724 union
725 {
726 struct
727 {
728 USHORT KernelApcDisable;
729 USHORT SpecialApcDisable;
730 };
731 ULONG CombinedApcDisable; /* D0 */
732 };
733 KAFFINITY UserAffinity; /* D4 */
734 UCHAR SystemAffinityActive;/* D8 */
735 UCHAR PowerState; /* D9 */
736 UCHAR NpxIrql; /* DA */
737 UCHAR Pad[1]; /* DB */
738 PVOID ServiceTable; /* DC */
739 struct _KQUEUE *Queue; /* E0 */
740 KSPIN_LOCK ApcQueueLock; /* E4 */
741 KTIMER Timer; /* E8 */
742 LIST_ENTRY QueueListEntry; /* 110 */
743 KAFFINITY Affinity; /* 118 */
744 UCHAR Preempted; /* 11C */
745 UCHAR ProcessReadyQueue; /* 11D */
746 UCHAR KernelStackResident; /* 11E */
747 UCHAR NextProcessor; /* 11F */
748 PVOID CallbackStack; /* 120 */
749 struct _W32THREAD *Win32Thread; /* 124 */
750 struct _KTRAP_FRAME *TrapFrame; /* 128 */
751 PKAPC_STATE ApcStatePointer[2]; /* 12C */
752 UCHAR EnableStackSwap; /* 134 */
753 UCHAR LargeStack; /* 135 */
754 UCHAR ResourceIndex; /* 136 */
755 UCHAR PreviousMode; /* 137 */
756 ULONG KernelTime; /* 138 */
757 ULONG UserTime; /* 13C */
758 KAPC_STATE SavedApcState; /* 140 */
759 UCHAR Alertable; /* 158 */
760 UCHAR ApcStateIndex; /* 159 */
761 UCHAR ApcQueueable; /* 15A */
762 UCHAR AutoAlignment; /* 15B */
763 PVOID StackBase; /* 15C */
764 KAPC SuspendApc; /* 160 */
765 KSEMAPHORE SuspendSemaphore; /* 190 */
766 LIST_ENTRY ThreadListEntry; /* 1A4 */
767 CHAR FreezeCount; /* 1AC */
768 UCHAR SuspendCount; /* 1AD */
769 UCHAR IdealProcessor; /* 1AE */
770 UCHAR DisableBoost; /* 1AF */
771 UCHAR QuantumReset; /* 1B0 */
772 } KTHREAD;
773
774 #include <poppack.h>
775
776 /*
777 * NAME: KPROCESS
778 * DESCRIPTION: Internal Kernel Process Structure.
779 * PORTABILITY: Architecture Dependent.
780 * KERNEL VERSION: 5.2
781 * DOCUMENTATION: http://reactos.com/wiki/index.php/KPROCESS
782 */
783 typedef struct _KPROCESS
784 {
785 DISPATCHER_HEADER Header; /* 000 */
786 LIST_ENTRY ProfileListHead; /* 010 */
787 PHYSICAL_ADDRESS DirectoryTableBase; /* 018 */
788 KGDTENTRY LdtDescriptor; /* 020 */
789 KIDTENTRY Int21Descriptor; /* 028 */
790 USHORT IopmOffset; /* 030 */
791 UCHAR Iopl; /* 032 */
792 UCHAR Unused; /* 033 */
793 ULONG ActiveProcessors; /* 034 */
794 ULONG KernelTime; /* 038 */
795 ULONG UserTime; /* 03C */
796 LIST_ENTRY ReadyListHead; /* 040 */
797 LIST_ENTRY SwapListEntry; /* 048 */
798 PVOID VdmTrapcHandler; /* 04C */
799 LIST_ENTRY ThreadListHead; /* 050 */
800 KSPIN_LOCK ProcessLock; /* 058 */
801 KAFFINITY Affinity; /* 05C */
802 union
803 {
804 struct
805 {
806 ULONG AutoAlignment:1; /* 060.0 */
807 ULONG DisableBoost:1; /* 060.1 */
808 ULONG DisableQuantum:1; /* 060.2 */
809 ULONG ReservedFlags:29; /* 060.3 */
810 };
811 ULONG ProcessFlags; /* 060 */
812 };
813 CHAR BasePriority; /* 064 */
814 CHAR QuantumReset; /* 065 */
815 UCHAR State; /* 066 */
816 UCHAR ThreadSeed; /* 067 */
817 UCHAR PowerState; /* 068 */
818 UCHAR IdealNode; /* 069 */
819 UCHAR Visited; /* 06A */
820 KEXECUTE_OPTIONS Flags; /* 06B */
821 ULONG StackCount; /* 06C */
822 LIST_ENTRY ProcessListEntry; /* 070 */
823 } KPROCESS;
824
825 typedef enum _KTHREAD_STATE
826 {
827 Initialized,
828 Ready,
829 Running,
830 Standby,
831 Terminated,
832 Waiting,
833 Transition,
834 DeferredReady,
835 } KTHREAD_STATE, *PKTHREAD_STATE;
836
837 #endif