-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathketypes.h
1508 lines (1415 loc) · 36.4 KB
/
ketypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*++ NDK Version: 0098
Copyright (c) Alex Ionescu. All rights reserved.
Header Name:
lpctypes.h
Abstract:
Type definitions for the Loader.
Author:
Alex Ionescu ([email protected]) - Updated - 27-Feb-2006
--*/
#ifndef _KETYPES_H
#define _KETYPES_H
//
// Dependencies
//
#include <..\ndk\umtypes.h>
#ifndef NTOS_MODE_USER
#include <..\ndk\haltypes.h>
#include <..\ndk\potypes.h>
#include <..\ndk\ifssupp.h>
#endif
//
// A system call ID is formatted as such:
// .________________________________________________________________.
// | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
// |--------------|-------------------------------------------------|
// | TABLE NUMBER | TABLE OFFSET |
// \----------------------------------------------------------------/
//
// The table number is then used as an index into the service descriptor table.
#define TABLE_NUMBER_BITS 1
#define TABLE_OFFSET_BITS 12
//
// There are 2 tables (kernel and shadow, used by Win32K)
//
#define NUMBER_SERVICE_TABLES 2
#define NTOS_SERVICE_INDEX 0
#define WIN32K_SERVICE_INDEX 1
//
// NB. From assembly code, the table number must be computed as an offset into
// the service descriptor table.
//
// Each entry into the table is 16 bytes long on 32-bit architectures, and
// 32 bytes long on 64-bit architectures.
//
// Thus, Table Number 1 is offset 16 (0x10) on x86, and offset 32 (0x20) on
// x64.
//
#ifdef _WIN64
#define BITS_PER_ENTRY 5 // (1 << 5) = 32 bytes
#else
#define BITS_PER_ENTRY 4 // (1 << 4) = 16 bytes
#endif
//
// We want the table number, but leave some extra bits to we can have the offset
// into the descriptor table.
//
#define SERVICE_TABLE_SHIFT (12 - BITS_PER_ENTRY)
//
// Now the table number (as an offset) is corrupted with part of the table offset
// This mask will remove the extra unwanted bits, and give us the offset into the
// descriptor table proper.
//
#define SERVICE_TABLE_MASK (((1 << TABLE_NUMBER_BITS) - 1) << BITS_PER_ENTRY)
//
// To get the table offset (ie: the service call number), just keep the 12 bits
//
#define SERVICE_NUMBER_MASK ((1 << TABLE_OFFSET_BITS) - 1)
//
// We'll often need to check if this is a graphics call. This is done by comparing
// the table number offset with the known Win32K table number offset.
// This is usually index 1, so table number offset 0x10 (x86) or 0x20 (x64)
//
#define SERVICE_TABLE_TEST (WIN32K_SERVICE_INDEX << BITS_PER_ENTRY)
//
// Context Record Flags
//
#define CONTEXT_DEBUGGER (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
//
// Maximum System Descriptor Table Entries
//
#define SSDT_MAX_ENTRIES 2
//
// Processor Architectures
//
#define PROCESSOR_ARCHITECTURE_INTEL 0
#define PROCESSOR_ARCHITECTURE_MIPS 1
#define PROCESSOR_ARCHITECTURE_ALPHA 2
#define PROCESSOR_ARCHITECTURE_PPC 3
#define PROCESSOR_ARCHITECTURE_SHX 4
#define PROCESSOR_ARCHITECTURE_ARM 5
#define PROCESSOR_ARCHITECTURE_IA64 6
#define PROCESSOR_ARCHITECTURE_ALPHA64 7
#define PROCESSOR_ARCHITECTURE_MSIL 8
#define PROCESSOR_ARCHITECTURE_AMD64 9
#define PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF
//
// Object Type Mask for Kernel Dispatcher Objects
//
#define KOBJECT_TYPE_MASK 0x7F
#define KOBJECT_LOCK_BIT 0x80
//
// Dispatcher Priority increments
//
#define THREAD_ALERT_INCREMENT 2
//
// Physical memory offset of KUSER_SHARED_DATA
//
#define KI_USER_SHARED_DATA_PHYSICAL 0x41000
//
// Quantum values and decrements
//
#define MAX_QUANTUM 0x7F
#define WAIT_QUANTUM_DECREMENT 1
#define CLOCK_QUANTUM_DECREMENT 3
//
// Kernel Feature Bits
//
#define KF_V86_VIS 0x00000001
#define KF_RDTSC 0x00000002
#define KF_CR4 0x00000004
#define KF_CMOV 0x00000008
#define KF_GLOBAL_PAGE 0x00000010
#define KF_LARGE_PAGE 0x00000020
#define KF_MTRR 0x00000040
#define KF_CMPXCHG8B 0x00000080
#define KF_MMX 0x00000100
#define KF_WORKING_PTE 0x00000200
#define KF_PAT 0x00000400
#define KF_FXSR 0x00000800
#define KF_FAST_SYSCALL 0x00001000
#define KF_XMMI 0x00002000
#define KF_3DNOW 0x00004000
#define KF_AMDK6MTRR 0x00008000
#define KF_XMMI64 0x00010000
#define KF_DTS 0x00020000
#define KF_BRANCH 0x00020000 // from ksamd64.inc
#define KF_SSE3 0x00080000
#define KF_CMPXCHG16B 0x00100000
#define KF_XSTATE 0x00800000 // from ks386.inc, ksamd64.inc
#define KF_NX_BIT 0x20000000
#define KF_NX_DISABLED 0x40000000
#define KF_NX_ENABLED 0x80000000
#define KF_XSAVEOPT_BIT 15
#define KF_XSTATE_BIT 23
#define KF_RDWRFSGSBASE_BIT 28
//
// Internal Exception Codes
//
#define KI_EXCEPTION_INTERNAL 0x10000000
#define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
typedef struct _FIBER /* Field offsets: */
{ /* i386 arm x64 */
PVOID FiberData; /* 0x000 0x000 0x000 */
struct _EXCEPTION_REGISTRATION_RECORD *ExceptionList;/* 0x004 0x004 0x008 */
PVOID StackBase; /* 0x008 0x008 0x010 */
PVOID StackLimit; /* 0x00C 0x00C 0x018 */
PVOID DeallocationStack; /* 0x010 0x010 0x020 */
CONTEXT FiberContext; /* 0x014 0x018 0x030 */
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
PVOID Wx86Tib; /* 0x2E0 0x1b8 0x500 */
struct _ACTIVATION_CONTEXT_STACK *ActivationContextStackPointer; /* 0x2E4 0x1bc 0x508 */
PVOID FlsData; /* 0x2E8 0x1c0 0x510 */
ULONG GuaranteedStackBytes; /* 0x2EC 0x1c4 0x518 */
ULONG TebFlags; /* 0x2F0 0x1c8 0x51C */
#else
ULONG GuaranteedStackBytes; /* 0x2E0 */
PVOID FlsData; /* 0x2E4 */
struct _ACTIVATION_CONTEXT_STACK *ActivationContextStackPointer;
#endif
} FIBER, *PFIBER;
#ifndef NTOS_MODE_USER
//
// Number of dispatch codes supported by KINTERRUPT
//
#ifdef _M_AMD64
#define DISPATCH_LENGTH 4
#elif (NTDDI_VERSION >= NTDDI_LONGHORN)
#define DISPATCH_LENGTH 135
#else
#define DISPATCH_LENGTH 106
#endif
#else
//
// KPROCESSOR_MODE Type
//
typedef CCHAR KPROCESSOR_MODE;
//
// Dereferencable pointer to KUSER_SHARED_DATA in User-Mode
//
#define SharedUserData ((KUSER_SHARED_DATA *)USER_SHARED_DATA)
//
// Maximum WOW64 Entries in KUSER_SHARED_DATA
//
#define MAX_WOW64_SHARED_ENTRIES 16
//
// Maximum Processor Features supported in KUSER_SHARED_DATA
//
#define PROCESSOR_FEATURE_MAX 64
//
// Event Types
//
typedef enum _EVENT_TYPE
{
NotificationEvent,
SynchronizationEvent
} EVENT_TYPE;
//
// Timer Types
//
typedef enum _TIMER_TYPE
{
NotificationTimer,
SynchronizationTimer
} TIMER_TYPE;
//
// Wait Types
//
typedef enum _WAIT_TYPE
{
WaitAll,
WaitAny
} WAIT_TYPE;
//
// Processor Execution Modes
//
typedef enum _MODE
{
KernelMode,
UserMode,
MaximumMode
} MODE;
//
// Wait Reasons
//
typedef enum _KWAIT_REASON
{
Executive,
FreePage,
PageIn,
PoolAllocation,
DelayExecution,
Suspended,
UserRequest,
WrExecutive,
WrFreePage,
WrPageIn,
WrPoolAllocation,
WrDelayExecution,
WrSuspended,
WrUserRequest,
WrEventPair,
WrQueue,
WrLpcReceive,
WrLpcReply,
WrVirtualMemory,
WrPageOut,
WrRendezvous,
Spare2,
WrGuardedMutex,
Spare4,
Spare5,
Spare6,
WrKernel,
WrResource,
WrPushLock,
WrMutex,
WrQuantumEnd,
WrDispatchInt,
WrPreempted,
WrYieldExecution,
MaximumWaitReason
} KWAIT_REASON;
//
// Profiling Sources
//
typedef enum _KPROFILE_SOURCE
{
ProfileTime,
ProfileAlignmentFixup,
ProfileTotalIssues,
ProfilePipelineDry,
ProfileLoadInstructions,
ProfilePipelineFrozen,
ProfileBranchInstructions,
ProfileTotalNonissues,
ProfileDcacheMisses,
ProfileIcacheMisses,
ProfileCacheMisses,
ProfileBranchMispredictions,
ProfileStoreInstructions,
ProfileFpInstructions,
ProfileIntegerInstructions,
Profile2Issue,
Profile3Issue,
Profile4Issue,
ProfileSpecialInstructions,
ProfileTotalCycles,
ProfileIcacheIssues,
ProfileDcacheAccesses,
ProfileMemoryBarrierCycles,
ProfileLoadLinkedIssues,
ProfileMaximum
} KPROFILE_SOURCE;
//
// NT Product and Architecture Types
//
typedef enum _NT_PRODUCT_TYPE
{
NtProductWinNt = 1,
NtProductLanManNt,
NtProductServer
} NT_PRODUCT_TYPE, *PNT_PRODUCT_TYPE;
typedef enum _ALTERNATIVE_ARCHITECTURE_TYPE
{
StandardDesign,
NEC98x86,
EndAlternatives
} ALTERNATIVE_ARCHITECTURE_TYPE;
#endif
//
// Thread States
//
typedef enum _KTHREAD_STATE
{
Initialized,
Ready,
Running,
Standby,
Terminated,
Waiting,
Transition,
DeferredReady,
#if (NTDDI_VERSION >= NTDDI_WS03)
GateWait
#endif
} KTHREAD_STATE, *PKTHREAD_STATE;
//
// Kernel Object Types
//
typedef enum _KOBJECTS
{
EventNotificationObject = 0,
EventSynchronizationObject = 1,
MutantObject = 2,
ProcessObject = 3,
QueueObject = 4,
SemaphoreObject = 5,
ThreadObject = 6,
GateObject = 7,
TimerNotificationObject = 8,
TimerSynchronizationObject = 9,
Spare2Object = 10,
Spare3Object = 11,
Spare4Object = 12,
Spare5Object = 13,
Spare6Object = 14,
Spare7Object = 15,
Spare8Object = 16,
Spare9Object = 17,
ApcObject = 18,
DpcObject = 19,
DeviceQueueObject = 20,
EventPairObject = 21,
InterruptObject = 22,
ProfileObject = 23,
ThreadedDpcObject = 24,
MaximumKernelObject = 25
} KOBJECTS;
//
// Adjust reasons
//
typedef enum _ADJUST_REASON
{
AdjustNone = 0,
AdjustUnwait = 1,
AdjustBoost = 2
} ADJUST_REASON;
//
// Continue Status
//
typedef enum _KCONTINUE_STATUS
{
ContinueError = 0,
ContinueSuccess,
ContinueProcessorReselected,
ContinueNextProcessor
} KCONTINUE_STATUS;
//
// Process States
//
typedef enum _KPROCESS_STATE
{
ProcessInMemory,
ProcessOutOfMemory,
ProcessInTransition,
ProcessInSwap,
ProcessOutSwap,
} KPROCESS_STATE, *PKPROCESS_STATE;
//
// NtVdmControl Classes
//
typedef enum _VDMSERVICECLASS
{
VdmStartExecution = 0,
VdmQueueInterrupt = 1,
VdmDelayInterrupt = 2,
VdmInitialize = 3,
VdmFeatures = 4,
VdmSetInt21Handler = 5,
VdmQueryDir = 6,
VdmPrinterDirectIoOpen = 7,
VdmPrinterDirectIoClose = 8,
VdmPrinterInitialize = 9,
VdmSetLdtEntries = 10,
VdmSetProcessLdtInfo = 11,
VdmAdlibEmulation = 12,
VdmPMCliControl = 13,
VdmQueryVdmProcess = 14,
} VDMSERVICECLASS;
#ifdef NTOS_MODE_USER
//
// APC Normal Routine
//
typedef VOID
(NTAPI *PKNORMAL_ROUTINE)(
_In_ PVOID NormalContext,
_In_ PVOID SystemArgument1,
_In_ PVOID SystemArgument2
);
//
// Timer Routine
//
typedef VOID
(NTAPI *PTIMER_APC_ROUTINE)(
_In_ PVOID TimerContext,
_In_ ULONG TimerLowValue,
_In_ LONG TimerHighValue
);
//
// System Time Structure
//
typedef struct _KSYSTEM_TIME
{
ULONG LowPart;
LONG High1Time;
LONG High2Time;
} KSYSTEM_TIME, *PKSYSTEM_TIME;
//
// Shared Kernel User Data
//
typedef struct _KUSER_SHARED_DATA
{
ULONG TickCountLowDeprecated;
ULONG TickCountMultiplier;
volatile KSYSTEM_TIME InterruptTime;
volatile KSYSTEM_TIME SystemTime;
volatile KSYSTEM_TIME TimeZoneBias;
USHORT ImageNumberLow;
USHORT ImageNumberHigh;
WCHAR NtSystemRoot[260];
ULONG MaxStackTraceDepth;
ULONG CryptoExponent;
ULONG TimeZoneId;
ULONG LargePageMinimum;
ULONG Reserved2[7];
NT_PRODUCT_TYPE NtProductType;
BOOLEAN ProductTypeIsValid;
ULONG NtMajorVersion;
ULONG NtMinorVersion;
BOOLEAN ProcessorFeatures[PROCESSOR_FEATURE_MAX];
ULONG Reserved1;
ULONG Reserved3;
volatile ULONG TimeSlip;
ALTERNATIVE_ARCHITECTURE_TYPE AlternativeArchitecture;
LARGE_INTEGER SystemExpirationDate;
ULONG SuiteMask;
BOOLEAN KdDebuggerEnabled;
#if (NTDDI_VERSION >= NTDDI_WINXPSP2)
UCHAR NXSupportPolicy;
#endif
volatile ULONG ActiveConsoleId;
volatile ULONG DismountCount;
ULONG ComPlusPackage;
ULONG LastSystemRITEventTickCount;
ULONG NumberOfPhysicalPages;
BOOLEAN SafeBootMode;
ULONG TraceLogging;
ULONG Fill0;
ULONGLONG TestRetInstruction;
ULONG SystemCall;
ULONG SystemCallReturn;
ULONGLONG SystemCallPad[3];
union {
volatile KSYSTEM_TIME TickCount;
volatile ULONG64 TickCountQuad;
};
ULONG Cookie;
#if (NTDDI_VERSION >= NTDDI_WS03)
LONGLONG ConsoleSessionForegroundProcessId;
ULONG Wow64SharedInformation[MAX_WOW64_SHARED_ENTRIES];
#endif
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
USHORT UserModeGlobalLogger[8];
ULONG HeapTracingPid[2];
ULONG CritSecTracingPid[2];
union
{
ULONG SharedDataFlags;
struct
{
ULONG DbgErrorPortPresent:1;
ULONG DbgElevationEnabled:1;
ULONG DbgVirtEnabled:1;
ULONG DbgInstallerDetectEnabled:1;
ULONG SpareBits:28;
};
};
ULONG ImageFileExecutionOptions;
KAFFINITY ActiveProcessorAffinity;
#endif
} KUSER_SHARED_DATA, *PKUSER_SHARED_DATA;
//
// VDM Structures
//
#include "pshpack1.h"
typedef struct _VdmVirtualIca
{
LONG ica_count[8];
LONG ica_int_line;
LONG ica_cpu_int;
USHORT ica_base;
USHORT ica_hipiri;
USHORT ica_mode;
UCHAR ica_master;
UCHAR ica_irr;
UCHAR ica_isr;
UCHAR ica_imr;
UCHAR ica_ssr;
} VDMVIRTUALICA, *PVDMVIRTUALICA;
#include "poppack.h"
typedef struct _VdmIcaUserData
{
PVOID pIcaLock;
PVDMVIRTUALICA pIcaMaster;
PVDMVIRTUALICA pIcaSlave;
PULONG pDelayIrq;
PULONG pUndelayIrq;
PULONG pDelayIret;
PULONG pIretHooked;
PULONG pAddrIretBopTable;
PHANDLE phWowIdleEvent;
PLARGE_INTEGER pIcaTimeout;
PHANDLE phMainThreadSuspended;
} VDMICAUSERDATA, *PVDMICAUSERDATA;
typedef struct _VDM_INITIALIZE_DATA
{
PVOID TrapcHandler;
PVDMICAUSERDATA IcaUserData;
} VDM_INITIALIZE_DATA, *PVDM_INITIALIZE_DATA;
#else
//
// System Thread Start Routine
//
typedef
VOID
(NTAPI *PKSYSTEM_ROUTINE)(
PKSTART_ROUTINE StartRoutine,
PVOID StartContext
);
#ifndef _NTSYSTEM_
typedef VOID
(NTAPI *PKNORMAL_ROUTINE)(
IN PVOID NormalContext OPTIONAL,
IN PVOID SystemArgument1 OPTIONAL,
IN PVOID SystemArgument2 OPTIONAL);
typedef VOID
(NTAPI *PKRUNDOWN_ROUTINE)(
IN struct _KAPC *Apc);
typedef VOID
(NTAPI *PKKERNEL_ROUTINE)(
IN struct _KAPC *Apc,
IN OUT PKNORMAL_ROUTINE *NormalRoutine OPTIONAL,
IN OUT PVOID *NormalContext OPTIONAL,
IN OUT PVOID *SystemArgument1 OPTIONAL,
IN OUT PVOID *SystemArgument2 OPTIONAL);
#endif
//
// APC Environment Types
//
typedef enum _KAPC_ENVIRONMENT
{
OriginalApcEnvironment,
AttachedApcEnvironment,
CurrentApcEnvironment,
InsertApcEnvironment
} KAPC_ENVIRONMENT;
typedef struct _KTIMER_TABLE_ENTRY
{
#if (NTDDI_VERSION >= NTDDI_LONGHORN) || defined(_M_ARM) || defined(_M_AMD64)
KSPIN_LOCK Lock;
#endif
LIST_ENTRY Entry;
ULARGE_INTEGER Time;
} KTIMER_TABLE_ENTRY, *PKTIMER_TABLE_ENTRY;
typedef struct _KTIMER_TABLE
{
PKTIMER TimerExpiry[64];
KTIMER_TABLE_ENTRY TimerEntries[256];
} KTIMER_TABLE, *PKTIMER_TABLE;
typedef struct _KDPC_LIST
{
SINGLE_LIST_ENTRY ListHead;
SINGLE_LIST_ENTRY* LastEntry;
} KDPC_LIST, *PKDPC_LIST;
typedef struct _SYNCH_COUNTERS
{
ULONG SpinLockAcquireCount;
ULONG SpinLockContentionCount;
ULONG SpinLockSpinCount;
ULONG IpiSendRequestBroadcastCount;
ULONG IpiSendRequestRoutineCount;
ULONG IpiSendSoftwareInterruptCount;
ULONG ExInitializeResourceCount;
ULONG ExReInitializeResourceCount;
ULONG ExDeleteResourceCount;
ULONG ExecutiveResourceAcquiresCount;
ULONG ExecutiveResourceContentionsCount;
ULONG ExecutiveResourceReleaseExclusiveCount;
ULONG ExecutiveResourceReleaseSharedCount;
ULONG ExecutiveResourceConvertsCount;
ULONG ExAcqResExclusiveAttempts;
ULONG ExAcqResExclusiveAcquiresExclusive;
ULONG ExAcqResExclusiveAcquiresExclusiveRecursive;
ULONG ExAcqResExclusiveWaits;
ULONG ExAcqResExclusiveNotAcquires;
ULONG ExAcqResSharedAttempts;
ULONG ExAcqResSharedAcquiresExclusive;
ULONG ExAcqResSharedAcquiresShared;
ULONG ExAcqResSharedAcquiresSharedRecursive;
ULONG ExAcqResSharedWaits;
ULONG ExAcqResSharedNotAcquires;
ULONG ExAcqResSharedStarveExclusiveAttempts;
ULONG ExAcqResSharedStarveExclusiveAcquiresExclusive;
ULONG ExAcqResSharedStarveExclusiveAcquiresShared;
ULONG ExAcqResSharedStarveExclusiveAcquiresSharedRecursive;
ULONG ExAcqResSharedStarveExclusiveWaits;
ULONG ExAcqResSharedStarveExclusiveNotAcquires;
ULONG ExAcqResSharedWaitForExclusiveAttempts;
ULONG ExAcqResSharedWaitForExclusiveAcquiresExclusive;
ULONG ExAcqResSharedWaitForExclusiveAcquiresShared;
ULONG ExAcqResSharedWaitForExclusiveAcquiresSharedRecursive;
ULONG ExAcqResSharedWaitForExclusiveWaits;
ULONG ExAcqResSharedWaitForExclusiveNotAcquires;
ULONG ExSetResOwnerPointerExclusive;
ULONG ExSetResOwnerPointerSharedNew;
ULONG ExSetResOwnerPointerSharedOld;
ULONG ExTryToAcqExclusiveAttempts;
ULONG ExTryToAcqExclusiveAcquires;
ULONG ExBoostExclusiveOwner;
ULONG ExBoostSharedOwners;
ULONG ExEtwSynchTrackingNotificationsCount;
ULONG ExEtwSynchTrackingNotificationsAccountedCount;
} SYNCH_COUNTERS, *PSYNCH_COUNTERS;
//
// PRCB DPC Data
//
typedef struct _KDPC_DATA
{
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
KDPC_LIST DpcList;
#else
LIST_ENTRY DpcListHead;
#endif
ULONG_PTR DpcLock;
#if defined(_M_AMD64) || defined(_M_ARM)
volatile LONG DpcQueueDepth;
#else
volatile ULONG DpcQueueDepth;
#endif
ULONG DpcCount;
#if (NTDDI_VERSION >= NTDDI_LONGHORN) || defined(_M_ARM)
PKDPC ActiveDpc;
#endif
} KDPC_DATA, *PKDPC_DATA;
//
// Per-Processor Lookaside List
//
typedef struct _PP_LOOKASIDE_LIST
{
struct _GENERAL_LOOKASIDE *P;
struct _GENERAL_LOOKASIDE *L;
} PP_LOOKASIDE_LIST, *PPP_LOOKASIDE_LIST;
//
// Architectural Types
//
#include <..\ndk\arch/ketypes.h>
//
// Kernel Memory Node
//
#include <pshpack1.h>
typedef struct _KNODE
{
SLIST_HEADER DeadStackList;
SLIST_HEADER PfnDereferenceSListHead;
KAFFINITY ProcessorMask;
ULONG Color;
UCHAR Seed;
UCHAR NodeNumber;
ULONG Flags;
ULONG MmShiftedColor;
ULONG FreeCount[2];
struct _SINGLE_LIST_ENTRY *PfnDeferredList;
} KNODE, *PKNODE;
#include <poppack.h>
//
// Structure for Get/SetContext APC
//
typedef struct _GETSETCONTEXT
{
KAPC Apc;
KEVENT Event;
KPROCESSOR_MODE Mode;
CONTEXT Context;
} GETSETCONTEXT, *PGETSETCONTEXT;
//
// Kernel Profile Object
//
typedef struct _KPROFILE
{
CSHORT Type;
CSHORT Size;
LIST_ENTRY ProfileListEntry;
struct _KPROCESS *Process;
PVOID RangeBase;
PVOID RangeLimit;
ULONG BucketShift;
PVOID Buffer;
ULONG_PTR Segment;
KAFFINITY Affinity;
KPROFILE_SOURCE Source;
BOOLEAN Started;
} KPROFILE, *PKPROFILE;
typedef void(*PKINTERRUPT_ROUTINE)(void);
//
// Kernel Interrupt Object
//
typedef struct _KINTERRUPT
{
CSHORT Type;
CSHORT Size;
LIST_ENTRY InterruptListEntry;
PKSERVICE_ROUTINE ServiceRoutine;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
PKSERVICE_ROUTINE MessageServiceRoutine;
ULONG MessageIndex;
#endif
PVOID ServiceContext;
KSPIN_LOCK SpinLock;
ULONG TickCount;
PKSPIN_LOCK ActualLock;
PKINTERRUPT_ROUTINE DispatchAddress;
ULONG Vector;
KIRQL Irql;
KIRQL SynchronizeIrql;
BOOLEAN FloatingSave;
BOOLEAN Connected;
CCHAR Number;
BOOLEAN ShareVector;
KINTERRUPT_MODE Mode;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
KINTERRUPT_POLARITY Polarity;
#endif
ULONG ServiceCount;
ULONG DispatchCount;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
ULONGLONG Rsvd1;
#endif
#ifdef _M_AMD64
PKTRAP_FRAME TrapFrame;
PVOID Reserved;
#endif
ULONG DispatchCode[DISPATCH_LENGTH];
} KINTERRUPT;
//
// Kernel Event Pair Object
//
typedef struct _KEVENT_PAIR
{
CSHORT Type;
CSHORT Size;
KEVENT LowEvent;
KEVENT HighEvent;
} KEVENT_PAIR, *PKEVENT_PAIR;
//
// Kernel No Execute Options
//
typedef struct _KEXECUTE_OPTIONS
{
UCHAR ExecuteDisable:1;
UCHAR ExecuteEnable:1;
UCHAR DisableThunkEmulation:1;
UCHAR Permanent:1;
UCHAR ExecuteDispatchEnable:1;
UCHAR ImageDispatchEnable:1;
UCHAR Spare:2;
} KEXECUTE_OPTIONS, *PKEXECUTE_OPTIONS;
#if (NTDDI_VERSION >= NTDDI_WIN7)
typedef union _KWAIT_STATUS_REGISTER
{
UCHAR Flags;
struct
{
UCHAR State:2;
UCHAR Affinity:1;
UCHAR Priority:1;
UCHAR Apc:1;
UCHAR UserApc:1;
UCHAR Alert:1;
UCHAR Unused:1;
};
} KWAIT_STATUS_REGISTER, *PKWAIT_STATUS_REGISTER;
typedef struct _COUNTER_READING
{
enum _HARDWARE_COUNTER_TYPE Type;
ULONG Index;
ULONG64 Start;
ULONG64 Total;
}COUNTER_READING, *PCOUNTER_READING;
typedef struct _KTHREAD_COUNTERS
{
ULONG64 WaitReasonBitMap;
struct _THREAD_PERFORMANCE_DATA* UserData;
ULONG Flags;
ULONG ContextSwitches;
ULONG64 CycleTimeBias;
ULONG64 HardwareCounters;
COUNTER_READING HwCounter[16];
}KTHREAD_COUNTERS, *PKTHREAD_COUNTERS;
#endif
//
// Kernel Thread (KTHREAD)
//
typedef struct _KTHREAD
{
DISPATCHER_HEADER Header;
#if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
ULONGLONG CycleTime;
#ifndef _WIN64 // [
ULONG HighCycleTime;
#endif // ]
ULONGLONG QuantumTarget;
#else // ][
LIST_ENTRY MutantListHead;
#endif // ]
PVOID InitialStack;
ULONG_PTR StackLimit; // FIXME: PVOID
PVOID KernelStack;
KSPIN_LOCK ThreadLock;
#if (NTDDI_VERSION >= NTDDI_WIN7) // [
KWAIT_STATUS_REGISTER WaitRegister;
BOOLEAN Running;
BOOLEAN Alerted[2];
union
{
struct
{
ULONG KernelStackResident:1;
ULONG ReadyTransition:1;
ULONG ProcessReadyQueue:1;
ULONG WaitNext:1;
ULONG SystemAffinityActive:1;
ULONG Alertable:1;
ULONG GdiFlushActive:1;
ULONG UserStackWalkActive:1;
ULONG ApcInterruptRequest:1;
ULONG ForceDeferSchedule:1;
ULONG QuantumEndMigrate:1;
ULONG UmsDirectedSwitchEnable:1;
ULONG TimerActive:1;
ULONG Reserved:19;
};
LONG MiscFlags;
};
#endif // ]
union
{
KAPC_STATE ApcState;
struct
{
UCHAR ApcStateFill[FIELD_OFFSET(KAPC_STATE, UserApcPending) + 1];
#if (NTDDI_VERSION >= NTDDI_LONGHORN) // [
SCHAR Priority;
#if (NTDDI_VERSION >= NTDDI_WIN7) // [
/* On x86, the following members "fall out" of the union */
volatile ULONG NextProcessor;
volatile ULONG DeferredProcessor;
#else // ][
/* On x86, the following members "fall out" of the union */
volatile USHORT NextProcessor;
volatile USHORT DeferredProcessor;
#endif // ]
#else // ][
UCHAR ApcQueueable;
/* On x86, the following members "fall out" of the union */
volatile UCHAR NextProcessor;
volatile UCHAR DeferredProcessor;
UCHAR AdjustReason;
SCHAR AdjustIncrement;
#endif // ]
};
};
KSPIN_LOCK ApcQueueLock;
#ifndef _M_AMD64 // [
ULONG ContextSwitches;
volatile UCHAR State;
UCHAR NpxState;
KIRQL WaitIrql;
KPROCESSOR_MODE WaitMode;
#endif // ]
LONG_PTR WaitStatus;