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)
12 /* DEPENDENCIES **************************************************************/
18 /* CONSTANTS *****************************************************************/
19 #define SSDT_MAX_ENTRIES 4
20 #define PROCESSOR_FEATURE_MAX 64
22 #define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
24 #define THREAD_WAIT_OBJECTS 4
26 /* X86 80386 Segment Types */
28 #define I386_ACTIVE_TSS 0xB
29 #define I386_CALL_GATE 0xC
30 #define I386_INTERRUPT_GATE 0xE
31 #define I386_TRAP_GATE 0xF
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
];
46 /* ENUMERATIONS **************************************************************/
48 /* TYPES *********************************************************************/
50 typedef struct _CONFIGURATION_COMPONENT_DATA
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
;
58 typedef enum _KAPC_ENVIRONMENT
60 OriginalApcEnvironment
,
61 AttachedApcEnvironment
,
65 typedef struct _KDPC_DATA
67 LIST_ENTRY DpcListHead
;
71 } KDPC_DATA
, *PKDPC_DATA
;
73 /* We don't want to force NTIFS usage only for a single structure */
75 typedef struct _KAPC_STATE
77 LIST_ENTRY ApcListHead
[2];
79 BOOLEAN KernelApcInProgress
;
80 BOOLEAN KernelApcPending
;
81 BOOLEAN UserApcPending
;
82 } KAPC_STATE
, *PKAPC_STATE
, *RESTRICTED_POINTER PRKAPC_STATE
;
85 /* FIXME: Most of these should go to i386 directory */
86 typedef struct _FNSAVE_FORMAT
95 UCHAR RegisterArea
[80];
96 } FNSAVE_FORMAT
, *PFNSAVE_FORMAT
;
98 typedef struct _FXSAVE_FORMAT
110 UCHAR RegisterArea
[128];
111 UCHAR Reserved3
[128];
112 UCHAR Reserved4
[224];
113 UCHAR Align16Byte
[8];
114 } FXSAVE_FORMAT
, *PFXSAVE_FORMAT
;
116 typedef struct _FX_SAVE_AREA
120 FNSAVE_FORMAT FnArea
;
121 FXSAVE_FORMAT FxArea
;
125 } FX_SAVE_AREA
, *PFX_SAVE_AREA
;
127 typedef struct _KTRAP_FRAME
173 } KTRAP_FRAME
, *PKTRAP_FRAME
;
175 /* FIXME: Win32k uses windows.h! */
177 typedef struct _LDT_ENTRY
198 DWORD Reserved_0
: 1;
199 DWORD Default_Big
: 1;
200 DWORD Granularity
: 1;
204 } LDT_ENTRY
, *PLDT_ENTRY
, *LPLDT_ENTRY
;
207 typedef struct _KGDTENTRY
228 ULONG Reserved_0
: 1;
229 ULONG Default_Big
: 1;
230 ULONG Granularity
: 1;
234 } KGDTENTRY
, *PKGDTENTRY
;
236 typedef struct _KIDT_ACCESS
244 UCHAR SystemSegmentFlag
:1;
250 } KIDT_ACCESS
, *PKIDT_ACCESS
;
252 typedef struct _KIDTENTRY
257 USHORT ExtendedOffset
;
258 } KIDTENTRY
, *PKIDTENTRY
;
260 typedef struct _HARDWARE_PTE_X86
265 ULONG WriteThrough
: 1;
266 ULONG CacheDisable
: 1;
271 ULONG CopyOnWrite
: 1;
274 ULONG PageFrameNumber
: 20;
275 } HARDWARE_PTE_X86
, *PHARDWARE_PTE_X86
;
277 typedef struct _DESCRIPTOR
282 } KDESCRIPTOR
, *PKDESCRIPTOR
;
284 typedef struct _KSPECIAL_REGISTERS
301 } KSPECIAL_REGISTERS
, *PKSPECIAL_REGISTERS
;
305 typedef struct _KPROCESSOR_STATE
307 PCONTEXT ContextFrame
;
308 KSPECIAL_REGISTERS SpecialRegisters
;
311 /* Processor Control Block */
312 typedef struct _KPRCB
316 struct _KTHREAD
*CurrentThread
;
317 struct _KTHREAD
*NextThread
;
318 struct _KTHREAD
*IdleThread
;
326 KPROCESSOR_STATE ProcessorState
;
327 ULONG KernelReserved
[16];
328 ULONG HalReserved
[16];
330 PVOID LockQueue
[33]; // Used for Queued Spinlocks
331 struct _KTHREAD
*NpxThread
;
332 ULONG InterruptCount
;
338 ULONG AdjustDpcThreshold
;
341 UCHAR DebuggerSavedIRQL
;
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
;
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];
376 PVOID CurrentPacket
[3];
378 ULONG_PTR WorkerRoutine
;
381 ULONG RequestSummary
;
382 struct _KPRCB
*SignalDone
;
384 struct _KDPC_DATA DpcData
[2];
386 ULONG MaximumDpcQueueDepth
;
387 ULONG DpcRequestRate
;
388 ULONG MinimumDpcRate
;
389 UCHAR DpcInterruptRequested
;
390 UCHAR DpcThreadRequested
;
391 UCHAR DpcRoutineActive
;
392 UCHAR DpcThreadActive
;
398 struct _KEVENT
*DpcEvent
;
399 UCHAR ThreadDpcEnable
;
403 ULONG DpcSetEventRequest
;
406 struct _KDPC
* CallDpc
;
408 LIST_ENTRY WaitListHead
;
410 ULONG SelectNextLast
;
411 LIST_ENTRY DispatcherReadyListHead
[32];
412 SINGLE_LIST_ENTRY DeferredReadyListHead
;
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
;
425 LONG MmDirtyPagesWriteCount
;
426 LONG MmDirtyWriteIoCount
;
427 LONG MmMappedPagesWriteCount
;
428 LONG MmMappedWriteIoCount
;
429 ULONG SpareFields0
[1];
430 CHAR VendorString
[13];
432 UCHAR LogicalProcessorsPerPhysicalProcessor
;
435 LARGE_INTEGER UpdateSignature
;
436 LARGE_INTEGER IsrTime
;
437 LARGE_INTEGER SpareField1
;
438 FX_SAVE_AREA NpxSaveArea
;
439 PROCESSOR_POWER_STATE PowerState
;
443 * This is the complete, internal KPCR structure
445 typedef struct _KIPCR
447 KPCR_TIB Tib
; /* 00 */
448 struct _KPCR
*Self
; /* 1C */
449 struct _KPRCB
*Prcb
; /* 20 */
452 ULONG IrrActive
; /* 2C */
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 */
477 #include <pshpack1.h>
479 typedef struct _KTSSNOIOPM
519 /* no interrupt redirection map */
563 /* no interrupt redirection map */
564 UCHAR IoBitmap
[8193];
569 /* i386 Doesn't have Exception Frames */
570 typedef struct _KEXCEPTION_FRAME
573 } KEXCEPTION_FRAME
, *PKEXCEPTION_FRAME
;
575 typedef struct _KNODE
577 SLIST_HEADER DeadStackList
;
578 SLIST_HEADER PfnDereferenceSListHead
;
584 ULONG MmShiftedColor
;
586 struct _SINGLE_LIST_ENTRY
*PfnDeferredList
;
589 typedef struct _KPROFILE
593 LIST_ENTRY ListEntry
;
601 struct _KPROCESS
*Process
;
602 } KPROFILE
, *PKPROFILE
;
604 typedef struct _KINTERRUPT
608 LIST_ENTRY InterruptListEntry
;
609 PKSERVICE_ROUTINE ServiceRoutine
;
610 PVOID ServiceContext
;
613 PKSPIN_LOCK ActualLock
;
614 PVOID DispatchAddress
;
617 KIRQL SynchronizeIrql
;
618 BOOLEAN FloatingSave
;
622 KINTERRUPT_MODE Mode
;
625 ULONG DispatchCode
[106];
626 } KINTERRUPT
, *PKINTERRUPT
;
628 typedef struct _KEVENT_PAIR
634 } KEVENT_PAIR
, *PKEVENT_PAIR
;
636 typedef struct _KEXECUTE_OPTIONS
638 UCHAR ExecuteDisable
:1;
639 UCHAR ExecuteEnable
:1;
640 UCHAR DisableThunkEmulation
:1;
642 UCHAR ExecuteDispatchEnable
:1;
643 UCHAR ImageDispatchEnable
:1;
645 } KEXECUTE_OPTIONS
, *PKEXECUTE_OPTIONS
;
647 typedef enum _KOBJECTS
649 EventNotificationObject
= 0,
650 EventSynchronizationObject
= 1,
657 TimerNotificationObject
= 8,
658 TimerSynchronizationObject
= 9,
669 DeviceQueueObject
= 20,
670 EventPairObject
= 21,
671 InterruptObject
= 22,
673 ThreadedDpcObject
= 24,
674 MaximumKernelObject
= 25
677 #include <pshpack1.h>
679 typedef struct _KTHREAD
681 /* For waiting on thread exit */
682 DISPATCHER_HEADER DispatcherHeader
; /* 00 */
684 /* List of mutants owned by the thread */
685 LIST_ENTRY MutantListHead
; /* 10 */
686 PVOID InitialStack
; /* 18 */
687 ULONG_PTR StackLimit
; /* 1C */
689 /* Pointer to the thread's environment block in user memory */
690 struct _TEB
*Teb
; /* 20 */
692 /* Pointer to the thread's TLS array */
693 PVOID TlsArray
; /* 24 */
694 PVOID KernelStack
; /* 28 */
695 UCHAR DebugActive
; /* 2C */
697 /* Thread state (one of THREAD_STATE_xxx constants below) */
698 UCHAR State
; /* 2D */
699 BOOLEAN Alerted
[2]; /* 2E */
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 */
713 PKWAIT_BLOCK WaitBlockList
; /* 58 */
714 PKGATE GateObject
; /* 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 */
728 USHORT KernelApcDisable
;
729 USHORT SpecialApcDisable
;
731 ULONG CombinedApcDisable
; /* D0 */
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 */
778 * DESCRIPTION: Internal Kernel Process Structure.
779 * PORTABILITY: Architecture Dependent.
780 * KERNEL VERSION: 5.2
781 * DOCUMENTATION: http://reactos.com/wiki/index.php/KPROCESS
783 typedef struct _KPROCESS
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 */
806 ULONG AutoAlignment
:1; /* 060.0 */
807 ULONG DisableBoost
:1; /* 060.1 */
808 ULONG DisableQuantum
:1; /* 060.2 */
809 ULONG ReservedFlags
:29; /* 060.3 */
811 ULONG ProcessFlags
; /* 060 */
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 */
825 typedef enum _KTHREAD_STATE
835 } KTHREAD_STATE
, *PKTHREAD_STATE
;