@@ -1145,28 +1145,169 @@ pub const UNICODE_STRING = extern struct {
1145
1145
Buffer : [* ]WCHAR ,
1146
1146
};
1147
1147
1148
+ const ACTIVATION_CONTEXT_DATA = @OpaqueType ();
1149
+ const ASSEMBLY_STORAGE_MAP = @OpaqueType ();
1150
+ const FLS_CALLBACK_INFO = @OpaqueType ();
1151
+
1152
+ /// Process Environment Block
1153
+ /// Microsoft documentation of this is incomplete, the fields here are taken from various resources including:
1154
+ /// - https://github.com/wine-mirror/wine/blob/1aff1e6a370ee8c0213a0fd4b220d121da8527aa/include/winternl.h#L269
1155
+ /// - https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/index.htm
1148
1156
pub const PEB = extern struct {
1149
- Reserved1 : [2 ]BYTE ,
1150
- BeingDebugged : BYTE ,
1151
- Reserved2 : [1 ]BYTE ,
1152
- Reserved3 : [2 ]PVOID ,
1157
+ // Versions: All
1158
+ InheritedAddressSpace : BOOLEAN ,
1159
+
1160
+ // Versions: 3.51+
1161
+ ReadImageFileExecOptions : BOOLEAN ,
1162
+ BeingDebugged : BOOLEAN ,
1163
+
1164
+ // Versions: 5.2+ (previously was padding)
1165
+ BitField : UCHAR ,
1166
+
1167
+ // Versions: all
1168
+ Mutant : HANDLE ,
1169
+ ImageBaseAddress : HMODULE ,
1153
1170
Ldr : * PEB_LDR_DATA ,
1154
1171
ProcessParameters : * RTL_USER_PROCESS_PARAMETERS ,
1155
- Reserved4 : [3 ]PVOID ,
1172
+ SubSystemData : PVOID ,
1173
+ ProcessHeap : HANDLE ,
1174
+
1175
+ // Versions: 5.1+
1176
+ FastPebLock : PRTL_CRITICAL_SECTION ,
1177
+
1178
+ // Versions: 5.2+
1156
1179
AtlThunkSListPtr : PVOID ,
1157
- Reserved5 : PVOID ,
1158
- Reserved6 : ULONG ,
1159
- Reserved7 : PVOID ,
1160
- Reserved8 : ULONG ,
1180
+ IFEOKey : PVOID ,
1181
+
1182
+ // Versions: 6.0+
1183
+
1184
+ /// https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/crossprocessflags.htm
1185
+ CrossProcessFlags : ULONG ,
1186
+
1187
+ // Versions: 6.0+
1188
+ union1 : union {
1189
+ KernelCallbackTable : PVOID ,
1190
+ UserSharedInfoPtr : PVOID ,
1191
+ },
1192
+
1193
+ // Versions: 5.1+
1194
+ SystemReserved : ULONG ,
1195
+
1196
+ // Versions: 5.1, (not 5.2, not 6.0), 6.1+
1161
1197
AtlThunkSListPtr32 : ULONG ,
1162
- Reserved9 : [45 ]PVOID ,
1163
- Reserved10 : [96 ]BYTE ,
1164
- PostProcessInitRoutine : PPS_POST_PROCESS_INIT_ROUTINE ,
1165
- Reserved11 : [128 ]BYTE ,
1166
- Reserved12 : [1 ]PVOID ,
1198
+
1199
+ // Versions: 6.1+
1200
+ ApiSetMap : PVOID ,
1201
+
1202
+ // Versions: all
1203
+ TlsExpansionCounter : ULONG ,
1204
+ // note: there is padding here on 64 bit
1205
+ TlsBitmap : PRTL_BITMAP ,
1206
+ TlsBitmapBits : ULONG [2 ],
1207
+ ReadOnlySharedMemoryBase : PVOID ,
1208
+
1209
+ // Versions: 1703+
1210
+ SharedData : PVOID ,
1211
+
1212
+ // Versions: all
1213
+ ReadOnlyStaticServerData : * PVOID ,
1214
+ AnsiCodePageData : PVOID ,
1215
+ OemCodePageData : PVOID ,
1216
+ UnicodeCaseTableData : PVOID ,
1217
+
1218
+ // Versions: 3.51+
1219
+ NumberOfProcessors : ULONG ,
1220
+ NtGlobalFlag : ULONG ,
1221
+
1222
+ // Versions: all
1223
+ CriticalSectionTimeout : LARGE_INTEGER ,
1224
+
1225
+ // End of Original PEB size
1226
+
1227
+ // Fields appended in 3.51:
1228
+ HeapSegmentReserve : ULONG_PTR ,
1229
+ HeapSegmentCommit : ULONG_PTR ,
1230
+ HeapDeCommitTotalFreeThreshold : ULONG_PTR ,
1231
+ HeapDeCommitFreeBlockThreshold : ULONG_PTR ,
1232
+ NumberOfHeaps : ULONG ,
1233
+ MaximumNumberOfHeaps : ULONG ,
1234
+ ProcessHeaps : * PVOID ,
1235
+
1236
+ // Fields appended in 4.0:
1237
+ GdiSharedHandleTable : PVOID ,
1238
+ ProcessStarterHelper : PVOID ,
1239
+ GdiDCAttributeList : ULONG ,
1240
+ // note: there is padding here on 64 bit
1241
+ LoaderLock : * RTL_CRITICAL_SECTION ,
1242
+ OSMajorVersion : ULONG ,
1243
+ OSMinorVersion : ULONG ,
1244
+ OSBuildNumber : USHORT ,
1245
+ OSCSDVersion : USHORT ,
1246
+ OSPlatformId : ULONG ,
1247
+ ImageSubSystem : ULONG ,
1248
+ ImageSubSystemMajorVersion : ULONG ,
1249
+ ImageSubSystemMinorVersion : ULONG ,
1250
+ // note: there is padding here on 64 bit
1251
+ ActiveProcessAffinityMask : KAFFINITY ,
1252
+ GdiHandleBuffer : ULONG [switch (@sizeOf (usize )) {
1253
+ 4 = > 0x22 ,
1254
+ 8 = > 0x3C ,
1255
+ else = > unreachable ,
1256
+ }],
1257
+
1258
+ // Fields appended in 5.0 (Windows 2000):
1259
+ PostProcessInitRoutine : PVOID ,
1260
+ TlsExpansionBitmap : PRTL_BITMAP ,
1261
+ TlsExpansionBitmapBits : ULONG [32 ],
1167
1262
SessionId : ULONG ,
1263
+ // note: there is padding here on 64 bit
1264
+ // Versions: 5.1+
1265
+ AppCompatFlags : ULARGE_INTEGER ,
1266
+ AppCompatFlagsUser : ULARGE_INTEGER ,
1267
+ ShimData : PVOID ,
1268
+ // Versions: 5.0+
1269
+ AppCompatInfo : PVOID ,
1270
+ CSDVersion : UNICODE_STRING ,
1271
+
1272
+ // Fields appended in 5.1 (Windows XP):
1273
+ ActivationContextData : * const ACTIVATION_CONTEXT_DATA ,
1274
+ ProcessAssemblyStorageMap : * ASSEMBLY_STORAGE_MAP ,
1275
+ SystemDefaultActivationData : * const ACTIVATION_CONTEXT_DATA ,
1276
+ SystemAssemblyStorageMap : * ASSEMBLY_STORAGE_MAP ,
1277
+ MinimumStackCommit : ULONG_PTR ,
1278
+
1279
+ // Fields appended in 5.2 (Windows Server 2003):
1280
+ FlsCallback : * FLS_CALLBACK_INFO ,
1281
+ FlsListHead : LIST_ENTRY ,
1282
+ FlsBitmap : PRTL_BITMAP ,
1283
+ FlsBitmapBits : ULONG [4 ],
1284
+ FlsHighIndex : ULONG ,
1285
+
1286
+ // Fields appended in 6.0 (Windows Vista):
1287
+ WerRegistrationData : PVOID ,
1288
+ WerShipAssertPtr : PVOID ,
1289
+
1290
+ // Fields appended in 6.1 (Windows 7):
1291
+ pUnused : PVOID , // previously pContextData
1292
+ pImageHeaderHash : PVOID ,
1293
+
1294
+ /// TODO: https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/tracingflags.htm
1295
+ TracingFlags : ULONG ,
1296
+
1297
+ // Fields appended in 6.2 (Windows 8):
1298
+ CsrServerReadOnlySharedMemoryBase : ULONGLONG ,
1299
+
1300
+ // Fields appended in 1511:
1301
+ TppWorkerpListLock : ULONG ,
1302
+ TppWorkerpList : LIST_ENTRY ,
1303
+ WaitOnAddressHashTable : PVOID [0x80 ],
1304
+
1305
+ // Fields appended in 1709:
1306
+ TelemetryCoverageHeader : PVOID ,
1307
+ CloudFileFlags : ULONG ,
1168
1308
};
1169
1309
1310
+ // TODO: https://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb_ldr_data.htm
1170
1311
pub const PEB_LDR_DATA = extern struct {
1171
1312
Reserved1 : [8 ]BYTE ,
1172
1313
Reserved2 : [3 ]PVOID ,
0 commit comments