3 Copyright (c) Alex Ionescu. All rights reserved.
11 Type definitions for the Loader.
15 Alex Ionescu (alex.ionescu@reactos.com) 06-Oct-2004
26 #ifndef NTOS_MODE_USER
34 // Context Record Flags
36 #define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
39 // Maximum System Descriptor Table Entries
41 #define SSDT_MAX_ENTRIES 4
46 // KPROCESSOR_MODE Type
48 typedef CCHAR KPROCESSOR_MODE
;
51 // Dereferencable pointer to KUSER_SHARED_DATA in User-Mode
53 #define SharedUserData ((KUSER_SHARED_DATA *CONST)USER_SHARED_DATA)
56 // Maximum WOW64 Entries in KUSER_SHARED_DATA
58 #define MAX_WOW64_SHARED_ENTRIES 16
61 // Maximum Processor Features supported in KUSER_SHARED_DATA
63 #define PROCESSOR_FEATURE_MAX 64
68 typedef enum _EVENT_TYPE
77 typedef enum _TIMER_TYPE
86 typedef enum _WAIT_TYPE
93 // Processor Execution Modes
105 typedef enum _KWAIT_REASON
147 typedef enum _KPROFILE_SOURCE
150 ProfileAlignmentFixup
,
153 ProfileLoadInstructions
,
154 ProfilePipelineFrozen
,
155 ProfileBranchInstructions
,
156 ProfileTotalNonissues
,
160 ProfileBranchMispredictions
,
161 ProfileStoreInstructions
,
162 ProfileFpInstructions
,
163 ProfileIntegerInstructions
,
167 ProfileSpecialInstructions
,
170 ProfileDcacheAccesses
,
171 ProfileMemoryBarrierCycles
,
172 ProfileLoadLinkedIssues
,
177 // NT Product and Architecture Types
179 typedef enum _NT_PRODUCT_TYPE
184 } NT_PRODUCT_TYPE
, *PNT_PRODUCT_TYPE
;
186 typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
191 } ALTERNATIVE_ARCHITECTURE_TYPE
;
198 typedef enum _KTHREAD_STATE
208 } KTHREAD_STATE
, *PKTHREAD_STATE
;
213 typedef enum _KPROCESS_STATE
218 } KPROCESS_STATE
, *PKPROCESS_STATE
;
220 #ifdef NTOS_MODE_USER
223 // APC Normal Routine
226 (NTAPI
*PKNORMAL_ROUTINE
)(
227 IN PVOID NormalContext
,
228 IN PVOID SystemArgument1
,
229 IN PVOID SystemArgument2
236 (NTAPI
*PTIMER_APC_ROUTINE
)(
237 IN PVOID TimerContext
,
238 IN ULONG TimerLowValue
,
239 IN LONG TimerHighValue
243 // System Time Structure
245 typedef struct _KSYSTEM_TIME
250 } KSYSTEM_TIME
, *PKSYSTEM_TIME
;
253 // Shared Kernel User Data
255 typedef struct _KUSER_SHARED_DATA
257 ULONG TickCountLowDeprecated
;
258 ULONG TickCountMultiplier
;
259 volatile KSYSTEM_TIME InterruptTime
;
260 volatile KSYSTEM_TIME SystemTime
;
261 volatile KSYSTEM_TIME TimeZoneBias
;
262 USHORT ImageNumberLow
;
263 USHORT ImageNumberHigh
;
264 WCHAR NtSystemRoot
[260];
265 ULONG MaxStackTraceDepth
;
266 ULONG CryptoExponent
;
268 ULONG LargePageMinimum
;
270 NT_PRODUCT_TYPE NtProductType
;
271 BOOLEAN ProductTypeIsValid
;
272 ULONG NtMajorVersion
;
273 ULONG NtMinorVersion
;
274 BOOLEAN ProcessorFeatures
[PROCESSOR_FEATURE_MAX
];
277 volatile ULONG TimeSlip
;
278 ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture
;
279 LARGE_INTEGER SystemExpirationDate
;
281 BOOLEAN KdDebuggerEnabled
;
282 volatile ULONG ActiveConsoleId
;
283 volatile ULONG DismountCount
;
284 ULONG ComPlusPackage
;
285 ULONG LastSystemRITEventTickCount
;
286 ULONG NumberOfPhysicalPages
;
287 BOOLEAN SafeBootMode
;
290 ULONGLONG TestRetInstruction
;
292 ULONG SystemCallReturn
;
293 ULONGLONG SystemCallPad
[3];
295 volatile KSYSTEM_TIME TickCount
;
296 volatile ULONG64 TickCountQuad
;
299 LONGLONG ConsoleSessionForegroundProcessId
;
300 ULONG Wow64SharedInformation
[MAX_WOW64_SHARED_ENTRIES
];
301 ULONG UserModeGlobalLogging
;
302 } KUSER_SHARED_DATA
, *PKUSER_SHARED_DATA
;
307 // APC Environment Types
309 typedef enum _KAPC_ENVIRONMENT
311 OriginalApcEnvironment
,
312 AttachedApcEnvironment
,
313 CurrentApcEnvironment
319 typedef struct _KDPC_DATA
321 LIST_ENTRY DpcListHead
;
325 } KDPC_DATA
, *PKDPC_DATA
;
328 // Per-Processor Lookaside List
330 typedef struct _PP_LOOKASIDE_LIST
332 struct _GENERAL_LOOKASIDE
*P
;
333 struct _GENERAL_LOOKASIDE
*L
;
334 } PP_LOOKASIDE_LIST
, *PPP_LOOKASIDE_LIST
;
337 // Architectural Types
339 #include <arch/ketypes.h>
342 // Kernel Memory Node
344 typedef struct _KNODE
346 SLIST_HEADER DeadStackList
;
347 SLIST_HEADER PfnDereferenceSListHead
;
353 ULONG MmShiftedColor
;
355 struct _SINGLE_LIST_ENTRY
*PfnDeferredList
;
359 // Kernel Profile Object
361 typedef struct _KPROFILE
365 LIST_ENTRY ProfileListEntry
;
366 struct _KPROCESS
*Process
;
373 KPROFILE_SOURCE Source
;
375 } KPROFILE
, *PKPROFILE
;
378 // Kernel Interrupt Object
380 typedef struct _KINTERRUPT
384 LIST_ENTRY InterruptListEntry
;
385 PKSERVICE_ROUTINE ServiceRoutine
;
386 PVOID ServiceContext
;
389 PKSPIN_LOCK ActualLock
;
390 PVOID DispatchAddress
;
393 KIRQL SynchronizeIrql
;
394 BOOLEAN FloatingSave
;
398 KINTERRUPT_MODE Mode
;
401 ULONG DispatchCode
[106];
402 } KINTERRUPT
, *PKINTERRUPT
;
405 // Kernel Event Pair Object
407 typedef struct _KEVENT_PAIR
413 } KEVENT_PAIR
, *PKEVENT_PAIR
;
416 // Kernel No Execute Options
418 typedef struct _KEXECUTE_OPTIONS
420 UCHAR ExecuteDisable
:1;
421 UCHAR ExecuteEnable
:1;
422 UCHAR DisableThunkEmulation
:1;
424 UCHAR ExecuteDispatchEnable
:1;
425 UCHAR ImageDispatchEnable
:1;
427 } KEXECUTE_OPTIONS
, *PKEXECUTE_OPTIONS
;
430 // Kernel Object Types
432 typedef enum _KOBJECTS
434 EventNotificationObject
= 0,
435 EventSynchronizationObject
= 1,
442 TimerNotificationObject
= 8,
443 TimerSynchronizationObject
= 9,
454 DeviceQueueObject
= 20,
455 EventPairObject
= 21,
456 InterruptObject
= 22,
458 ThreadedDpcObject
= 24,
459 MaximumKernelObject
= 25
463 // Kernel Thread (KTHREAD)
465 #include <pshpack1.h>
466 typedef struct _KTHREAD
468 DISPATCHER_HEADER DispatcherHeader
; /* 00 */
469 LIST_ENTRY MutantListHead
; /* 10 */
470 PVOID InitialStack
; /* 18 */
471 ULONG_PTR StackLimit
; /* 1C */
472 PVOID KernelStack
; /* 20 */
473 KSPIN_LOCK ThreadLock
; /* 24 */
476 KAPC_STATE ApcState
; /* 34 */
479 UCHAR ApcStateFill
[23]; /* 34 */
480 UCHAR ApcQueueable
; /* 3F */
483 UCHAR NextProcessor
; /* 40 */
484 UCHAR DeferredProcessor
; /* 41 */
485 UCHAR AdjustReason
; /* 42 */
486 UCHAR AdjustIncrement
; /* 43 */
487 KSPIN_LOCK ApcQueueLock
; /* 44 */
488 ULONG ContextSwitches
; /* 48 */
489 UCHAR State
; /* 4C */
490 UCHAR NpxState
; /* 4D */
491 UCHAR WaitIrql
; /* 4E */
492 UCHAR WaitMode
; /* 4F */
493 LONG WaitStatus
; /* 50 */
496 PKWAIT_BLOCK WaitBlockList
; /* 54 */
497 PKGATE GateObject
; /* 54 */
499 UCHAR Alertable
; /* 58 */
500 UCHAR WaitNext
; /* 59 */
501 UCHAR WaitReason
; /* 5A */
502 UCHAR Priority
; /* 5B */
503 UCHAR EnableStackSwap
; /* 5C */
504 UCHAR SwapBusy
; /* 5D */
505 UCHAR Alerted
[2]; /* 5E */
508 LIST_ENTRY WaitListEntry
; /* 60 */
509 SINGLE_LIST_ENTRY SwapListEntry
; /* 60 */
511 PKQUEUE Queue
; /* 68 */
512 ULONG WaitTime
; /* 6C */
517 USHORT KernelApcDisable
; /* 70 */
518 USHORT SpecialApcDisable
; /* 72 */
520 ULONG CombinedApcDisable
; /* 70 */
522 struct _TEB
*Teb
; /* 74 */
525 KTIMER Timer
; /* 78 */
526 UCHAR TimerFill
[40]; /* 78 */
532 LONG AutoAlignment
:1; /* A0 */
533 LONG DisableBoost
:1; /* A0 */
534 LONG ReservedFlags
:30; /* A0 */
536 LONG ThreadFlags
; /* A0 */
538 PVOID Padding
; /* A4 */
541 KWAIT_BLOCK WaitBlock
[4]; /* A8 */
546 UCHAR WaitBlockFill0
[23]; /* A8 */
547 UCHAR SystemAffinityActive
; /* BF */
551 UCHAR WaitBlockFill1
[47]; /* A8 */
552 UCHAR PreviousMode
; /* D7 */
556 UCHAR WaitBlockFill2
[71]; /* A8 */
557 UCHAR ResourceIndex
; /* EF */
561 UCHAR WaitBlockFill3
[95]; /* A8 */
562 UCHAR LargeStack
; /* 107 */
566 LIST_ENTRY QueueListEntry
; /* 108 */
567 PKTRAP_FRAME TrapFrame
; /* 110 */
568 PVOID CallbackStack
; /* 114 */
569 PVOID ServiceTable
; /* 118 */
570 UCHAR ApcStateIndex
; /* 11C */
571 UCHAR IdealProcessor
; /* 11D */
572 UCHAR Preempted
; /* 11E */
573 UCHAR ProcessReadyQueue
; /* 11F */
574 UCHAR KernelStackResident
; /* 120 */
575 CHAR BasePriority
; /* 121 */
576 CHAR PriorityDecrement
; /* 122 */
577 CHAR Saturation
; /* 123 */
578 KAFFINITY UserAffinity
; /* 124 */
579 struct _KPROCESS
*Process
; /* 128 */
580 KAFFINITY Affinity
; /* 12C */
581 PKAPC_STATE ApcStatePointer
[2]; /* 130 */
584 KAPC_STATE SavedApcState
; /* 138 */
587 UCHAR SavedApcStateFill
[23]; /* 138 */
588 CHAR FreezeCount
; /* 14F */
591 CHAR SuspendCount
; /* 150 */
592 UCHAR UserIdealProcessor
; /* 151 */
593 UCHAR CalloutActive
; /* 152 */
594 UCHAR Iopl
; /* 153 */
595 PVOID Win32Thread
; /* 154 */
596 PVOID StackBase
; /* 158 */
599 KAPC SuspendApc
; /* 15C */
602 UCHAR SuspendApcFill0
[1]; /* 15C */
603 CHAR Quantum
; /* 15D */
607 UCHAR SuspendApcFill1
[3]; /* 15C */
608 UCHAR QuantumReset
; /* 15F */
612 UCHAR SuspendApcFill2
[4]; /* 15C */
613 ULONG KernelTime
; /* 160 */
617 UCHAR SuspendApcFill3
[36]; /* 15C */
618 PVOID TlsArray
; /* 180 */
622 UCHAR SuspendApcFill4
[40]; /* 15C */
623 PVOID LegoData
; /* 184 */
627 UCHAR SuspendApcFill5
[47]; /* 15C */
628 UCHAR PowerState
; /* 18B */
631 ULONG UserTime
; /* 18C */
634 KSEMAPHORE SuspendSemaphore
; /* 190 */
635 UCHAR SuspendSemaphorefill
[20]; /* 190 */
637 ULONG SListFaultCount
; /* 1A4 */
638 LIST_ENTRY ThreadListEntry
; /* 1A8 */
639 PVOID SListFaultAddress
; /* 1B0 */
640 } KTHREAD
; /* sizeof: 1B4 */
644 // Kernel Process (KPROCESS)
646 typedef struct _KPROCESS
648 DISPATCHER_HEADER Header
; /* 000 */
649 LIST_ENTRY ProfileListHead
; /* 010 */
650 PHYSICAL_ADDRESS DirectoryTableBase
; /* 018 */
652 KGDTENTRY LdtDescriptor
; /* 020 */
653 KIDTENTRY Int21Descriptor
; /* 028 */
654 USHORT IopmOffset
; /* 030 */
655 UCHAR Iopl
; /* 032 */
656 UCHAR Unused
; /* 033 */
658 ULONG ActiveProcessors
; /* 034 */
659 ULONG KernelTime
; /* 038 */
660 ULONG UserTime
; /* 03C */
661 LIST_ENTRY ReadyListHead
; /* 040 */
662 LIST_ENTRY SwapListEntry
; /* 048 */
663 PVOID VdmTrapcHandler
; /* 04C */
664 LIST_ENTRY ThreadListHead
; /* 050 */
665 KSPIN_LOCK ProcessLock
; /* 058 */
666 KAFFINITY Affinity
; /* 05C */
671 ULONG AutoAlignment
:1; /* 060.0 */
672 ULONG DisableBoost
:1; /* 060.1 */
673 ULONG DisableQuantum
:1; /* 060.2 */
674 ULONG ReservedFlags
:29; /* 060.3 */
676 ULONG ProcessFlags
; /* 060 */
678 CHAR BasePriority
; /* 064 */
679 CHAR QuantumReset
; /* 065 */
680 UCHAR State
; /* 066 */
681 UCHAR ThreadSeed
; /* 067 */
682 UCHAR PowerState
; /* 068 */
683 UCHAR IdealNode
; /* 069 */
684 UCHAR Visited
; /* 06A */
685 KEXECUTE_OPTIONS Flags
; /* 06B */
686 ULONG StackCount
; /* 06C */
687 LIST_ENTRY ProcessListEntry
; /* 070 */
688 } KPROCESS
, *PKPROCESS
;
691 // System Service Table Descriptor
693 typedef struct _KSERVICE_TABLE_DESCRIPTOR
699 LONG TableBaseGpOffset
;
702 } KSERVICE_TABLE_DESCRIPTOR
, *PKSERVICE_TABLE_DESCRIPTOR
;
705 // Exported Loader Parameter Block
708 extern LOADER_PARAMETER_BLOCK NTSYSAPI KeLoaderBlock
;
710 extern PLOADER_PARAMETER_BLOCK NTSYSAPI KeLoaderBlock
;
714 // Exported Hardware Data
716 extern KAFFINITY NTSYSAPI KeActiveProcessors
;
717 extern CHAR NTSYSAPI KeNumberProcessors
;
718 extern ULONG NTSYSAPI KiDmaIoCoherency
;
719 extern ULONG NTSYSAPI KeMaximumIncrement
;
720 extern ULONG NTSYSAPI KeMinimumIncrement
;
721 extern ULONG NTSYSAPI KeDcacheFlushCount
;
722 extern ULONG NTSYSAPI KeIcacheFlushCount
;
725 // Exported System Service Descriptor Tables
727 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTable
[SSDT_MAX_ENTRIES
];
728 extern KSERVICE_TABLE_DESCRIPTOR NTSYSAPI KeServiceDescriptorTableShadow
[SSDT_MAX_ENTRIES
];
730 #endif // !NTOS_MODE_USER