-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.h
More file actions
2293 lines (2163 loc) · 61.6 KB
/
process.h
File metadata and controls
2293 lines (2163 loc) · 61.6 KB
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
#pragma once
// @todo: requires "kernel.h"; used: KERNEL_USER_TIMES
#pragma pack(push, 8)
#pragma region process_status
using PPS_POST_PROCESS_INIT_ROUTINE = void(NTAPI*)();
using PS_ATTRIBUTE_NUM = enum _PS_ATTRIBUTE_NUM
{
PsAttributeParentProcess = 0,
PsAttributeDebugObject = 1,
PsAttributeToken = 2,
PsAttributeClientId = 3,
PsAttributeTebAddress = 4,
PsAttributeImageName = 5,
PsAttributeImageInfo = 6,
PsAttributeMemoryReserve = 7,
PsAttributePriorityClass = 8,
PsAttributeErrorMode = 9,
PsAttributeStdHandleInfo = 10,
PsAttributeHandleList = 11,
#if Q_NT_VERSION >= Q_NT_WIN7
PsAttributeGroupAffinity = 12,
PsAttributePreferredNode = 13,
PsAttributeIdealProcessor = 14,
PsAttributeUmsThread = 15,
#if Q_NT_VERSION >= Q_NT_WIN8
PsAttributeExecuteOptions = 16,
#else
PsAttributeMitigationOptions = 16,
#endif
#endif
#if Q_NT_VERSION >= Q_NT_WINBLUE
PsAttributeProtectionLevel = 17,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10
PsAttributeSecureProcess = 18,
PsAttributeJobList = 19,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_TH2
PsAttributeChildProcessPolicy = 20,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS1
PsAttributeAllApplicationPackagesPolicy = 21,
PsAttributeWin32kFilter = 22,
PsAttributeSafeOpenPromptOriginClaim = 23,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS2
PsAttributeBnoIsolation = 24,
PsAttributeDesktopAppPolicy = 25,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS3
PsAttributeChpe = 26,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_20H2
PsAttributeMitigationAuditOptions = 27,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_21H1
PsAttributeMachineType = 28,
PsAttributeComponentFilter = 29,
#endif
#if Q_NT_VERSION >= Q_NT_WIN11
PsAttributeEnableOptionalXStateFeatures = 30,
#endif
#if Q_NT_VERSION >= Q_NT_WIN11_24H2
PsAttributeSupportedMachines = 31,
PsAttributeSveVectorLength = 32,
#endif
PsAttributeMax
};
#define PS_ATTRIBUTE_NUMBER_MASK 0x0000FFFF
#define PS_ATTRIBUTE_THREAD 0x00010000
#define PS_ATTRIBUTE_INPUT 0x00020000
#define PS_ATTRIBUTE_ADDITIVE 0x00040000
_Q_NT_BIT_TEMPLATE struct PS_ATTRIBUTE
{
private:
_Q_NT_BIT_TYPE
public:
BitnessType_t<std::uintptr_t> Attribute; // 0x00
BitnessType_t<std::size_t> Size; // 0x04 / 0x08
union
{
BitnessType_t<std::uintptr_t> Value;
BitnessType_t<void*> ValuePtr;
}; // 0x08 / 0x10
BitnessType_t<std::size_t*> ReturnLength; // 0x0C / 0x18
};
_Q_NT_BIT_ASSERT(PS_ATTRIBUTE, 0x10, 0x20);
_Q_NT_BIT_TEMPLATE struct PS_ATTRIBUTE_LIST
{
private:
_Q_NT_BIT_TYPE
public:
BitnessType_t<std::size_t> TotalLength; // 0x0
PS_ATTRIBUTE<nBitness> Attributes[ANYSIZE_ARRAY]; // 0x4 / 0x8
};
_Q_NT_BIT_TEMPLATE struct PS_MEMORY_RESERVE
{
private:
_Q_NT_BIT_TYPE
public:
BitnessType_t<void*> ReserveAddress; // 0x0
BitnessType_t<std::size_t> ReserveSize; // 0x4 / 0x8
};
_Q_NT_BIT_ASSERT(PS_MEMORY_RESERVE, 0x8, 0x10);
using PS_STD_HANDLE_STATE = enum _PS_STD_HANDLE_STATE
{
PsNeverDuplicate = 0,
PsRequestDuplicate = 1,
PsAlwaysDuplicate = 2,
PsMaxStdHandleStates = 3
};
struct PS_STD_HANDLE_INFO
{
union
{
std::uint32_t Flags;
struct
{
std::uint32_t StdHandleState : 2;
std::uint32_t PseudoHandleMask : 3;
};
}; // 0x0
std::uint32_t StdHandleSubsystemType; // 0x4
};
static_assert(sizeof(PS_STD_HANDLE_INFO) == 0x8);
using PS_CREATE_STATE = enum _PS_CREATE_STATE : std::int32_t
{
PsCreateInitialState = 0,
PsCreateFailOnFileOpen = 1,
PsCreateFailOnSectionCreate = 2,
PsCreateFailExeFormat = 3,
PsCreateFailMachineMismatch = 4,
PsCreateFailExeName = 5,
PsCreateSuccess = 6,
PsCreateMaximumStates = 7
};
_Q_NT_BIT_TEMPLATE struct PS_CREATE_INFO
{
private:
_Q_NT_BIT_TYPE
public:
BitnessType_t<std::size_t> Size; // 0x00
PS_CREATE_STATE State; // 0x04 / 0x08
union
{
struct
{
union
{
std::uint32_t InitFlags;
struct
{
std::uint8_t WriteOutputOnExit : 1;
std::uint8_t DetectManifest : 1;
#if Q_NT_VERSION >= Q_NT_WIN8
#if Q_NT_VERSION >= Q_NT_WIN11
std::uint8_t IFEOSkipRedirects : 1;
#else
std::uint8_t IFEOSkipDebugger : 1;
#endif
std::uint8_t IFEODoNotPropagateKeyState : 1;
std::uint8_t SpareBits1 : 4;
#else
std::uint8_t SpareBits1 : 6;
#endif
#if Q_NT_VERSION >= Q_NT_WIN8
std::uint8_t SpareBits2 : 8;
#else
std::uint8_t IFEOKeyState : 2;
std::uint8_t SpareBits2 : 6;
#endif
std::uint16_t ProhibitedImageCharacteristics : 16;
};
};
ACCESS_MASK AdditionalFileAccess;
} InitState;
struct
{
BitnessType_t<HANDLE> FileHandle;
} FailSection;
#if Q_NT_VERSION >= Q_NT_WIN8
struct
{
std::uint16_t DllCharacteristics;
} ExeFormat;
#endif
struct
{
BitnessType_t<HANDLE> IFEOKey;
} ExeName;
struct
{
union
{
std::uint32_t OutputFlags;
struct
{
std::uint8_t ProtectedProcess : 1;
std::uint8_t AddressSpaceOverride : 1;
std::uint8_t DevOverrideEnabled : 1;
std::uint8_t ManifestDetected : 1;
#if Q_NT_VERSION >= Q_NT_WINBLUE
std::uint8_t ProtectedProcessLight : 1;
std::uint8_t SpareBits1 : 3;
#else
std::uint8_t SpareBits1 : 4;
#endif
std::uint8_t SpareBits2 : 8;
std::uint16_t SpareBits3 : 16;
};
};
BitnessType_t<HANDLE> FileHandle;
BitnessType_t<HANDLE> SectionHandle;
std::uint64_t UserProcessParametersNative;
std::uint32_t UserProcessParametersWow64;
std::uint32_t CurrentParameterFlags;
std::uint64_t PebAddressNative;
std::uint32_t PebAddressWow64;
std::uint64_t ManifestAddress;
std::uint32_t ManifestSize;
} SuccessState;
}; // 0x08 / 0x10
};
_Q_NT_BIT_ASSERT(PS_CREATE_INFO, 0x48, 0x58);
#if Q_NT_VERSION >= Q_NT_WIN7
struct PS_CPU_QUOTA_QUERY_ENTRY
{
std::uint32_t SessionId; // 0x0
std::uint32_t Weight; // 0x4
};
static_assert(sizeof(PS_CPU_QUOTA_QUERY_ENTRY) == 0x8);
struct PS_CPU_QUOTA_QUERY_INFORMATION
{
std::uint32_t SessionCount; // 0x0
PS_CPU_QUOTA_QUERY_ENTRY SessionInformation[ANYSIZE_ARRAY]; // 0x4
};
#endif
#if Q_NT_VERSION >= Q_NT_WINBLUE
#define PROTECTION_LEVEL_WINTCB_LIGHT 0x00000000
#define PROTECTION_LEVEL_WINDOWS 0x00000001
#define PROTECTION_LEVEL_WINDOWS_LIGHT 0x00000002
#define PROTECTION_LEVEL_ANTIMALWARE_LIGHT 0x00000003
#define PROTECTION_LEVEL_LSA_LIGHT 0x00000004
#define PROTECTION_LEVEL_WINTCB 0x00000005
#define PROTECTION_LEVEL_CODEGEN_LIGHT 0x00000006
#define PROTECTION_LEVEL_AUTHENTICODE 0x00000007
#define PROTECTION_LEVEL_PPL_APP 0x00000008
#define PROTECTION_LEVEL_SAME 0xFFFFFFFF
#define PROTECTION_LEVEL_NONE 0xFFFFFFFE
using PS_PROTECTED_TYPE = enum _PS_PROTECTED_TYPE : std::int32_t
{
PsProtectedTypeNone = 0,
PsProtectedTypeProtectedLight = 1,
PsProtectedTypeProtected = 2,
PsProtectedTypeMax = 3
};
using PS_PROTECTED_SIGNER = enum _PS_PROTECTED_SIGNER : std::int32_t
{
PsProtectedSignerNone = 0,
PsProtectedSignerAuthenticode = 1,
PsProtectedSignerCodeGen = 2,
PsProtectedSignerAntimalware = 3,
PsProtectedSignerLsa = 4,
PsProtectedSignerWindows = 5,
PsProtectedSignerWinTcb = 6,
#if Q_NT_VERSION >= Q_NT_WIN10_RS1
PsProtectedSignerWinSystem = 7,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS2
PsProtectedSignerApp = 8,
#endif
PsProtectedSignerMax
};
struct PS_PROTECTION
{
union
{
std::uint8_t Level;
struct
{
std::uint8_t Type : 3;
std::uint8_t Audit : 1;
std::uint8_t Signer : 4;
};
};
};
static_assert(sizeof(PS_PROTECTION) == 0x1);
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_TH2
union PS_TRUSTLET_ATTRIBUTE_ACCESSRIGHTS
{
std::uint8_t AccessRights;
struct
{
std::uint8_t Trustlet : 1;
std::uint8_t Ntos : 1;
std::uint8_t WriteHandle : 1;
std::uint8_t ReadHandle : 1;
std::uint8_t Reserved : 4;
};
};
static_assert(sizeof(PS_TRUSTLET_ATTRIBUTE_ACCESSRIGHTS) == 0x1);
union PS_TRUSTLET_ATTRIBUTE_TYPE
{
std::uint32_t AttributeType;
struct
{
std::uint8_t Version;
std::uint8_t DataCount;
std::uint8_t SemanticType;
PS_TRUSTLET_ATTRIBUTE_ACCESSRIGHTS AccessRights;
};
};
static_assert(sizeof(PS_TRUSTLET_ATTRIBUTE_TYPE) == 0x4);
struct PS_TRUSTLET_ATTRIBUTE_HEADER
{
PS_TRUSTLET_ATTRIBUTE_TYPE AttributeType; // 0x0
struct
{
std::uint32_t InstanceNumber : 8;
std::uint32_t Reserved : 24;
}; // 0x4
};
static_assert(sizeof(PS_TRUSTLET_ATTRIBUTE_HEADER) == 0x8);
struct PS_TRUSTLET_ATTRIBUTE_DATA
{
PS_TRUSTLET_ATTRIBUTE_HEADER Header;
std::uint64_t Data[ANYSIZE_ARRAY];
};
struct PS_TRUSTLET_CREATE_ATTRIBUTES
{
std::uint64_t TrustletIdentity;
PS_TRUSTLET_ATTRIBUTE_DATA Attributes[ANYSIZE_ARRAY];
};
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS2
struct PS_MITIGATION_OPTIONS_MAP
{
std::uint64_t Map[
#if Q_NT_VERSION >= Q_NT_WIN10_20H1
3
#else
2
#endif
];
};
static_assert(sizeof(PS_MITIGATION_OPTIONS_MAP) == 0x18);
_Q_NT_BIT_TEMPLATE struct PS_BNO_ISOLATION_PARAMETERS
{
private:
_Q_NT_BIT_TYPE
public:
UNICODE_STRING<nBitness> IsolationPrefix; // 0x00
std::uint32_t HandleCount; // 0x08 / 0x10
BitnessType_t<void**> Handles; // 0x0C / 0x18
bool IsolationEnabled; // 0x10 / 0x20
};
_Q_NT_BIT_ASSERT(PS_BNO_ISOLATION_PARAMETERS, 0x14, 0x28);
using PS_MITIGATION_OPTION = enum _PS_MITIGATION_OPTION
{
PS_MITIGATION_OPTION_NX = 0,
PS_MITIGATION_OPTION_SEHOP = 1,
PS_MITIGATION_OPTION_FORCE_RELOCATE_IMAGES = 2,
PS_MITIGATION_OPTION_HEAP_TERMINATE = 3,
PS_MITIGATION_OPTION_BOTTOM_UP_ASLR = 4,
PS_MITIGATION_OPTION_HIGH_ENTROPY_ASLR = 5,
PS_MITIGATION_OPTION_STRICT_HANDLE_CHECKS = 6,
PS_MITIGATION_OPTION_WIN32K_SYSTEM_CALL_DISABLE = 7,
PS_MITIGATION_OPTION_EXTENSION_POINT_DISABLE = 8,
PS_MITIGATION_OPTION_PROHIBIT_DYNAMIC_CODE = 9,
PS_MITIGATION_OPTION_CONTROL_FLOW_GUARD = 10,
PS_MITIGATION_OPTION_BLOCK_NON_MICROSOFT_BINARIES = 11,
PS_MITIGATION_OPTION_FONT_DISABLE = 12,
PS_MITIGATION_OPTION_IMAGE_LOAD_NO_REMOTE = 13,
PS_MITIGATION_OPTION_IMAGE_LOAD_NO_LOW_LABEL = 14,
PS_MITIGATION_OPTION_IMAGE_LOAD_PREFER_SYSTEM32 = 15,
PS_MITIGATION_OPTION_RETURN_FLOW_GUARD = 16,
PS_MITIGATION_OPTION_LOADER_INTEGRITY_CONTINUITY = 17,
PS_MITIGATION_OPTION_STRICT_CONTROL_FLOW_GUARD = 18,
PS_MITIGATION_OPTION_RESTRICT_SET_THREAD_CONTEXT = 19,
#if Q_NT_VERSION >= Q_NT_WIN10_RS3
PS_MITIGATION_OPTION_ROP_STACKPIVOT = 20,
PS_MITIGATION_OPTION_ROP_CALLER_CHECK = 21,
PS_MITIGATION_OPTION_ROP_SIMEXEC = 22,
PS_MITIGATION_OPTION_EXPORT_ADDRESS_FILTER = 23,
PS_MITIGATION_OPTION_EXPORT_ADDRESS_FILTER_PLUS = 24,
PS_MITIGATION_OPTION_RESTRICT_CHILD_PROCESS_CREATION = 25,
PS_MITIGATION_OPTION_IMPORT_ADDRESS_FILTER = 26,
PS_MITIGATION_OPTION_MODULE_TAMPERING_PROTECTION = 27,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS4
PS_MITIGATION_OPTION_RESTRICT_INDIRECT_BRANCH_PREDICTION = 28,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS5
PS_MITIGATION_OPTION_SPECULATIVE_STORE_BYPASS_DISABLE = 29,
PS_MITIGATION_OPTION_ALLOW_DOWNGRADE_DYNAMIC_CODE_POLICY = 30,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_19H1
PS_MITIGATION_OPTION_CET_USER_SHADOW_STACKS = 31,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_20H1
PS_MITIGATION_OPTION_USER_CET_SET_CONTEXT_IP_VALIDATION = 32,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_21H1
PS_MITIGATION_OPTION_BLOCK_NON_CET_BINARIES = 33,
PS_MITIGATION_OPTION_XTENDED_CONTROL_FLOW_GUARD = 34,
PS_MITIGATION_OPTION_POINTER_AUTH_USER_IP = 35,
PS_MITIGATION_OPTION_CET_DYNAMIC_APIS_OUT_OF_PROC_ONLY = 36,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_21H2
PS_MITIGATION_OPTION_REDIRECTION_TRUST = 37,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_22H2
PS_MITIGATION_OPTION_RESTRICT_CORE_SHARING = 38,
#endif
#if Q_NT_VERSION >= Q_NT_WIN11_24H2
PS_MITIGATION_OPTION_FSCTL_SYSTEM_CALL_DISABLE = 39
#endif
};
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS3
using PS_MITIGATION_AUDIT_OPTIONS_MAP = PS_MITIGATION_OPTIONS_MAP;
#endif
// @todo: _PS_SYSTEM_DLL_INIT_BLOCK
#if Q_NT_VERSION >= Q_NT_WIN11_24H2
union PS_PROCESS_CREATION_SVE_VECTOR_LENGTH
{
std::uint32_t Data;
struct
{
std::uint32_t VectorLength : 24;
std::uint32_t FlagsReserved : 8;
};
};
static_assert(sizeof(PS_PROCESS_CREATION_SVE_VECTOR_LENGTH) == 0x4);
#endif
#pragma endregion
#pragma region process_environment_block
struct ACTIVATION_CONTEXT_DATA
{
std::uint32_t Magic; // 0x00
std::uint32_t HeaderSize; // 0x04
std::uint32_t FormatVersion; // 0x08
std::uint32_t TotalSize; // 0x0C
std::uint32_t DefaultTocOffset; // 0x10
std::uint32_t ExtendedTocOffset; // 0x14
std::uint32_t AssemblyRosterOffset; // 0x18
std::uint32_t Flags; // 0x1C
};
static_assert(sizeof(ACTIVATION_CONTEXT_DATA) == 0x20);
_Q_NT_BIT_TEMPLATE struct PEB_LDR_DATA
{
private:
_Q_NT_BIT_TYPE
public:
std::uint32_t Length; // 0x00
std::uint8_t Initialized; // 0x04
BitnessType_t<void*> SsHandle; // 0x08
LIST_ENTRY<nBitness> InLoadOrderModuleList; // 0x0C / 0x10
LIST_ENTRY<nBitness> InMemoryOrderModuleList; // 0x14 / 0x20
LIST_ENTRY<nBitness> InInitializationOrderModuleList; // 0x1C / 0x30
BitnessType_t<void*> EntryInProgress; // 0x24 / 0x40
std::uint8_t ShutdownInProgress; // 0x28 / 0x48
BitnessType_t<void*> ShutdownThreadId; // 0x2C / 0x50
};
_Q_NT_BIT_ASSERT(PEB_LDR_DATA, 0x30, 0x58);
// @todo: move to "gdi.h"?
_Q_NT_BIT_TEMPLATE using GDI_HANDLE_BUFFER = std::uint32_t[nBitness == 32U ? 34U : 60U];
_Q_NT_BIT_TEMPLATE struct PEB
{
private:
_Q_NT_BIT_TYPE
public:
bool InheritedAddressSpace; // 0x0000
bool ReadImageFileExecOptions; // 0x0001
bool BeingDebugged; // 0x0002
union
{
std::uint8_t BitField;
struct
{
std::uint8_t ImageUsesLargePages : 1;
std::uint8_t IsProtectedProcess : 1;
#if Q_NT_VERSION <= Q_NT_WIN8
std::uint8_t IsLegacyProcess : 1;
#endif
std::uint8_t IsImageDynamicallyRelocated : 1;
#if Q_NT_VERSION >= Q_NT_VISTA_SP1
std::uint8_t SkipPatchingUser32Forwarders : 1;
#if Q_NT_VERSION >= Q_NT_WIN8
std::uint8_t IsPackagedProcess : 1;
std::uint8_t IsAppContainer : 1;
#if Q_NT_VERSION >= Q_NT_WINBLUE
std::uint8_t IsProtectedProcessLight : 1;
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS1
std::uint8_t IsLongPathAwareProcess : 1;
#else
std::uint8_t SpareBits : 1;
#endif
#else
std::uint8_t SpareBits : 3;
#endif
#else
std::uint8_t SpareBits : 4;
#endif
};
}; // 0x03
BitnessType_t<HANDLE> Mutant; // 0x0004 / 0x0008
BitnessType_t<void*> ImageBaseAddress; // 0x0008 / 0x0010
BitnessType_t<PEB_LDR_DATA<nBitness>*> Ldr; // 0x000C / 0x0018
BitnessType_t<RTL_USER_PROCESS_PARAMETERS<nBitness>*> ProcessParameters; // 0x0010 / 0x0020
BitnessType_t<void*> SubSystemData; // 0x0014 / 0x0028
BitnessType_t<void*> ProcessHeap; // 0x0018 / 0x0030
BitnessType_t<RTL_CRITICAL_SECTION<nBitness>*> FastPebLock; // 0x001C / 0x0038
BitnessType_t<SLIST_HEADER<nBitness>* volatile> AtlThunkSListPtr; // 0x0020 / 0x0040
BitnessType_t<void*> IFEOKey; // 0x0024 / 0x0048
union
{
std::uint32_t CrossProcessFlags;
struct
{
std::uint32_t ProcessInJob : 1;
std::uint32_t ProcessInitializing : 1;
#if Q_NT_VERSION >= Q_NT_VISTA_SP1
std::uint32_t ProcessUsingVEH : 1;
std::uint32_t ProcessUsingVCH : 1;
#if Q_NT_VERSION >= Q_NT_WIN7
std::uint32_t ProcessUsingFTH : 1;
#if Q_NT_VERSION >= Q_NT_WIN10_RS2
std::uint32_t ProcessPreviouslyThrottled : 1;
std::uint32_t ProcessCurrentlyThrottled : 1;
#if Q_NT_VERSION >= Q_NT_WIN10_RS5
std::uint32_t ProcessImagesHotPatched : 1;
std::uint32_t ReservedBits0 : 24;
#else
std::uint32_t ReservedBits0 : 25;
#endif
#else
std::uint32_t ReservedBits0 : 27;
#endif
#else
std::uint32_t ReservedBits0 : 28;
#endif
#else
std::uint32_t ReservedBits0 : 30;
#endif
};
}; // 0x0028 / 0x0050
union
{
BitnessType_t<void*> KernelCallbackTable;
BitnessType_t<void*> UserSharedInfoPtr;
}; // 0x002C / 0x0058
std::uint32_t SystemReserved; // 0x0030 / 0x0060
#if Q_NT_VERSION >= Q_NT_WIN7
std::uint32_t AtlThunkSListPtr32; // 0x0034 / 0x0064
BitnessType_t<void*> ApiSetMap; // 0x0038 / 0x0068
#else
std::uint32_t SpareUlong; // 0x0034 / 0x0064
BitnessType_t<void*> FreeList; // 0x0038 / 0x0068
#endif
std::uint32_t TlsExpansionCounter; // 0x003C / 0x0070
BitnessType_t<void*> TlsBitmap; // 0x0040 / 0x0078
std::uint32_t TlsBitmapBits[2]; // 0x0044 / 0x0080
BitnessType_t<void*> ReadOnlySharedMemoryBase; // 0x004C / 0x0088
#if Q_NT_VERSION >= Q_NT_WIN10_RS2
BitnessType_t<void*> SharedData; // 0x0050 / 0x0090
#else
BitnessType_t<void*> HotpatchInformation; // 0x0050 / 0x0090
#endif
BitnessType_t<void**> ReadOnlyStaticServerData; // 0x0054 / 0x0098
BitnessType_t<void*> AnsiCodePageData; // 0x0058 / 0x00A0
BitnessType_t<void*> OemCodePageData; // 0x005C / 0x00A8
BitnessType_t<void*> UnicodeCaseTableData; // 0x0060 / 0x00B0
std::uint32_t NumberOfProcessors; // 0x0064 / 0x00B8
std::uint32_t NtGlobalFlag; // 0x0068 / 0x00BC // FLG_*
LARGE_INTEGER CriticalSectionTimeout; // 0x0070 / 0x00C0
BitnessType_t<std::size_t> HeapSegmentReserve; // 0x0078 / 0x00C8
BitnessType_t<std::size_t> HeapSegmentCommit; // 0x007C / 0x00D0
BitnessType_t<std::size_t> HeapDeCommitTotalFreeThreshold; // 0x0080 / 0x00D8
BitnessType_t<std::size_t> HeapDeCommitFreeBlockThreshold; // 0x0084 / 0x00E0
std::uint32_t NumberOfHeaps; // 0x0088 / 0x00E8
std::uint32_t MaximumNumberOfHeaps; // 0x008C / 0x00EC
BitnessType_t<void**> ProcessHeaps; // 0x0090 / 0x00F0
BitnessType_t<void*> GdiSharedHandleTable; // 0x0094 / 0x00F8
BitnessType_t<void*> ProcessStarterHelper; // 0x0098 / 0x0100
std::uint32_t GdiDCAttributeList; // 0x009C / 0x108
BitnessType_t<RTL_CRITICAL_SECTION<nBitness>*> LoaderLock; // 0x00A0 / 0x0110
std::uint32_t OSMajorVersion; // 0x00A4 / 0x0118
std::uint32_t OSMinorVersion; // 0x00A8 / 0x011C
std::uint16_t OSBuildNumber; // 0x00AC / 0x0120
std::uint16_t OSCSDVersion; // 0x00AE / 0x0122
std::uint32_t OSPlatformId; // 0x00B0 / 0x0124
std::uint32_t ImageSubsystem; // 0x00B4 / 0x0128
std::uint32_t ImageSubsystemMajorVersion; // 0x00B8 / 0x012C
std::uint32_t ImageSubsystemMinorVersion; // 0x00BC / 0x0130
BitnessType_t<KAFFINITY> ActiveProcessAffinityMask; // 0x00C0 / 0x0134
GDI_HANDLE_BUFFER<nBitness> GdiHandleBuffer; // 0x00C4 / 0x0140
BitnessType_t<PPS_POST_PROCESS_INIT_ROUTINE> PostProcessInitRoutine; // 0x014C / 0x0230
BitnessType_t<void*> TlsExpansionBitmap; // 0x0150 / 0x0238
std::uint32_t TlsExpansionBitmapBits[32]; // 0x0154 / 0x0240
std::uint32_t SessionId; // 0x01D4 / 0x02C0
ULARGE_INTEGER AppCompatFlags; // 0x01D8 / 0x02C8
ULARGE_INTEGER AppCompatFlagsUser; // 0x01E0 / 0x02D0
BitnessType_t<void*> pShimData; // 0x01E8 / 0x02D8
BitnessType_t<void*> AppCompatInfo; // 0x01EC / 0x02E0
UNICODE_STRING<nBitness> CSDVersion; // 0x01F0 / 0x02E8
BitnessType_t<ACTIVATION_CONTEXT_DATA*> ActivationContextData; // 0x01F8 / 0x02F8
BitnessType_t<struct ASSEMBLY_STORAGE_MAP*> ProcessAssemblyStorageMap; // 0x01FC / 0x0300
BitnessType_t<ACTIVATION_CONTEXT_DATA*> SystemDefaultActivationContextData; // 0x0200 / 0x0308
BitnessType_t<struct ASSEMBLY_STORAGE_MAP*> SystemAssemblyStorageMap; // 0x0204 / 0x0310
BitnessType_t<std::size_t> MinimumStackCommit; // 0x0208 / 0x0318
// @todo: since XP_SP2/SP3
BitnessType_t<struct FLS_CALLBACK_INFO*> FlsCallback; // 0x020C / 0x0320
LIST_ENTRY<nBitness> FlsListHead; // 0x0210
BitnessType_t<void*> FlsBitmap; // 0x0218
std::uint32_t SpareUlongs[5]; // 0x021C
#if Q_NT_VERSION >= Q_NT_VISTA
BitnessType_t<void*> WerRegistrationData; // 0x0230 / 0x0358
BitnessType_t<void*> WerShipAssertPtr; // 0x0234 / 0x0360
#endif
#if Q_NT_VERSION >= Q_NT_WIN7
BitnessType_t<void*> Unused; // 0x0238 / 0x0368
BitnessType_t<void*> pImageHeaderHash; // 0x023C / 0x0370
std::uint32_t TracingFlags; // 0x0240 / 0x0378
#endif
#if Q_NT_VERSION >= Q_NT_WIN8
std::uint64_t CsrServerReadOnlySharedMemoryBase; // 0x0248 / 0x0380
#endif
#if Q_NT_VERSION >= Q_NT_WIN10
std::uint32_t TppWorkerpListLock; // 0x0250 / 0x0388
LIST_ENTRY<nBitness> TppWorkerpList; // 0x0254 / 0x0390
BitnessType_t<void*> WaitOnAddressHashTable[128]; // 0x025C / 0x03A0
BitnessType_t<void*> TelemetryCoverageHeader; // 0x045C / 0x07A0
std::uint32_t CloudFileFlags; // 0x0460 / 0x07A8
std::uint32_t CloudFileDiagFlags; // 0x0464 / 0x07AC
std::int8_t PlaceholderCompatibilityMode; // 0x0468 / 0x07B0 // @note: originally "PlaceholderCompatibiltyMode"
std::int8_t PlaceholderCompatibilityModeReserved[7]; // 0x469 / 0x7B1
BitnessType_t<struct LEAP_SECOND_DATA*> LeapSecondData; // 0x0470 / 0x07B8
std::uint32_t LeapSecondFlags; // 0x0474 / 0x07C0
std::uint32_t NtGlobalFlag2; // 0x0478 / 0x07C4
std::uint64_t ExtendedFeatureDisableMask; // 0x0480 / 0x07C8
#endif
};
_Q_NT_BIT_ASSERT(PEB, 0x488, 0x7D0);
#pragma endregion
#pragma region process_information
// @note: originally "_PROCESSINFOCLASS"
using PROCESS_INFORMATION_CLASS = enum _PROCESS_INFORMATION_CLASS : std::uint32_t
{
ProcessBasicInformation = 0,
ProcessQuotaLimits = 1,
ProcessIoCounters = 2,
ProcessVmCounters = 3,
ProcessTimes = 4,
ProcessBasePriority = 5,
ProcessRaisePriority = 6,
ProcessDebugPort = 7,
ProcessExceptionPort = 8,
ProcessAccessToken = 9,
ProcessLdtInformation = 10,
ProcessLdtSize = 11,
ProcessDefaultHardErrorMode = 12,
ProcessIoPortHandlers = 13,
ProcessPooledUsageAndLimits = 14,
ProcessWorkingSetWatch = 15,
ProcessUserModeIOPL = 16, // requires 'SeTcbPrivilege'
ProcessEnableAlignmentFaultFixup = 17,
ProcessPriorityClass = 18,
ProcessWx86Information = 19, // requires 'SeTcbPrivilege'
ProcessHandleCount = 20,
ProcessAffinityMask = 21,
ProcessPriorityBoost = 22,
ProcessDeviceMap = 23,
ProcessSessionInformation = 24,
ProcessForegroundInformation = 25,
ProcessWow64Information = 26,
ProcessImageFileName = 27,
ProcessLUIDDeviceMapsEnabled = 28,
ProcessBreakOnTermination = 29,
ProcessDebugObjectHandle = 30,
ProcessDebugFlags = 31,
ProcessHandleTracing = 32,
ProcessIoPriority = 33,
ProcessExecuteFlags = 34,
ProcessResourceManagement = 35,
ProcessCookie = 36,
ProcessImageInformation = 37,
#if Q_NT_VERSION >= Q_NT_VISTA
ProcessCycleTime = 38,
ProcessPagePriority = 39,
ProcessInstrumentationCallback = 40,
ProcessThreadStackAllocation = 41,
ProcessWorkingSetWatchEx = 42,
ProcessImageFileNameWin32 = 43,
ProcessImageFileMapping = 44,
#endif
#if Q_NT_VERSION >= Q_NT_VISTA_SP1
ProcessAffinityUpdateMode = 45,
ProcessMemoryAllocationMode = 46,
#endif
#if Q_NT_VERSION >= Q_NT_WIN7
ProcessGroupInformation = 47,
ProcessTokenVirtualizationEnabled = 48,
ProcessConsoleHostProcess = 49,
ProcessWindowInformation = 50,
#endif
#if Q_NT_VERSION >= Q_NT_WIN8
ProcessHandleInformation = 51,
ProcessMitigationPolicy = 52,
ProcessDynamicFunctionTableInformation = 53,
ProcessHandleCheckingMode = 54,
ProcessKeepAliveCount = 55,
ProcessRevokeFileHandles = 56,
ProcessWorkingSetControl = 57,
#endif
#if Q_NT_VERSION >= Q_NT_WINBLUE
ProcessHandleTable = 58,
ProcessCheckStackExtentsMode = 59,
ProcessCommandLineInformation = 60,
ProcessProtectionInformation = 61,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10
ProcessMemoryExhaustion = 62,
ProcessFaultInformation = 63,
ProcessTelemetryIdInformation = 64,
ProcessCommitReleaseInformation = 65,
ProcessDefaultCpuSetsInformation = 66,
ProcessAllowedCpuSetsInformation = 67,
ProcessSubsystemProcess = 68,
ProcessJobMemoryInformation = 69,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_TH2
ProcessInPrivate = 70,
ProcessRaiseUMExceptionOnInvalidHandleClose = 71,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS1
ProcessIumChallengeResponse = 72,
ProcessChildProcessInformation = 73,
ProcessHighGraphicsPriorityInformation = 74, // requires 'SeTcbPrivilege'
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS2
ProcessSubsystemInformation = 75,
ProcessEnergyValues = 76,
#if Q_NT_VERSION >= Q_NT_WIN10_RS3
ProcessPowerThrottlingState = 77,
ProcessReserved3Information = 78,
#else
ProcessActivityThrottleState = 77,
ProcessActivityThrottlePolicy = 78,
#endif
ProcessWin32kSyscallFilterInformation = 79,
ProcessDisableSystemAllowedCpuSets = 80,
ProcessWakeInformation = 81,
ProcessEnergyTrackingState = 82,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS3
ProcessManageWritesToExecutableMemory = 83,
ProcessCaptureTrustletLiveDump = 84,
ProcessTelemetryCoverage = 85,
ProcessEnclaveInformation = 86,
ProcessEnableReadWriteVmLogging = 87,
ProcessUptimeInformation = 88,
ProcessImageSection = 89,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS4
ProcessDebugAuthInformation = 90,
ProcessSystemResourceManagement = 91,
ProcessSequenceNumber = 92,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_RS5
ProcessLoaderDetour = 93,
ProcessSecurityDomainInformation = 94,
ProcessCombineSecurityDomainsInformation = 95,
ProcessEnableLogging = 96,
ProcessLeapSecondInformation = 97,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_19H1
ProcessFiberShadowStackAllocation = 98,
ProcessFreeFiberShadowStackAllocation = 99,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_20H1
ProcessAltSystemCallInformation = 100,
ProcessDynamicEHContinuationTargets = 101,
#endif
#if Q_NT_VERSION >= Q_NT_WIN10_21H1
ProcessDynamicEnforcedCetCompatibleRanges = 102,
#endif
#if Q_NT_VERSION >= Q_NT_WIN11
ProcessCreateStateChange = 103,
ProcessApplyStateChange = 104,
ProcessEnableOptionalXStateFeatures = 105,
#endif
#if Q_NT_VERSION >= Q_NT_WIN11_22H2
ProcessAltPrefetchParam = 106,
ProcessAssignCpuPartitions = 107,
ProcessPriorityClassEx = 108,
ProcessMembershipInformation = 109,
ProcessEffectiveIoPriority = 110,
ProcessEffectivePagePriority = 111,
#endif
#if Q_NT_VERSION >= Q_NT_WIN11_24H2
ProcessSchedulerSharedData = 112,
ProcessSlistRollbackInformation = 113,
ProcessNetworkIoCounters = 114,
ProcessFindFirstThreadByTebValue = 115,
#endif
#if Q_NT_VERSION >= Q_NT_WIN11_25H2
ProcessEnclaveAddressSpaceRestriction = 116,
ProcessAvailableCpus = 117,
#endif
MaxProcessInfoClass
};
_Q_NT_BIT_TEMPLATE struct PROCESS_BASIC_INFORMATION
{
private:
_Q_NT_BIT_TYPE
public:
NTSTATUS ExitStatus; // 0x00
BitnessType_t<std::uintptr_t> PebBaseAddress; // 0x04 / 0x08
BitnessType_t<KAFFINITY> AffinityMask; // 0x08 / 0x10
KPRIORITY BasePriority; // 0x0C / 0x18
BitnessType_t<std::uintptr_t> UniqueProcessId; // 0x10 / 0x20
BitnessType_t<std::uintptr_t> InheritedFromUniqueProcessId; // 0x14 / 0x28
};
_Q_NT_BIT_ASSERT(PROCESS_BASIC_INFORMATION, 0x18, 0x30);
_Q_NT_BIT_TEMPLATE struct PROCESS_EXTENDED_BASIC_INFORMATION
{
private:
_Q_NT_BIT_TYPE
public:
BitnessType_t<std::size_t> Size; // 0x00
PROCESS_BASIC_INFORMATION<nBitness> BasicInfo; // 0x04 / 0x08
union
{
std::uint32_t Flags;
struct
{
std::uint32_t IsProtectedProcess : 1;
std::uint32_t IsWow64Process : 1;
#if Q_NT_VERSION >= Q_NT_WIN7
std::uint32_t IsProcessDeleting : 1;
std::uint32_t IsCrossSessionCreate : 1;
#if Q_NT_VERSION >= Q_NT_WIN8
std::uint32_t IsFrozen : 1;
std::uint32_t IsBackground : 1;
std::uint32_t IsStronglyNamed : 1;
#if Q_NT_VERSION >= Q_NT_WIN10
std::uint32_t IsSecureProcess : 1;
#if Q_NT_VERSION >= Q_NT_WIN10_RS2
std::uint32_t IsSubsystemProcess : 1;
#if Q_NT_VERSION >= Q_NT_WIN11_24H2
std::uint32_t IsTrustedApp : 1;
std::uint32_t SpareBits : 22;
#else
std::uint32_t SpareBits : 23;
#endif
#else
std::uint32_t SpareBits : 24;
#endif
#else
std::uint32_t SpareBits : 25;
#endif
#else
std::uint32_t SpareBits : 28;
#endif
#else
std::uint32_t SpareBits : 30;
#endif
};
}; // 0x1C / 0x38
};
_Q_NT_BIT_ASSERT(PROCESS_EXTENDED_BASIC_INFORMATION, 0x20, 0x40);
_Q_NT_BIT_TEMPLATE struct VM_COUNTERS
{
private:
_Q_NT_BIT_TYPE
public:
BitnessType_t<std::size_t> PeakVirtualSize; // 0x00
BitnessType_t<std::size_t> VirtualSize; // 0x04 / 0x08
std::uint32_t PageFaultCount; // 0x08 / 0x10
BitnessType_t<std::size_t> PeakWorkingSetSize; // 0x0C / 0x18
BitnessType_t<std::size_t> WorkingSetSize; // 0x10 / 0x20
BitnessType_t<std::size_t> QuotaPeakPagedPoolUsage; // 0x14 / 0x28
BitnessType_t<std::size_t> QuotaPagedPoolUsage; // 0x18 / 0x30
BitnessType_t<std::size_t> QuotaPeakNonPagedPoolUsage; // 0x1C / 0x38
BitnessType_t<std::size_t> QuotaNonPagedPoolUsage; // 0x20 / 0x40
BitnessType_t<std::size_t> PagefileUsage; // 0x24 / 0x48
BitnessType_t<std::size_t> PeakPagefileUsage; // 0x28 / 0x50
};
_Q_NT_BIT_ASSERT(VM_COUNTERS, 0x2C, 0x58);
_Q_NT_BIT_TEMPLATE struct VM_COUNTERS_EX : VM_COUNTERS<nBitness>
{
private:
_Q_NT_BIT_TYPE
public:
BitnessType_t<std::size_t> PrivateUsage; // 0x2C / 0x58
};
_Q_NT_BIT_ASSERT(VM_COUNTERS_EX, 0x30, 0x60);
_Q_NT_BIT_TEMPLATE struct PROCESS_EXCEPTION_PORT
{
private:
_Q_NT_BIT_TYPE
public:
BitnessType_t<HANDLE> ExceptionPortHandle; // 0x0
std::uint32_t StateFlags; // 0x4 / 0x8
};
_Q_NT_BIT_ASSERT(PROCESS_EXCEPTION_PORT, 0x8, 0x10);
_Q_NT_BIT_TEMPLATE struct PROCESS_ACCESS_TOKEN
{
private:
_Q_NT_BIT_TYPE
public:
BitnessType_t<HANDLE> Token; // 0x0
BitnessType_t<HANDLE> Thread; // 0x4 / 0x8
};
_Q_NT_BIT_ASSERT(PROCESS_ACCESS_TOKEN, 0x8, 0x10);
// @todo: move to "loader.h"?
struct LDT_ENTRY
{
std::uint16_t LimitLow; // 0x0
std::uint16_t BaseLow; // 0x2
union
{
struct
{
std::uint8_t BaseMid;
std::uint8_t Flags1;
std::uint8_t Flags2;
std::uint8_t BaseHi;
} Bytes;
struct
{
std::uint32_t BaseMid : 8;
std::uint32_t Type : 5;
std::uint32_t Dpl : 2;
std::uint32_t Pres : 1;
std::uint32_t LimitHi : 4;
std::uint32_t Sys : 1;
std::uint32_t Reserved_0 : 1;
std::uint32_t Default_Big : 1;
std::uint32_t Granularity : 1;
std::uint32_t BaseHi : 8;
} Bits;
} HighWord; // 0x4
};
static_assert(sizeof(LDT_ENTRY) == 0x8);
struct PROCESS_LDT_INFORMATION // @note: originally "_LDT_INFORMATION"
{
std::uint32_t Start; // 0x0
std::uint32_t Length; // 0x4
LDT_ENTRY LdtEntries[ANYSIZE_ARRAY]; // 0x8
};
_Q_NT_BIT_TEMPLATE struct PROCESS_WS_WATCH_INFORMATION
{
private:
_Q_NT_BIT_TYPE
public: