summaryrefslogtreecommitdiffstats
path: root/include/iprt/formats/pecoff.h
blob: 3342b54f77f7a47a37239675fca33b3cfb790ca3 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
/* $Id: pecoff.h $ */
/** @file
 * IPRT - Windows NT PE & COFF Structures and Constants.
 */

/*
 * Copyright (C) 2006-2020 Oracle Corporation
 *
 * This file is part of VirtualBox Open Source Edition (OSE), as
 * available from http://www.virtualbox.org. This file is free software;
 * you can redistribute it and/or modify it under the terms of the GNU
 * General Public License (GPL) as published by the Free Software
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 * VirtualBox OSE distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 */

#ifndef IPRT_INCLUDED_formats_pecoff_h
#define IPRT_INCLUDED_formats_pecoff_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

#include <iprt/types.h>
#include <iprt/assertcompile.h>


/** @defgroup grp_rt_formats_pecoff     PE & Microsoft COFF structures and definitions
 * @ingroup grp_rt_formats
 * @{
 */


/**
 * PE & COFF file header.
 *
 * This starts COFF files, while in PE files it's preceeded by the PE signature
 * (see IMAGE_NT_HEADERS32, IMAGE_NT_HEADERS64).
 */
typedef struct _IMAGE_FILE_HEADER
{
    uint16_t  Machine;                      /**< 0x00 */
    uint16_t  NumberOfSections;             /**< 0x02 */
    uint32_t  TimeDateStamp;                /**< 0x04 */
    uint32_t  PointerToSymbolTable;         /**< 0x08 */
    uint32_t  NumberOfSymbols;              /**< 0x0c */
    uint16_t  SizeOfOptionalHeader;         /**< 0x10 */
    uint16_t  Characteristics;              /**< 0x12 */
} IMAGE_FILE_HEADER;                        /* size: 0x14 */
AssertCompileSize(IMAGE_FILE_HEADER, 0x14);
typedef IMAGE_FILE_HEADER *PIMAGE_FILE_HEADER;
typedef IMAGE_FILE_HEADER const *PCIMAGE_FILE_HEADER;


/** @name PE & COFF machine types.
 * Used by IMAGE_FILE_HEADER::Machine and IMAGE_SEPARATE_DEBUG_HEADER::Machine.
 * @{ */
/** X86 compatible CPU, 32-bit instructions. */
#define IMAGE_FILE_MACHINE_I386             UINT16_C(0x014c)
/** AMD64 compatible CPU, 64-bit instructions. */
#define IMAGE_FILE_MACHINE_AMD64            UINT16_C(0x8664)

/** Unknown target CPU. */
#define IMAGE_FILE_MACHINE_UNKNOWN          UINT16_C(0x0000)
/** Basic-16 (whatever that is). */
#define IMAGE_FILE_MACHINE_BASIC_16         UINT16_C(0x0142)
/** Basic-16 (whatever that is) w/ transfer vector(s?) (TV). */
#define IMAGE_FILE_MACHINE_BASIC_16_TV      UINT16_C(0x0143)
/** Intel iAPX 16 (8086?). */
#define IMAGE_FILE_MACHINE_IAPX16           UINT16_C(0x0144)
/** Intel iAPX 16 (8086?) w/ transfer vector(s?) (TV). */
#define IMAGE_FILE_MACHINE_IAPX16_TV        UINT16_C(0x0145)
/** Intel iAPX 20 (80286?). */
#define IMAGE_FILE_MACHINE_IAPX20           UINT16_C(0x0144)
/** Intel iAPX 20 (80286?) w/ transfer vector(s?) (TV). */
#define IMAGE_FILE_MACHINE_IAPX20_TV        UINT16_C(0x0145)
/** X86 compatible CPU, 8086. */
#define IMAGE_FILE_MACHINE_I8086            UINT16_C(0x0148)
/** X86 compatible CPU, 8086 w/ transfer vector(s?) (TV). */
#define IMAGE_FILE_MACHINE_I8086_TV         UINT16_C(0x0149)
/** X86 compatible CPU, 80286 small model program. */
#define IMAGE_FILE_MACHINE_I286_SMALL       UINT16_C(0x014a)
/** Motorola 68000. */
#define IMAGE_FILE_MACHINE_MC68             UINT16_C(0x0150)
/** Motorola 68000 w/ writable text sections. */
#define IMAGE_FILE_MACHINE_MC68_WR          UINT16_C(0x0150)
/** Motorola 68000 w/ transfer vector(s?). */
#define IMAGE_FILE_MACHINE_MC68_TV          UINT16_C(0x0151)
/** Motorola 68000 w/ demand paged text.
 * @note shared with 80286 large model program. */
#define IMAGE_FILE_MACHINE_MC68_PG          UINT16_C(0x0152)
/** X86 compatible CPU, 80286 large model program.
 * @note shared with MC68000 w/ demand paged text */
#define IMAGE_FILE_MACHINE_I286_LARGE       UINT16_C(0x0152)
/** IBM 370 (writable text). */
#define IMAGE_FILE_MACHINE_U370_WR          UINT16_C(0x0158)
/** Amdahl 470/580 (writable text). */
#define IMAGE_FILE_MACHINE_AMDAHL_470_WR    UINT16_C(0x0159)
/** Amdahl 470/580 (read only text). */
#define IMAGE_FILE_MACHINE_AMDAHL_470_RO    UINT16_C(0x015c)
/** IBM 370 (read only text). */
#define IMAGE_FILE_MACHINE_U370_RO          UINT16_C(0x015d)
/** MIPS R4000 CPU, little endian. */
#define IMAGE_FILE_MACHINE_R4000            UINT16_C(0x0166)
/** MIPS CPU, little endian, Windows CE (?) v2 designation. */
#define IMAGE_FILE_MACHINE_WCEMIPSV2        UINT16_C(0x0169)
/** VAX-11/750 and VAX-11/780 (writable text). */
#define IMAGE_FILE_MACHINE_VAX_WR           UINT16_C(0x0178)
/** VAX-11/750 and VAX-11/780 (read-only text). */
#define IMAGE_FILE_MACHINE_VAX_RO           UINT16_C(0x017d)
/** Hitachi SH3 CPU. */
#define IMAGE_FILE_MACHINE_SH3              UINT16_C(0x01a2)
/** Hitachi SH3 DSP. */
#define IMAGE_FILE_MACHINE_SH3DSP           UINT16_C(0x01a3)
/** Hitachi SH4 CPU. */
#define IMAGE_FILE_MACHINE_SH4              UINT16_C(0x01a6)
/** Hitachi SH5 CPU. */
#define IMAGE_FILE_MACHINE_SH5              UINT16_C(0x01a8)
/** Little endian ARM CPU. */
#define IMAGE_FILE_MACHINE_ARM              UINT16_C(0x01c0)
/** ARM or Thumb stuff. */
#define IMAGE_FILE_MACHINE_THUMB            UINT16_C(0x01c2)
/** ARMv7 or higher CPU, Thumb mode. */
#define IMAGE_FILE_MACHINE_ARMNT            UINT16_C(0x01c4)
/** Matshushita AM33 CPU. */
#define IMAGE_FILE_MACHINE_AM33             UINT16_C(0x01d3)
/** Power PC CPU, little endian. */
#define IMAGE_FILE_MACHINE_POWERPC          UINT16_C(0x01f0)
/** Power PC CPU with FPU, also little endian? */
#define IMAGE_FILE_MACHINE_POWERPCFP        UINT16_C(0x01f1)
/** "Itanic" CPU. */
#define IMAGE_FILE_MACHINE_IA64             UINT16_C(0x0200)
/** MIPS CPU, compact 16-bit instructions only? */
#define IMAGE_FILE_MACHINE_MIPS16           UINT16_C(0x0266)
/** MIPS CPU with FPU, full 32-bit instructions only? */
#define IMAGE_FILE_MACHINE_MIPSFPU          UINT16_C(0x0366)
/** MIPS CPU with FPU, compact 16-bit instructions? */
#define IMAGE_FILE_MACHINE_MIPSFPU16        UINT16_C(0x0466)
/** EFI byte code. */
#define IMAGE_FILE_MACHINE_EBC              UINT16_C(0x0ebc)
/** Mitsubishi M32R CPU, little endian. */
#define IMAGE_FILE_MACHINE_M32R             UINT16_C(0x9041)
/** ARMv8 CPU, 64-bit mode. */
#define IMAGE_FILE_MACHINE_ARM64            UINT16_C(0xaa64)
/** @} */

/** @name File header characteristics (IMAGE_FILE_HEADER::Characteristics)
 * @{ */
#define IMAGE_FILE_RELOCS_STRIPPED          UINT16_C(0x0001)
#define IMAGE_FILE_EXECUTABLE_IMAGE         UINT16_C(0x0002)
#define IMAGE_FILE_LINE_NUMS_STRIPPED       UINT16_C(0x0004)
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED      UINT16_C(0x0008)
#define IMAGE_FILE_AGGRESIVE_WS_TRIM        UINT16_C(0x0010)
#define IMAGE_FILE_LARGE_ADDRESS_AWARE      UINT16_C(0x0020)
#define IMAGE_FILE_16BIT_MACHINE            UINT16_C(0x0040)
#define IMAGE_FILE_BYTES_REVERSED_LO        UINT16_C(0x0080)
#define IMAGE_FILE_32BIT_MACHINE            UINT16_C(0x0100)
#define IMAGE_FILE_DEBUG_STRIPPED           UINT16_C(0x0200)
#define IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP  UINT16_C(0x0400)
#define IMAGE_FILE_NET_RUN_FROM_SWAP        UINT16_C(0x0800)
#define IMAGE_FILE_SYSTEM                   UINT16_C(0x1000) /**< (COFF/IAPX*: Used to indicate 80186 instructions) */
#define IMAGE_FILE_DLL                      UINT16_C(0x2000) /**< (COFF/IAPX*: Used to indicate 80286 instructions) */
#define IMAGE_FILE_UP_SYSTEM_ONLY           UINT16_C(0x4000)
#define IMAGE_FILE_BYTES_REVERSED_HI        UINT16_C(0x8000)
/** @} */


/**
 * PE data directory.
 *
 * This is used to locate data in the loaded image so the dynamic linker or
 * others can make use of it.  However, in the case of
 * IMAGE_DIRECTORY_ENTRY_SECURITY it is referring to raw file offsets.
 */
typedef struct _IMAGE_DATA_DIRECTORY
{
    uint32_t  VirtualAddress;
    uint32_t  Size;
} IMAGE_DATA_DIRECTORY;
AssertCompileSize(IMAGE_DATA_DIRECTORY, 0x8);
typedef IMAGE_DATA_DIRECTORY *PIMAGE_DATA_DIRECTORY;
typedef IMAGE_DATA_DIRECTORY const *PCIMAGE_DATA_DIRECTORY;

/** The standard number of data directories in the optional header.
 * I.e. the dimensions of IMAGE_OPTIONAL_HEADER32::DataDirectory and
 * IMAGE_OPTIONAL_HEADER64::DataDirectory.
 */
#define IMAGE_NUMBEROF_DIRECTORY_ENTRIES        0x10


/**
 * PE optional header, 32-bit version.
 */
typedef struct _IMAGE_OPTIONAL_HEADER32
{
    uint16_t  Magic;                        /**< 0x00 */
    uint8_t   MajorLinkerVersion;           /**< 0x02 */
    uint8_t   MinorLinkerVersion;           /**< 0x03 */
    uint32_t  SizeOfCode;                   /**< 0x04 */
    uint32_t  SizeOfInitializedData;        /**< 0x08 */
    uint32_t  SizeOfUninitializedData;      /**< 0x0c */
    uint32_t  AddressOfEntryPoint;          /**< 0x10 */
    uint32_t  BaseOfCode;                   /**< 0x14 */
    uint32_t  BaseOfData;                   /**< 0x18 */
    uint32_t  ImageBase;                    /**< 0x1c */
    uint32_t  SectionAlignment;             /**< 0x20 */
    uint32_t  FileAlignment;                /**< 0x24 */
    uint16_t  MajorOperatingSystemVersion;  /**< 0x28 */
    uint16_t  MinorOperatingSystemVersion;  /**< 0x2a */
    uint16_t  MajorImageVersion;            /**< 0x2c */
    uint16_t  MinorImageVersion;            /**< 0x2e */
    uint16_t  MajorSubsystemVersion;        /**< 0x30 */
    uint16_t  MinorSubsystemVersion;        /**< 0x32 */
    uint32_t  Win32VersionValue;            /**< 0x34 */
    uint32_t  SizeOfImage;                  /**< 0x38 */
    uint32_t  SizeOfHeaders;                /**< 0x3c */
    uint32_t  CheckSum;                     /**< 0x40 */
    uint16_t  Subsystem;                    /**< 0x44 */
    uint16_t  DllCharacteristics;           /**< 0x46 */
    uint32_t  SizeOfStackReserve;           /**< 0x48 */
    uint32_t  SizeOfStackCommit;            /**< 0x4c */
    uint32_t  SizeOfHeapReserve;            /**< 0x50 */
    uint32_t  SizeOfHeapCommit;             /**< 0x54 */
    uint32_t  LoaderFlags;                  /**< 0x58 */
    uint32_t  NumberOfRvaAndSizes;          /**< 0x5c */
    IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /**< 0x60; 0x10*8 = 0x80 */
} IMAGE_OPTIONAL_HEADER32;                  /* size: 0xe0 */
AssertCompileSize(IMAGE_OPTIONAL_HEADER32, 0xe0);
typedef IMAGE_OPTIONAL_HEADER32 *PIMAGE_OPTIONAL_HEADER32;
typedef IMAGE_OPTIONAL_HEADER32 const *PCIMAGE_OPTIONAL_HEADER32;

/**
 * PE optional header, 64-bit version.
 */
typedef struct _IMAGE_OPTIONAL_HEADER64
{
    uint16_t  Magic;                        /**< 0x00 */
    uint8_t   MajorLinkerVersion;           /**< 0x02 */
    uint8_t   MinorLinkerVersion;           /**< 0x03 */
    uint32_t  SizeOfCode;                   /**< 0x04 */
    uint32_t  SizeOfInitializedData;        /**< 0x08 */
    uint32_t  SizeOfUninitializedData;      /**< 0x0c */
    uint32_t  AddressOfEntryPoint;          /**< 0x10 */
    uint32_t  BaseOfCode;                   /**< 0x14 */
    uint64_t  ImageBase;                    /**< 0x18 */
    uint32_t  SectionAlignment;             /**< 0x20 */
    uint32_t  FileAlignment;                /**< 0x24 */
    uint16_t  MajorOperatingSystemVersion;  /**< 0x28 */
    uint16_t  MinorOperatingSystemVersion;  /**< 0x2a */
    uint16_t  MajorImageVersion;            /**< 0x2c */
    uint16_t  MinorImageVersion;            /**< 0x2e */
    uint16_t  MajorSubsystemVersion;        /**< 0x30 */
    uint16_t  MinorSubsystemVersion;        /**< 0x32 */
    uint32_t  Win32VersionValue;            /**< 0x34 */
    uint32_t  SizeOfImage;                  /**< 0x38 */
    uint32_t  SizeOfHeaders;                /**< 0x3c */
    uint32_t  CheckSum;                     /**< 0x40 */
    uint16_t  Subsystem;                    /**< 0x44 */
    uint16_t  DllCharacteristics;           /**< 0x46 */
    uint64_t  SizeOfStackReserve;           /**< 0x48 */
    uint64_t  SizeOfStackCommit;            /**< 0x50 */
    uint64_t  SizeOfHeapReserve;            /**< 0x58 */
    uint64_t  SizeOfHeapCommit;             /**< 0x60 */
    uint32_t  LoaderFlags;                  /**< 0x68 */
    uint32_t  NumberOfRvaAndSizes;          /**< 0x6c */
    IMAGE_DATA_DIRECTORY DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES]; /**< 0x70; 0x10*8 = 0x80 */
} IMAGE_OPTIONAL_HEADER64;                  /* size: 0xf0 */
AssertCompileSize(IMAGE_OPTIONAL_HEADER64, 0xf0);
typedef IMAGE_OPTIONAL_HEADER64 *PIMAGE_OPTIONAL_HEADER64;
typedef IMAGE_OPTIONAL_HEADER64 const *PCIMAGE_OPTIONAL_HEADER64;

/** @name Optional header magic values.
 * @{ */
#define IMAGE_NT_OPTIONAL_HDR32_MAGIC       UINT16_C(0x010b)
#define IMAGE_NT_OPTIONAL_HDR64_MAGIC       UINT16_C(0x020b)
/** @}  */

/** @name IMAGE_SUBSYSTEM_XXX - Optional header subsystems.
 * IMAGE_OPTIONAL_HEADER32::Subsystem, IMAGE_OPTIONAL_HEADER64::Subsystem
 * @{ */
#define IMAGE_SUBSYSTEM_UNKNOWN             UINT16_C(0x0000)
#define IMAGE_SUBSYSTEM_NATIVE              UINT16_C(0x0001)
#define IMAGE_SUBSYSTEM_WINDOWS_GUI         UINT16_C(0x0002)
#define IMAGE_SUBSYSTEM_WINDOWS_CUI         UINT16_C(0x0003)
#define IMAGE_SUBSYSTEM_OS2_GUI             UINT16_C(0x0004)
#define IMAGE_SUBSYSTEM_OS2_CUI             UINT16_C(0x0005)
#define IMAGE_SUBSYSTEM_POSIX_CUI           UINT16_C(0x0007)
/** @} */

/** @name Optional header characteristics.
 * @{ */
#define IMAGE_LIBRARY_PROCESS_INIT                      UINT16_C(0x0001)
#define IMAGE_LIBRARY_PROCESS_TERM                      UINT16_C(0x0002)
#define IMAGE_LIBRARY_THREAD_INIT                       UINT16_C(0x0004)
#define IMAGE_LIBRARY_THREAD_TERM                       UINT16_C(0x0008)
#define IMAGE_DLLCHARACTERISTICS_RESERVED               UINT16_C(0x0010)
#define IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA        UINT16_C(0x0020)
#define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE           UINT16_C(0x0040)
#define IMAGE_DLLCHARACTERISTICS_FORCE_INTEGRITY        UINT16_C(0x0080)
#define IMAGE_DLLCHARACTERISTICS_NX_COMPAT              UINT16_C(0x0100)
#define IMAGE_DLLCHARACTERISTICS_NO_ISOLATION           UINT16_C(0x0200)
#define IMAGE_DLLCHARACTERISTICS_NO_SEH                 UINT16_C(0x0400)
#define IMAGE_DLLCHARACTERISTICS_NO_BIND                UINT16_C(0x0800)
#define IMAGE_DLLCHARACTERISTICS_APPCONTAINER           UINT16_C(0x1000)
#define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER             UINT16_C(0x2000)
#define IMAGE_DLLCHARACTERISTICS_GUARD_CF               UINT16_C(0x4000)
#define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE  UINT16_C(0x8000)
/** @} */


/** @name IMAGE_DIRECTORY_ENTRY_XXX - Data directory indexes.
 * Used to index IMAGE_OPTIONAL_HEADER32::DataDirectory and
 * IMAGE_OPTIONAL_HEADER64::DataDirectory
 * @{ */
#define IMAGE_DIRECTORY_ENTRY_EXPORT            0x0
#define IMAGE_DIRECTORY_ENTRY_IMPORT            0x1
#define IMAGE_DIRECTORY_ENTRY_RESOURCE          0x2
#define IMAGE_DIRECTORY_ENTRY_EXCEPTION         0x3
#define IMAGE_DIRECTORY_ENTRY_SECURITY          0x4
#define IMAGE_DIRECTORY_ENTRY_BASERELOC         0x5
#define IMAGE_DIRECTORY_ENTRY_DEBUG             0x6
#define IMAGE_DIRECTORY_ENTRY_ARCHITECTURE      0x7
#define IMAGE_DIRECTORY_ENTRY_COPYRIGHT         IMAGE_DIRECTORY_ENTRY_ARCHITECTURE
#define IMAGE_DIRECTORY_ENTRY_GLOBALPTR         0x8
#define IMAGE_DIRECTORY_ENTRY_TLS               0x9
#define IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG       0xa
#define IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT      0xb
#define IMAGE_DIRECTORY_ENTRY_IAT               0xc
#define IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT      0xd
#define IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR    0xe
/** @} */


/**
 * PE (NT) headers, 32-bit version.
 */
typedef struct _IMAGE_NT_HEADERS32
{
    uint32_t  Signature;                    /**< 0x00 */
    IMAGE_FILE_HEADER FileHeader;           /**< 0x04 */
    IMAGE_OPTIONAL_HEADER32 OptionalHeader; /**< 0x18 */
} IMAGE_NT_HEADERS32;                       /* size:  0xf8 */
AssertCompileSize(IMAGE_NT_HEADERS32, 0xf8);
AssertCompileMemberOffset(IMAGE_NT_HEADERS32, FileHeader, 4);
AssertCompileMemberOffset(IMAGE_NT_HEADERS32, OptionalHeader, 24);
typedef IMAGE_NT_HEADERS32 *PIMAGE_NT_HEADERS32;
typedef IMAGE_NT_HEADERS32 const *PCIMAGE_NT_HEADERS32;

/**
 * PE (NT) headers, 64-bit version.
 */
typedef struct _IMAGE_NT_HEADERS64
{
    uint32_t  Signature;                    /**< 0x00 */
    IMAGE_FILE_HEADER FileHeader;           /**< 0x04 */
    IMAGE_OPTIONAL_HEADER64 OptionalHeader; /**< 0x18 */
} IMAGE_NT_HEADERS64;                       /**< 0x108 */
AssertCompileSize(IMAGE_NT_HEADERS64, 0x108);
AssertCompileMemberOffset(IMAGE_NT_HEADERS64, FileHeader, 4);
AssertCompileMemberOffset(IMAGE_NT_HEADERS64, OptionalHeader, 24);
typedef IMAGE_NT_HEADERS64 *PIMAGE_NT_HEADERS64;
typedef IMAGE_NT_HEADERS64 const *PCIMAGE_NT_HEADERS64;

/** The PE signature.
 * Used by IMAGE_NT_HEADERS32::Signature, IMAGE_NT_HEADERS64::Signature. */
#define IMAGE_NT_SIGNATURE                  UINT32_C(0x00004550)


/** Section header short name length (IMAGE_SECTION_HEADER::Name). */
#define IMAGE_SIZEOF_SHORT_NAME             0x8

/**
 * PE & COFF section header.
 */
typedef struct _IMAGE_SECTION_HEADER
{
    uint8_t  Name[IMAGE_SIZEOF_SHORT_NAME];
    union
    {
        uint32_t  PhysicalAddress;
        uint32_t  VirtualSize;
    } Misc;
    uint32_t  VirtualAddress;
    uint32_t  SizeOfRawData;
    uint32_t  PointerToRawData;
    uint32_t  PointerToRelocations;
    uint32_t  PointerToLinenumbers;
    uint16_t  NumberOfRelocations;
    uint16_t  NumberOfLinenumbers;
    uint32_t  Characteristics;
} IMAGE_SECTION_HEADER;
AssertCompileSize(IMAGE_SECTION_HEADER, 40);
typedef IMAGE_SECTION_HEADER *PIMAGE_SECTION_HEADER;
typedef IMAGE_SECTION_HEADER const *PCIMAGE_SECTION_HEADER;

/** @name IMAGE_SCN_XXX - Section header characteristics.
 * Used by IMAGE_SECTION_HEADER::Characteristics.
 * @{ */
#define IMAGE_SCN_TYPE_REG                  UINT32_C(0x00000000)
#define IMAGE_SCN_TYPE_DSECT                UINT32_C(0x00000001)
#define IMAGE_SCN_TYPE_NOLOAD               UINT32_C(0x00000002)
#define IMAGE_SCN_TYPE_GROUP                UINT32_C(0x00000004)
#define IMAGE_SCN_TYPE_NO_PAD               UINT32_C(0x00000008)
#define IMAGE_SCN_TYPE_COPY                 UINT32_C(0x00000010)

#define IMAGE_SCN_CNT_CODE                  UINT32_C(0x00000020)
#define IMAGE_SCN_CNT_INITIALIZED_DATA      UINT32_C(0x00000040)
#define IMAGE_SCN_CNT_UNINITIALIZED_DATA    UINT32_C(0x00000080)

#define IMAGE_SCN_LNK_OTHER                 UINT32_C(0x00000100)
#define IMAGE_SCN_LNK_INFO                  UINT32_C(0x00000200)
#define IMAGE_SCN_TYPE_OVER                 UINT32_C(0x00000400)
#define IMAGE_SCN_LNK_REMOVE                UINT32_C(0x00000800)
#define IMAGE_SCN_LNK_COMDAT                UINT32_C(0x00001000)
#define IMAGE_SCN_MEM_PROTECTED             UINT32_C(0x00004000)
#define IMAGE_SCN_NO_DEFER_SPEC_EXC         UINT32_C(0x00004000)
#define IMAGE_SCN_GPREL                     UINT32_C(0x00008000)
#define IMAGE_SCN_MEM_FARDATA               UINT32_C(0x00008000)
#define IMAGE_SCN_MEM_SYSHEAP               UINT32_C(0x00010000)
#define IMAGE_SCN_MEM_PURGEABLE             UINT32_C(0x00020000)
#define IMAGE_SCN_MEM_16BIT                 UINT32_C(0x00020000)
#define IMAGE_SCN_MEM_LOCKED                UINT32_C(0x00040000)
#define IMAGE_SCN_MEM_PRELOAD               UINT32_C(0x00080000)

#define IMAGE_SCN_ALIGN_1BYTES              UINT32_C(0x00100000)
#define IMAGE_SCN_ALIGN_2BYTES              UINT32_C(0x00200000)
#define IMAGE_SCN_ALIGN_4BYTES              UINT32_C(0x00300000)
#define IMAGE_SCN_ALIGN_8BYTES              UINT32_C(0x00400000)
#define IMAGE_SCN_ALIGN_16BYTES             UINT32_C(0x00500000)
#define IMAGE_SCN_ALIGN_32BYTES             UINT32_C(0x00600000)
#define IMAGE_SCN_ALIGN_64BYTES             UINT32_C(0x00700000)
#define IMAGE_SCN_ALIGN_128BYTES            UINT32_C(0x00800000)
#define IMAGE_SCN_ALIGN_256BYTES            UINT32_C(0x00900000)
#define IMAGE_SCN_ALIGN_512BYTES            UINT32_C(0x00A00000)
#define IMAGE_SCN_ALIGN_1024BYTES           UINT32_C(0x00B00000)
#define IMAGE_SCN_ALIGN_2048BYTES           UINT32_C(0x00C00000)
#define IMAGE_SCN_ALIGN_4096BYTES           UINT32_C(0x00D00000)
#define IMAGE_SCN_ALIGN_8192BYTES           UINT32_C(0x00E00000)
#define IMAGE_SCN_ALIGN_MASK                UINT32_C(0x00F00000)
#define IMAGE_SCN_ALIGN_SHIFT               20

#define IMAGE_SCN_LNK_NRELOC_OVFL           UINT32_C(0x01000000)
#define IMAGE_SCN_MEM_DISCARDABLE           UINT32_C(0x02000000)
#define IMAGE_SCN_MEM_NOT_CACHED            UINT32_C(0x04000000)
#define IMAGE_SCN_MEM_NOT_PAGED             UINT32_C(0x08000000)
#define IMAGE_SCN_MEM_SHARED                UINT32_C(0x10000000)
#define IMAGE_SCN_MEM_EXECUTE               UINT32_C(0x20000000)
#define IMAGE_SCN_MEM_READ                  UINT32_C(0x40000000)
#define IMAGE_SCN_MEM_WRITE                 UINT32_C(0x80000000)
/** @} */


/**
 * PE image base relocations block header.
 *
 * This found in IMAGE_DIRECTORY_ENTRY_BASERELOC. Each entry is follow
 * immediately by an array of 16-bit words, where the lower 12-bits are used
 * for the page offset and the upper 4-bits for the base relocation type
 * (IMAGE_REL_BASE_XXX).  The block should be padded with
 * IMAGE_REL_BASED_ABSOLUTE entries to ensure 32-bit alignment of this header.
 */
typedef struct _IMAGE_BASE_RELOCATION
{
    /** The RVA of the page/block the following ase relocations applies to. */
    uint32_t  VirtualAddress;
    /** The size of this relocation block, including this header. */
    uint32_t  SizeOfBlock;
} IMAGE_BASE_RELOCATION;
AssertCompileSize(IMAGE_BASE_RELOCATION, 8);
typedef IMAGE_BASE_RELOCATION *PIMAGE_BASE_RELOCATION;
typedef IMAGE_BASE_RELOCATION const *PCIMAGE_BASE_RELOCATION;

/** @name IMAGE_REL_BASED_XXX - PE base relocations.
 * Found in the IMAGE_DIRECTORY_ENTRY_BASERELOC data directory.
 * @{ */
#define IMAGE_REL_BASED_ABSOLUTE            UINT16_C(0x0)
#define IMAGE_REL_BASED_HIGH                UINT16_C(0x1)
#define IMAGE_REL_BASED_LOW                 UINT16_C(0x2)
#define IMAGE_REL_BASED_HIGHLOW             UINT16_C(0x3)
#define IMAGE_REL_BASED_HIGHADJ             UINT16_C(0x4)
#define IMAGE_REL_BASED_MIPS_JMPADDR        UINT16_C(0x5)
#define IMAGE_REL_BASED_MIPS_JMPADDR16      UINT16_C(0x9)
#define IMAGE_REL_BASED_IA64_IMM64          UINT16_C(0x9)
#define IMAGE_REL_BASED_DIR64               UINT16_C(0xa)
#define IMAGE_REL_BASED_HIGH3ADJ            UINT16_C(0xb)
/** @} */

/**
 * PE export directory entry.
 */
typedef struct _IMAGE_EXPORT_DIRECTORY
{
    uint32_t  Characteristics;
    uint32_t  TimeDateStamp;
    uint16_t  MajorVersion;
    uint16_t  MinorVersion;
    uint32_t  Name;
    uint32_t  Base;
    uint32_t  NumberOfFunctions;
    uint32_t  NumberOfNames;
    uint32_t  AddressOfFunctions;
    uint32_t  AddressOfNames;
    uint32_t  AddressOfNameOrdinals;
} IMAGE_EXPORT_DIRECTORY;
AssertCompileSize(IMAGE_EXPORT_DIRECTORY, 40);
typedef IMAGE_EXPORT_DIRECTORY *PIMAGE_EXPORT_DIRECTORY;
typedef IMAGE_EXPORT_DIRECTORY const *PCIMAGE_EXPORT_DIRECTORY;


/**
 * PE import directory entry.
 */
typedef struct _IMAGE_IMPORT_DESCRIPTOR
{
    union
    {
        uint32_t  Characteristics;
        uint32_t  OriginalFirstThunk;
    } u;
    uint32_t  TimeDateStamp;
    uint32_t  ForwarderChain;
    uint32_t  Name;
    uint32_t  FirstThunk;
} IMAGE_IMPORT_DESCRIPTOR;
AssertCompileSize(IMAGE_IMPORT_DESCRIPTOR, 20);
typedef IMAGE_IMPORT_DESCRIPTOR *PIMAGE_IMPORT_DESCRIPTOR;
typedef IMAGE_IMPORT_DESCRIPTOR const *PCIMAGE_IMPORT_DESCRIPTOR;

/**
 * Something we currently don't make use of...
 */
typedef struct _IMAGE_IMPORT_BY_NAME
{
    uint16_t  Hint;
    uint8_t   Name[1];
} IMAGE_IMPORT_BY_NAME;
AssertCompileSize(IMAGE_IMPORT_BY_NAME, 4);
typedef IMAGE_IMPORT_BY_NAME *PIMAGE_IMPORT_BY_NAME;
typedef IMAGE_IMPORT_BY_NAME const *PCIMAGE_IMPORT_BY_NAME;


#if 0
/* The image_thunk_data32/64 structures are not very helpful except for getting RSI.
   keep them around till all the code has been converted. */
typedef struct _IMAGE_THUNK_DATA64
{
    union
    {
        uint64_t  ForwarderString;
        uint64_t  Function;
        uint64_t  Ordinal;
        uint64_t  AddressOfData;
    } u1;
} IMAGE_THUNK_DATA64;
typedef IMAGE_THUNK_DATA64 *PIMAGE_THUNK_DATA64;
typedef IMAGE_THUNK_DATA64 const *PCIMAGE_THUNK_DATA64;

typedef struct _IMAGE_THUNK_DATA32
{
    union
    {
        uint32_t  ForwarderString;
        uint32_t  Function;
        uint32_t  Ordinal;
        uint32_t  AddressOfData;
    } u1;
} IMAGE_THUNK_DATA32;
typedef IMAGE_THUNK_DATA32 *PIMAGE_THUNK_DATA32;
typedef IMAGE_THUNK_DATA32 const *PCIMAGE_THUNK_DATA32;
#endif

/** @name PE import directory macros.
 * @{ */
#define IMAGE_ORDINAL_FLAG32                UINT32_C(0x80000000)
#define IMAGE_ORDINAL32(ord)                ((ord) &  UINT32_C(0xffff))
#define IMAGE_SNAP_BY_ORDINAL32(ord)        (!!((ord) & IMAGE_ORDINAL_FLAG32))

#define IMAGE_ORDINAL_FLAG64                UINT64_C(0x8000000000000000)
#define IMAGE_ORDINAL64(ord)                ((ord) &  UINT32_C(0xffff))
#define IMAGE_SNAP_BY_ORDINAL64(ord)        (!!((ord) & IMAGE_ORDINAL_FLAG64))
/** @} */

/** @name PE Resource directory
 * @{ */
typedef struct _IMAGE_RESOURCE_DIRECTORY
{
    uint32_t    Characteristics;
    uint32_t    TimeDateStamp;
    uint16_t    MajorVersion;
    uint16_t    MinorVersion;
    uint16_t    NumberOfNamedEntries;
    uint16_t    NumberOfIdEntries;
} IMAGE_RESOURCE_DIRECTORY;
typedef IMAGE_RESOURCE_DIRECTORY *PIMAGE_RESOURCE_DIRECTORY;
typedef IMAGE_RESOURCE_DIRECTORY const *PCIMAGE_RESOURCE_DIRECTORY;

typedef struct _IMAGE_RESOURCE_DIRECTORY_ENTRY
{
    union
    {
        struct
        {
            uint32_t NameOffset        : 31;
            uint32_t NameIsString      : 1; /**< IMAGE_RESOURCE_NAME_IS_STRING */
        } s;
        uint32_t Name;
        uint16_t Id;
    } u;
    union
    {
        struct
        {
            uint32_t OffsetToDirectory : 31;
            uint32_t DataIsDirectory   : 1; /**< IMAGE_RESOURCE_DATA_IS_DIRECTORY*/
        } s2;
        uint32_t OffsetToData;
    } u2;
} IMAGE_RESOURCE_DIRECTORY_ENTRY;
typedef IMAGE_RESOURCE_DIRECTORY_ENTRY *PIMAGE_RESOURCE_DIRECTORY_ENTRY;
typedef IMAGE_RESOURCE_DIRECTORY_ENTRY const *PCIMAGE_RESOURCE_DIRECTORY_ENTRY;

#define IMAGE_RESOURCE_NAME_IS_STRING       UINT32_C(0x80000000)
#define IMAGE_RESOURCE_DATA_IS_DIRECTORY    UINT32_C(0x80000000)

typedef struct _IMAGE_RESOURCE_DIRECTORY_STRING
{
    uint16_t    Length;
    char        NameString[1];
} IMAGE_RESOURCE_DIRECTORY_STRING;
typedef IMAGE_RESOURCE_DIRECTORY_STRING *PIMAGE_RESOURCE_DIRECTORY_STRING;
typedef IMAGE_RESOURCE_DIRECTORY_STRING const *PCIMAGE_RESOURCE_DIRECTORY_STRING;


typedef struct _IMAGE_RESOURCE_DIR_STRING_U
{
    uint16_t    Length;
    RTUTF16     NameString[1];
} IMAGE_RESOURCE_DIR_STRING_U;
typedef IMAGE_RESOURCE_DIR_STRING_U *PIMAGE_RESOURCE_DIR_STRING_U;
typedef IMAGE_RESOURCE_DIR_STRING_U const *PCIMAGE_RESOURCE_DIR_STRING_U;


typedef struct _IMAGE_RESOURCE_DATA_ENTRY
{
    uint32_t    OffsetToData;
    uint32_t    Size;
    uint32_t    CodePage;
    uint32_t    Reserved;
} IMAGE_RESOURCE_DATA_ENTRY;
typedef IMAGE_RESOURCE_DATA_ENTRY *PIMAGE_RESOURCE_DATA_ENTRY;
typedef IMAGE_RESOURCE_DATA_ENTRY const *PCIMAGE_RESOURCE_DATA_ENTRY;

/** @} */

/** @name Image exception information
 * @{ */

/** This structure is used by AMD64 and "Itanic".
 * MIPS uses a different one.  ARM, SH3, SH4 and PPC on WinCE also uses a different one.  */
typedef struct _IMAGE_RUNTIME_FUNCTION_ENTRY
{
    uint32_t    BeginAddress;
    uint32_t    EndAddress;
    uint32_t    UnwindInfoAddress;
} IMAGE_RUNTIME_FUNCTION_ENTRY;
AssertCompileSize(IMAGE_RUNTIME_FUNCTION_ENTRY, 12);
typedef IMAGE_RUNTIME_FUNCTION_ENTRY *PIMAGE_RUNTIME_FUNCTION_ENTRY;
typedef IMAGE_RUNTIME_FUNCTION_ENTRY const *PCIMAGE_RUNTIME_FUNCTION_ENTRY;

/**
 * An unwind code for AMD64 and ARM64.
 *
 * @note Also known as UNWIND_CODE or _UNWIND_CODE.
 */
typedef union IMAGE_UNWIND_CODE
{
    struct
    {
        /** The prolog offset where the change takes effect.
         * This means the instruction following the one being described.  */
        uint8_t CodeOffset;
        /** Unwind opcode.
         * For AMD64 see IMAGE_AMD64_UNWIND_OP_CODES. */
        RT_GCC_EXTENSION uint8_t UnwindOp : 4;
        /** Opcode specific. */
        RT_GCC_EXTENSION uint8_t OpInfo   : 4;
    } u;
    uint16_t    FrameOffset;
} IMAGE_UNWIND_CODE;
AssertCompileSize(IMAGE_UNWIND_CODE, 2);

/**
 * Unwind information for AMD64 and ARM64.
 *
 * Pointed to by IMAGE_RUNTIME_FUNCTION_ENTRY::UnwindInfoAddress,
 *
 * @note Also known as UNWIND_INFO or _UNWIND_INFO.
 */
typedef struct IMAGE_UNWIND_INFO
{
    /** Version, currently 1 or 2.  The latter if IMAGE_AMD64_UWOP_EPILOG is used. */
    RT_GCC_EXTENSION uint8_t    Version : 3;
    /** IMAGE_UNW_FLAG_XXX */
    RT_GCC_EXTENSION uint8_t    Flags : 5;
    /** Size of function prolog. */
    uint8_t                     SizeOfProlog;
    /** Number of opcodes in aOpcodes. */
    uint8_t                     CountOfCodes;
    /** Initial frame register. */
    RT_GCC_EXTENSION uint8_t    FrameRegister : 4;
    /** Scaled frame register offset. */
    RT_GCC_EXTENSION uint8_t    FrameOffset : 4;
    /** Unwind opcodes. */
    RT_FLEXIBLE_ARRAY_EXTENSION
    IMAGE_UNWIND_CODE           aOpcodes[RT_FLEXIBLE_ARRAY];
} IMAGE_UNWIND_INFO;
AssertCompileMemberOffset(IMAGE_UNWIND_INFO, aOpcodes, 4);
typedef IMAGE_UNWIND_INFO *PIMAGE_UNWIND_INFO;
typedef IMAGE_UNWIND_INFO const *PCIMAGE_UNWIND_INFO;

/** IMAGE_UNW_FLAGS_XXX - IMAGE_UNWIND_INFO::Flags.
 * @{  */
/** No handler.
 * @note Aslo know as UNW_FLAG_NHANDLER. */
#define IMAGE_UNW_FLAGS_NHANDLER        0
/** Have exception handler (RVA after codes, dword aligned.)
 * @note Aslo know as UNW_FLAG_NHANDLER. */
#define IMAGE_UNW_FLAGS_EHANDLER        1
/** Have unwind handler (RVA after codes, dword aligned.)
 * @note Aslo know as UNW_FLAG_NHANDLER. */
#define IMAGE_UNW_FLAGS_UHANDLER        2
/** Set if not primary unwind info for a function.  An
 * IMAGE_RUNTIME_FUNCTION_ENTRY giving the chained unwind info follows the
 * aOpcodes array at a dword aligned offset. */
#define IMAGE_UNW_FLAGS_CHAININFO       4
/** @}  */

/**
 * AMD64 unwind opcodes.
 */
typedef enum IMAGE_AMD64_UNWIND_OP_CODES
{
    /** Push non-volatile register (OpInfo).
     * YASM: [pushreg reg]
     * MASM: .PUSHREG reg */
    IMAGE_AMD64_UWOP_PUSH_NONVOL = 0,
    /** Stack allocation: Size stored in scaled in the next slot if OpInfo == 0,
     * otherwise stored unscaled in the next two slots.
     * YASM: [allocstack size]
     * MASM: .ALLOCSTACK size */
    IMAGE_AMD64_UWOP_ALLOC_LARGE,
    /** Stack allocation: OpInfo = size / 8 - 1.
     * YASM: [allocstack size]
     * MASM: .ALLOCSTACK size  */
    IMAGE_AMD64_UWOP_ALLOC_SMALL,
    /** Set frame pointer register: RSP + FrameOffset * 16.
     * YASM: [setframe reg, offset]
     * MASM: .SETFRAME reg, offset
     * @code
     *      LEA     RBP, [RSP + 20h]
     *      [setframe RBP, 20h]
     * @endcode */
    IMAGE_AMD64_UWOP_SET_FPREG,
    /** Save non-volatile register (OpInfo) on stack (RSP/FP + next slot).
     * YASM: [savereg reg, offset]
     * MASM: .SAVEREG reg, offset */
    IMAGE_AMD64_UWOP_SAVE_NONVOL,
    /** Save non-volatile register (OpInfo) on stack (RSP/FP + next two slots).
     * YASM: [savereg reg, offset]
     * MASM: .SAVEREG reg, offset  */
    IMAGE_AMD64_UWOP_SAVE_NONVOL_FAR,
    /** Epilog info, version 2+.
     *
     * The first time this opcode is used, the CodeOffset gives the size of the
     * epilog and bit 0 of the OpInfo field indicates that there is only one
     * epilog at the very end of the function.
     *
     * Subsequent uses of this opcode specifies epilog start offsets relative to
     * the end of the function, using CodeOffset for the 8 lower bits and OpInfo
     * for bits 8 thru 11.
     *
     * The compiler seems to stack allocations and register saving opcodes and
     * indicates the location mirroring the first IMAGE_AMD64_UWOP_PUSH_NONVOL. */
    IMAGE_AMD64_UWOP_EPILOG,
    /** Undefined. */
    IMAGE_AMD64_UWOP_RESERVED_7,
    /** Save 128-bit XMM register (OpInfo) on stack (RSP/FP + next slot).
     * YASM: [savexmm128 reg, offset]
     * MASM: .SAVEXMM128 reg, offset */
    IMAGE_AMD64_UWOP_SAVE_XMM128,
    /** Save 128-bit XMM register (OpInfo) on stack (RSP/FP + next two slots).
     * YASM: [savexmm128 reg, offset]
     * MASM: .SAVEXMM128 reg, offset  */
    IMAGE_AMD64_UWOP_SAVE_XMM128_FAR,
    /** IRET frame, OpInfo serves as error code indicator.
     * YASM: [pushframe with-code]
     * MASM: .pushframe with-code  */
    IMAGE_AMD64_UWOP_PUSH_MACHFRAME
} IMAGE_AMD64_UNWIND_OP_CODES;
/** @} */



/** @name Image load config directories
 * @{ */

/** @since Windows 10 (preview 9879) */
typedef struct _IMAGE_LOAD_CONFIG_CODE_INTEGRITY
{
    uint16_t  Flags;
    uint16_t  Catalog;
    uint32_t  CatalogOffset;
    uint32_t  Reserved;
} IMAGE_LOAD_CONFIG_CODE_INTEGRITY;
AssertCompileSize(IMAGE_LOAD_CONFIG_CODE_INTEGRITY, 12);
typedef IMAGE_LOAD_CONFIG_CODE_INTEGRITY *PIMAGE_LOAD_CONFIG_CODE_INTEGRITY;
typedef IMAGE_LOAD_CONFIG_CODE_INTEGRITY const *PCIMAGE_LOAD_CONFIG_CODE_INTEGRITY;

typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V1
{
    uint32_t  Size;
    uint32_t  TimeDateStamp;
    uint16_t  MajorVersion;
    uint16_t  MinorVersion;
    uint32_t  GlobalFlagsClear;
    uint32_t  GlobalFlagsSet;
    uint32_t  CriticalSectionDefaultTimeout;
    uint32_t  DeCommitFreeBlockThreshold;
    uint32_t  DeCommitTotalFreeThreshold;
    uint32_t  LockPrefixTable;
    uint32_t  MaximumAllocationSize;
    uint32_t  VirtualMemoryThreshold;
    uint32_t  ProcessHeapFlags;
    uint32_t  ProcessAffinityMask;
    uint16_t  CSDVersion;
    uint16_t  DependentLoadFlags;
    uint32_t  EditList;
    uint32_t  SecurityCookie;
} IMAGE_LOAD_CONFIG_DIRECTORY32_V1;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V1, 0x40);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V1 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V1;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V1 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V1;

typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V2
{
    uint32_t  Size;
    uint32_t  TimeDateStamp;
    uint16_t  MajorVersion;
    uint16_t  MinorVersion;
    uint32_t  GlobalFlagsClear;
    uint32_t  GlobalFlagsSet;
    uint32_t  CriticalSectionDefaultTimeout;
    uint32_t  DeCommitFreeBlockThreshold;
    uint32_t  DeCommitTotalFreeThreshold;
    uint32_t  LockPrefixTable;
    uint32_t  MaximumAllocationSize;
    uint32_t  VirtualMemoryThreshold;
    uint32_t  ProcessHeapFlags;
    uint32_t  ProcessAffinityMask;
    uint16_t  CSDVersion;
    uint16_t  DependentLoadFlags;
    uint32_t  EditList;
    uint32_t  SecurityCookie;
    uint32_t  SEHandlerTable;
    uint32_t  SEHandlerCount;
} IMAGE_LOAD_CONFIG_DIRECTORY32_V2;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V2, 0x48);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V2 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V2;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V2 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V2;

typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V3
{
    uint32_t  Size;
    uint32_t  TimeDateStamp;
    uint16_t  MajorVersion;
    uint16_t  MinorVersion;
    uint32_t  GlobalFlagsClear;
    uint32_t  GlobalFlagsSet;
    uint32_t  CriticalSectionDefaultTimeout;
    uint32_t  DeCommitFreeBlockThreshold;
    uint32_t  DeCommitTotalFreeThreshold;
    uint32_t  LockPrefixTable;
    uint32_t  MaximumAllocationSize;
    uint32_t  VirtualMemoryThreshold;
    uint32_t  ProcessHeapFlags;
    uint32_t  ProcessAffinityMask;
    uint16_t  CSDVersion;
    uint16_t  DependentLoadFlags;
    uint32_t  EditList;
    uint32_t  SecurityCookie;
    uint32_t  SEHandlerTable;
    uint32_t  SEHandlerCount;
    uint32_t  GuardCFCCheckFunctionPointer;
    uint32_t  GuardCFDispatchFunctionPointer;
    uint32_t  GuardCFFunctionTable;
    uint32_t  GuardCFFunctionCount;
    uint32_t  GuardFlags;
} IMAGE_LOAD_CONFIG_DIRECTORY32_V3;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V3, 0x5c);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V3 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V3;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V3 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V3;

/** @since Windows 10 (preview 9879) */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V4
{
    uint32_t  Size;
    uint32_t  TimeDateStamp;
    uint16_t  MajorVersion;
    uint16_t  MinorVersion;
    uint32_t  GlobalFlagsClear;
    uint32_t  GlobalFlagsSet;
    uint32_t  CriticalSectionDefaultTimeout;
    uint32_t  DeCommitFreeBlockThreshold;
    uint32_t  DeCommitTotalFreeThreshold;
    uint32_t  LockPrefixTable;
    uint32_t  MaximumAllocationSize;
    uint32_t  VirtualMemoryThreshold;
    uint32_t  ProcessHeapFlags;
    uint32_t  ProcessAffinityMask;
    uint16_t  CSDVersion;
    uint16_t  DependentLoadFlags;
    uint32_t  EditList;
    uint32_t  SecurityCookie;
    uint32_t  SEHandlerTable;
    uint32_t  SEHandlerCount;
    uint32_t  GuardCFCCheckFunctionPointer;
    uint32_t  GuardCFDispatchFunctionPointer;
    uint32_t  GuardCFFunctionTable;
    uint32_t  GuardCFFunctionCount;
    uint32_t  GuardFlags;
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY  CodeIntegrity;
} IMAGE_LOAD_CONFIG_DIRECTORY32_V4;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V4, 0x68);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V4;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V4 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V4;

/** @since  Windows 10 build 14286 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V5
{
    uint32_t  Size;
    uint32_t  TimeDateStamp;
    uint16_t  MajorVersion;
    uint16_t  MinorVersion;
    uint32_t  GlobalFlagsClear;
    uint32_t  GlobalFlagsSet;
    uint32_t  CriticalSectionDefaultTimeout;
    uint32_t  DeCommitFreeBlockThreshold;
    uint32_t  DeCommitTotalFreeThreshold;
    uint32_t  LockPrefixTable;
    uint32_t  MaximumAllocationSize;
    uint32_t  VirtualMemoryThreshold;
    uint32_t  ProcessHeapFlags;
    uint32_t  ProcessAffinityMask;
    uint16_t  CSDVersion;
    uint16_t  DependentLoadFlags;
    uint32_t  EditList;
    uint32_t  SecurityCookie;
    uint32_t  SEHandlerTable;
    uint32_t  SEHandlerCount;
    uint32_t  GuardCFCCheckFunctionPointer;
    uint32_t  GuardCFDispatchFunctionPointer;
    uint32_t  GuardCFFunctionTable;
    uint32_t  GuardCFFunctionCount;
    uint32_t  GuardFlags;
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY  CodeIntegrity;
    uint32_t  GuardAddressTakenIatEntryTable;
    uint32_t  GuardAddressTakenIatEntryCount;
    uint32_t  GuardLongJumpTargetTable;
    uint32_t  GuardLongJumpTargetCount;
} IMAGE_LOAD_CONFIG_DIRECTORY32_V5;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V5, 0x78);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V5;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V5 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V5;

/** @since  Windows 10 build 14383 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V6
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
    uint32_t  LockPrefixTable;                      /**< 0x20 */
    uint32_t  MaximumAllocationSize;                /**< 0x24 */
    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
    uint16_t  CSDVersion;                           /**< 0x34 */
    uint16_t  DependentLoadFlags;                   /**< 0x36 */
    uint32_t  EditList;                             /**< 0x38 */
    uint32_t  SecurityCookie;                       /**< 0x3c */
    uint32_t  SEHandlerTable;                       /**< 0x40 */
    uint32_t  SEHandlerCount;                       /**< 0x44 */
    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
    uint32_t  GuardFlags;                           /**< 0x58 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
    uint32_t  HybridMetadataPointer;                /**< 0x7c */
} IMAGE_LOAD_CONFIG_DIRECTORY32_V6;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V6, 0x80);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V6 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V6;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V6 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V6;

/** @since  Windows 10 build 14901 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V7
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
    uint32_t  LockPrefixTable;                      /**< 0x20 */
    uint32_t  MaximumAllocationSize;                /**< 0x24 */
    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
    uint16_t  CSDVersion;                           /**< 0x34 */
    uint16_t  DependentLoadFlags;                   /**< 0x36 */
    uint32_t  EditList;                             /**< 0x38 */
    uint32_t  SecurityCookie;                       /**< 0x3c */
    uint32_t  SEHandlerTable;                       /**< 0x40 */
    uint32_t  SEHandlerCount;                       /**< 0x44 */
    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
    uint32_t  GuardFlags;                           /**< 0x58 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
    uint32_t  CHPEMetadataPointer;                  /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
    uint32_t  GuardRFFailureRoutine;                /**< 0x80 */
    uint32_t  GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0x88 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0x8c */
    uint16_t  Reserved2;                            /**< 0x8e */
} IMAGE_LOAD_CONFIG_DIRECTORY32_V7;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V7, 0x90);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V7;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V7 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V7;

/** @since  Windows 10 build 15002 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V8
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
    uint32_t  LockPrefixTable;                      /**< 0x20 */
    uint32_t  MaximumAllocationSize;                /**< 0x24 */
    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
    uint16_t  CSDVersion;                           /**< 0x34 */
    uint16_t  DependentLoadFlags;                   /**< 0x36 */
    uint32_t  EditList;                             /**< 0x38 */
    uint32_t  SecurityCookie;                       /**< 0x3c */
    uint32_t  SEHandlerTable;                       /**< 0x40 */
    uint32_t  SEHandlerCount;                       /**< 0x44 */
    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
    uint32_t  GuardFlags;                           /**< 0x58 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
    uint32_t  CHPEMetadataPointer;                  /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
    uint32_t  GuardRFFailureRoutine;                /**< 0x80 */
    uint32_t  GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0x88 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0x8c */
    uint16_t  Reserved2;                            /**< 0x8e */
    uint32_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0x90 */
    uint32_t  HotPatchTableOffset;                  /**< 0x94 */
} IMAGE_LOAD_CONFIG_DIRECTORY32_V8;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V8, 0x98);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V8 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V8;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V8 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V8;

/** @since  Windows 10 build 16237 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V9
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
    uint32_t  LockPrefixTable;                      /**< 0x20 */
    uint32_t  MaximumAllocationSize;                /**< 0x24 */
    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
    uint16_t  CSDVersion;                           /**< 0x34 */
    uint16_t  DependentLoadFlags;                   /**< 0x36 */
    uint32_t  EditList;                             /**< 0x38 */
    uint32_t  SecurityCookie;                       /**< 0x3c */
    uint32_t  SEHandlerTable;                       /**< 0x40 */
    uint32_t  SEHandlerCount;                       /**< 0x44 */
    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
    uint32_t  GuardFlags;                           /**< 0x58 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
    uint32_t  CHPEMetadataPointer;                  /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
    uint32_t  GuardRFFailureRoutine;                /**< 0x80 */
    uint32_t  GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0x88 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0x8c */
    uint16_t  Reserved2;                            /**< 0x8e */
    uint32_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0x90 */
    uint32_t  HotPatchTableOffset;                  /**< 0x94 */
    uint32_t  Reserved3;                            /**< 0x98 */
    uint32_t  EnclaveConfigurationPointer;          /**< 0x9c */
} IMAGE_LOAD_CONFIG_DIRECTORY32_V9;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V9, 0xa0);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V9 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V9;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V9 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V9;

/** @since  Windows 10 build 18362 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V10
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
    uint32_t  LockPrefixTable;                      /**< 0x20 */
    uint32_t  MaximumAllocationSize;                /**< 0x24 */
    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
    uint16_t  CSDVersion;                           /**< 0x34 */
    uint16_t  DependentLoadFlags;                   /**< 0x36 */
    uint32_t  EditList;                             /**< 0x38 */
    uint32_t  SecurityCookie;                       /**< 0x3c */
    uint32_t  SEHandlerTable;                       /**< 0x40 */
    uint32_t  SEHandlerCount;                       /**< 0x44 */
    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
    uint32_t  GuardFlags;                           /**< 0x58 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
    uint32_t  CHPEMetadataPointer;                  /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
    uint32_t  GuardRFFailureRoutine;                /**< 0x80 */
    uint32_t  GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0x88 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0x8c */
    uint16_t  Reserved2;                            /**< 0x8e */
    uint32_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0x90 */
    uint32_t  HotPatchTableOffset;                  /**< 0x94 */
    uint32_t  Reserved3;                            /**< 0x98 */
    uint32_t  EnclaveConfigurationPointer;          /**< 0x9c */
    uint32_t  VolatileMetadataPointer;              /**< 0xa0 */
} IMAGE_LOAD_CONFIG_DIRECTORY32_V10;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V10, 0xa4);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V10 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V10;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V10 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V10;

/** @since  Windows 10 build 19564 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V11
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
    uint32_t  LockPrefixTable;                      /**< 0x20 */
    uint32_t  MaximumAllocationSize;                /**< 0x24 */
    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
    uint16_t  CSDVersion;                           /**< 0x34 */
    uint16_t  DependentLoadFlags;                   /**< 0x36 */
    uint32_t  EditList;                             /**< 0x38 */
    uint32_t  SecurityCookie;                       /**< 0x3c */
    uint32_t  SEHandlerTable;                       /**< 0x40 */
    uint32_t  SEHandlerCount;                       /**< 0x44 */
    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
    uint32_t  GuardFlags;                           /**< 0x58 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
    uint32_t  CHPEMetadataPointer;                  /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
    uint32_t  GuardRFFailureRoutine;                /**< 0x80 */
    uint32_t  GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0x88 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0x8c */
    uint16_t  Reserved2;                            /**< 0x8e */
    uint32_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0x90 */
    uint32_t  HotPatchTableOffset;                  /**< 0x94 */
    uint32_t  Reserved3;                            /**< 0x98 */
    uint32_t  EnclaveConfigurationPointer;          /**< 0x9c - virtual address */
    uint32_t  VolatileMetadataPointer;              /**< 0xa0 */
    uint32_t  GuardEHContinuationTable;             /**< 0xa4 - virtual address */
    uint32_t  GuardEHContinuationCount;             /**< 0xa8 */
} IMAGE_LOAD_CONFIG_DIRECTORY32_V11;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V11, 0xac);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V11 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V11;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V11 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V11;

/** @since  Visual C++ 2019 / RS5_IMAGE_LOAD_CONFIG_DIRECTORY32. */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY32_V12
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint32_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint32_t  DeCommitTotalFreeThreshold;           /**< 0x1c */
    uint32_t  LockPrefixTable;                      /**< 0x20 */
    uint32_t  MaximumAllocationSize;                /**< 0x24 */
    uint32_t  VirtualMemoryThreshold;               /**< 0x28 */
    uint32_t  ProcessHeapFlags;                     /**< 0x2c */
    uint32_t  ProcessAffinityMask;                  /**< 0x30 */
    uint16_t  CSDVersion;                           /**< 0x34 */
    uint16_t  DependentLoadFlags;                   /**< 0x36 */
    uint32_t  EditList;                             /**< 0x38 */
    uint32_t  SecurityCookie;                       /**< 0x3c */
    uint32_t  SEHandlerTable;                       /**< 0x40 */
    uint32_t  SEHandlerCount;                       /**< 0x44 */
    uint32_t  GuardCFCCheckFunctionPointer;         /**< 0x48 */
    uint32_t  GuardCFDispatchFunctionPointer;       /**< 0x4c */
    uint32_t  GuardCFFunctionTable;                 /**< 0x50 */
    uint32_t  GuardCFFunctionCount;                 /**< 0x54 */
    uint32_t  GuardFlags;                           /**< 0x58 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x5c */
    uint32_t  GuardAddressTakenIatEntryTable;       /**< 0x68 */
    uint32_t  GuardAddressTakenIatEntryCount;       /**< 0x6c */
    uint32_t  GuardLongJumpTargetTable;             /**< 0x70 */
    uint32_t  GuardLongJumpTargetCount;             /**< 0x74 */
    uint32_t  DynamicValueRelocTable;               /**< 0x78 */
    uint32_t  CHPEMetadataPointer;                  /**< 0x7c Not sure when this was renamed from HybridMetadataPointer. */
    uint32_t  GuardRFFailureRoutine;                /**< 0x80 */
    uint32_t  GuardRFFailureRoutineFunctionPointer; /**< 0x84 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0x88 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0x8c */
    uint16_t  Reserved2;                            /**< 0x8e */
    uint32_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0x90 */
    uint32_t  HotPatchTableOffset;                  /**< 0x94 */
    uint32_t  Reserved3;                            /**< 0x98 */
    uint32_t  EnclaveConfigurationPointer;          /**< 0x9c - virtual address */
    uint32_t  VolatileMetadataPointer;              /**< 0xa0 */
    uint32_t  GuardEHContinuationTable;             /**< 0xa4 - virtual address */
    uint32_t  GuardEHContinuationCount;             /**< 0xa8 */
    uint32_t  GuardXFGCheckFunctionPointer;         /**< 0xac */
    uint32_t  GuardXFGDispatchFunctionPointer;      /**< 0xb0 */
    uint32_t  GuardXFGTableDispatchFunctionPointer; /**< 0xb4 */
} IMAGE_LOAD_CONFIG_DIRECTORY32_V12;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY32_V12, 0xb8);
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V12 *PIMAGE_LOAD_CONFIG_DIRECTORY32_V12;
typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V12 const *PCIMAGE_LOAD_CONFIG_DIRECTORY32_V12;

typedef IMAGE_LOAD_CONFIG_DIRECTORY32_V12   IMAGE_LOAD_CONFIG_DIRECTORY32;
typedef PIMAGE_LOAD_CONFIG_DIRECTORY32_V12  PIMAGE_LOAD_CONFIG_DIRECTORY32;
typedef PCIMAGE_LOAD_CONFIG_DIRECTORY32_V12 PCIMAGE_LOAD_CONFIG_DIRECTORY32;


/* No _IMAGE_LOAD_CONFIG_DIRECTORY64_V1 exists. */

typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V2
{
    uint32_t  Size;
    uint32_t  TimeDateStamp;
    uint16_t  MajorVersion;
    uint16_t  MinorVersion;
    uint32_t  GlobalFlagsClear;
    uint32_t  GlobalFlagsSet;
    uint32_t  CriticalSectionDefaultTimeout;
    uint64_t  DeCommitFreeBlockThreshold;
    uint64_t  DeCommitTotalFreeThreshold;
    uint64_t  LockPrefixTable;
    uint64_t  MaximumAllocationSize;
    uint64_t  VirtualMemoryThreshold;
    uint64_t  ProcessAffinityMask;
    uint32_t  ProcessHeapFlags;
    uint16_t  CSDVersion;
    uint16_t  DependentLoadFlags;
    uint64_t  EditList;
    uint64_t  SecurityCookie;
    uint64_t  SEHandlerTable;
    uint64_t  SEHandlerCount;
} IMAGE_LOAD_CONFIG_DIRECTORY64_V2;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V2, 0x70);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V2 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V2;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V2 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V2;

#pragma pack(4) /* Why not 8 byte alignment, baka microsofties?!? */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V3
{
    uint32_t  Size;
    uint32_t  TimeDateStamp;
    uint16_t  MajorVersion;
    uint16_t  MinorVersion;
    uint32_t  GlobalFlagsClear;
    uint32_t  GlobalFlagsSet;
    uint32_t  CriticalSectionDefaultTimeout;
    uint64_t  DeCommitFreeBlockThreshold;
    uint64_t  DeCommitTotalFreeThreshold;
    uint64_t  LockPrefixTable;
    uint64_t  MaximumAllocationSize;
    uint64_t  VirtualMemoryThreshold;
    uint64_t  ProcessAffinityMask;
    uint32_t  ProcessHeapFlags;
    uint16_t  CSDVersion;
    uint16_t  DependentLoadFlags;
    uint64_t  EditList;
    uint64_t  SecurityCookie;
    uint64_t  SEHandlerTable;
    uint64_t  SEHandlerCount;
    uint64_t  GuardCFCCheckFunctionPointer;
    uint64_t  GuardCFDispatchFunctionPointer;
    uint64_t  GuardCFFunctionTable;
    uint64_t  GuardCFFunctionCount;
    uint32_t  GuardFlags;
} IMAGE_LOAD_CONFIG_DIRECTORY64_V3;
#pragma pack()
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V3, 0x94);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V3 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V3;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V3 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V3;

/** @since  Windows 10 (Preview (9879). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V4
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
    uint64_t  LockPrefixTable;                      /**< 0x28 */
    uint64_t  MaximumAllocationSize;                /**< 0x30 */
    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
    uint16_t  CSDVersion;                           /**< 0x4c */
    uint16_t  DependentLoadFlags;                   /**< 0x4e */
    uint64_t  EditList;                             /**< 0x50 */
    uint64_t  SecurityCookie;                       /**< 0x58 */
    uint64_t  SEHandlerTable;                       /**< 0x60 */
    uint64_t  SEHandlerCount;                       /**< 0x68 */
    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
    uint32_t  GuardFlags;                           /**< 0x90 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
} IMAGE_LOAD_CONFIG_DIRECTORY64_V4;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V4, 0xa0);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V4;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V4 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V4;

/** @since  Windows 10 build 14286 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V5
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
    uint64_t  LockPrefixTable;                      /**< 0x28 */
    uint64_t  MaximumAllocationSize;                /**< 0x30 */
    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
    uint16_t  CSDVersion;                           /**< 0x4c */
    uint16_t  DependentLoadFlags;                   /**< 0x4e */
    uint64_t  EditList;                             /**< 0x50 */
    uint64_t  SecurityCookie;                       /**< 0x58 */
    uint64_t  SEHandlerTable;                       /**< 0x60 */
    uint64_t  SEHandlerCount;                       /**< 0x68 */
    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
    uint32_t  GuardFlags;                           /**< 0x90 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
} IMAGE_LOAD_CONFIG_DIRECTORY64_V5;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V5, 0xc0);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V5;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V5 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V5;

/** @since  Windows 10 build 14393 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V6
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
    uint64_t  LockPrefixTable;                      /**< 0x28 */
    uint64_t  MaximumAllocationSize;                /**< 0x30 */
    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
    uint16_t  CSDVersion;                           /**< 0x4c */
    uint16_t  DependentLoadFlags;                   /**< 0x4e */
    uint64_t  EditList;                             /**< 0x50 */
    uint64_t  SecurityCookie;                       /**< 0x58 */
    uint64_t  SEHandlerTable;                       /**< 0x60 */
    uint64_t  SEHandlerCount;                       /**< 0x68 */
    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
    uint32_t  GuardFlags;                           /**< 0x90 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
    uint64_t  HybridMetadataPointer;                /**< 0xc8 */
} IMAGE_LOAD_CONFIG_DIRECTORY64_V6;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V6, 0xd0);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V6 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V6;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V6 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V6;

/** @since  Windows 10 build 14901 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V7
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
    uint64_t  LockPrefixTable;                      /**< 0x28 */
    uint64_t  MaximumAllocationSize;                /**< 0x30 */
    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
    uint16_t  CSDVersion;                           /**< 0x4c */
    uint16_t  DependentLoadFlags;                   /**< 0x4e */
    uint64_t  EditList;                             /**< 0x50 */
    uint64_t  SecurityCookie;                       /**< 0x58 */
    uint64_t  SEHandlerTable;                       /**< 0x60 */
    uint64_t  SEHandlerCount;                       /**< 0x68 */
    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
    uint32_t  GuardFlags;                           /**< 0x90 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
    uint64_t  CHPEMetadataPointer;                  /**< 0xc8 Not sure when this was renamed from HybridMetadataPointer. */
    uint64_t  GuardRFFailureRoutine;                /**< 0xd0 */
    uint64_t  GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0xe0 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0xe4 */
    uint16_t  Reserved2;                            /**< 0xe6 */
} IMAGE_LOAD_CONFIG_DIRECTORY64_V7;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V7, 0xe8);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V7 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V7;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V7 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V7;

/** @since  Windows 10 build 15002 (or maybe earlier). */
#pragma pack(4) /* Stupid, stupid microsofties! */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V8
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
    uint64_t  LockPrefixTable;                      /**< 0x28 */
    uint64_t  MaximumAllocationSize;                /**< 0x30 */
    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
    uint16_t  CSDVersion;                           /**< 0x4c */
    uint16_t  DependentLoadFlags;                   /**< 0x4e */
    uint64_t  EditList;                             /**< 0x50 */
    uint64_t  SecurityCookie;                       /**< 0x58 */
    uint64_t  SEHandlerTable;                       /**< 0x60 */
    uint64_t  SEHandlerCount;                       /**< 0x68 */
    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
    uint32_t  GuardFlags;                           /**< 0x90 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
    uint64_t  CHPEMetadataPointer;                  /**< 0xc8 */
    uint64_t  GuardRFFailureRoutine;                /**< 0xd0 */
    uint64_t  GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0xe0 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0xe4 */
    uint16_t  Reserved2;                            /**< 0xe6 */
    uint64_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0xe8 */
    uint32_t  HotPatchTableOffset;                  /**< 0xf0 */
} IMAGE_LOAD_CONFIG_DIRECTORY64_V8;
#pragma pack()
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V8, 0xf4);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V8 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V8;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V8 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V8;

/** @since  Windows 10 build 15002 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V9
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
    uint64_t  LockPrefixTable;                      /**< 0x28 */
    uint64_t  MaximumAllocationSize;                /**< 0x30 */
    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
    uint16_t  CSDVersion;                           /**< 0x4c */
    uint16_t  DependentLoadFlags;                   /**< 0x4e */
    uint64_t  EditList;                             /**< 0x50 */
    uint64_t  SecurityCookie;                       /**< 0x58 */
    uint64_t  SEHandlerTable;                       /**< 0x60 */
    uint64_t  SEHandlerCount;                       /**< 0x68 */
    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
    uint32_t  GuardFlags;                           /**< 0x90 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
    uint64_t  CHPEMetadataPointer;                  /**< 0xc8 */
    uint64_t  GuardRFFailureRoutine;                /**< 0xd0 */
    uint64_t  GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0xe0 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0xe4 */
    uint16_t  Reserved2;                            /**< 0xe6 */
    uint64_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0xe8 */
    uint32_t  HotPatchTableOffset;                  /**< 0xf0 */
    uint32_t  Reserved3;                            /**< 0xf4 */
    uint64_t  EnclaveConfigurationPointer;          /**< 0xf8 - seen in bcrypt and bcryptprimitives pointing to the string "L". */
} IMAGE_LOAD_CONFIG_DIRECTORY64_V9;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V9, 0x100);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V9 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V9;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V9 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V9;

/** @since  Windows 10 build 18362 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V10
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
    uint64_t  LockPrefixTable;                      /**< 0x28 */
    uint64_t  MaximumAllocationSize;                /**< 0x30 */
    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
    uint16_t  CSDVersion;                           /**< 0x4c */
    uint16_t  DependentLoadFlags;                   /**< 0x4e */
    uint64_t  EditList;                             /**< 0x50 */
    uint64_t  SecurityCookie;                       /**< 0x58 */
    uint64_t  SEHandlerTable;                       /**< 0x60 */
    uint64_t  SEHandlerCount;                       /**< 0x68 */
    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
    uint32_t  GuardFlags;                           /**< 0x90 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
    uint64_t  CHPEMetadataPointer;                  /**< 0xc8 */
    uint64_t  GuardRFFailureRoutine;                /**< 0xd0 */
    uint64_t  GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0xe0 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0xe4 */
    uint16_t  Reserved2;                            /**< 0xe6 */
    uint64_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0xe8 */
    uint32_t  HotPatchTableOffset;                  /**< 0xf0 */
    uint32_t  Reserved3;                            /**< 0xf4 */
    uint64_t  EnclaveConfigurationPointer;          /**< 0xf8 - seen in bcrypt and bcryptprimitives pointing to the string "L". */
    uint64_t  VolatileMetadataPointer;              /**< 0x100 */
} IMAGE_LOAD_CONFIG_DIRECTORY64_V10;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V10, 0x108);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V10 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V10;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V10 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V10;

/** @since  Windows 10 build 19534 (or maybe earlier). */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V11
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
    uint64_t  LockPrefixTable;                      /**< 0x28 */
    uint64_t  MaximumAllocationSize;                /**< 0x30 */
    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
    uint16_t  CSDVersion;                           /**< 0x4c */
    uint16_t  DependentLoadFlags;                   /**< 0x4e */
    uint64_t  EditList;                             /**< 0x50 */
    uint64_t  SecurityCookie;                       /**< 0x58 */
    uint64_t  SEHandlerTable;                       /**< 0x60 */
    uint64_t  SEHandlerCount;                       /**< 0x68 */
    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
    uint32_t  GuardFlags;                           /**< 0x90 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
    uint64_t  CHPEMetadataPointer;                  /**< 0xc8 */
    uint64_t  GuardRFFailureRoutine;                /**< 0xd0 */
    uint64_t  GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0xe0 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0xe4 */
    uint16_t  Reserved2;                            /**< 0xe6 */
    uint64_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0xe8 */
    uint32_t  HotPatchTableOffset;                  /**< 0xf0 */
    uint32_t  Reserved3;                            /**< 0xf4 */
    uint64_t  EnclaveConfigurationPointer;          /**< 0xf8 - seen in bcrypt and bcryptprimitives pointing to the string "L". */
    uint64_t  VolatileMetadataPointer;              /**< 0x100 */
    uint64_t  GuardEHContinuationTable;             /**< 0x108 - virtual address */
    uint64_t  GuardEHContinuationCount;             /**< 0x110 */
} IMAGE_LOAD_CONFIG_DIRECTORY64_V11;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V11, 0x118);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V11 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V11;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V11 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V11;

/** @since  Visual C++ 2019 / RS5_IMAGE_LOAD_CONFIG_DIRECTORY64. */
typedef struct _IMAGE_LOAD_CONFIG_DIRECTORY64_V12
{
    uint32_t  Size;                                 /**< 0x00 */
    uint32_t  TimeDateStamp;                        /**< 0x04 */
    uint16_t  MajorVersion;                         /**< 0x08 */
    uint16_t  MinorVersion;                         /**< 0x0a */
    uint32_t  GlobalFlagsClear;                     /**< 0x0c */
    uint32_t  GlobalFlagsSet;                       /**< 0x10 */
    uint32_t  CriticalSectionDefaultTimeout;        /**< 0x14 */
    uint64_t  DeCommitFreeBlockThreshold;           /**< 0x18 */
    uint64_t  DeCommitTotalFreeThreshold;           /**< 0x20 */
    uint64_t  LockPrefixTable;                      /**< 0x28 */
    uint64_t  MaximumAllocationSize;                /**< 0x30 */
    uint64_t  VirtualMemoryThreshold;               /**< 0x38 */
    uint64_t  ProcessAffinityMask;                  /**< 0x40 */
    uint32_t  ProcessHeapFlags;                     /**< 0x48 */
    uint16_t  CSDVersion;                           /**< 0x4c */
    uint16_t  DependentLoadFlags;                   /**< 0x4e */
    uint64_t  EditList;                             /**< 0x50 */
    uint64_t  SecurityCookie;                       /**< 0x58 */
    uint64_t  SEHandlerTable;                       /**< 0x60 */
    uint64_t  SEHandlerCount;                       /**< 0x68 */
    uint64_t  GuardCFCCheckFunctionPointer;         /**< 0x70 */
    uint64_t  GuardCFDispatchFunctionPointer;       /**< 0x78 */
    uint64_t  GuardCFFunctionTable;                 /**< 0x80 */
    uint64_t  GuardCFFunctionCount;                 /**< 0x88 */
    uint32_t  GuardFlags;                           /**< 0x90 */
    IMAGE_LOAD_CONFIG_CODE_INTEGRITY CodeIntegrity; /**< 0x94 */
    uint64_t  GuardAddressTakenIatEntryTable;       /**< 0xa0 */
    uint64_t  GuardAddressTakenIatEntryCount;       /**< 0xa8 */
    uint64_t  GuardLongJumpTargetTable;             /**< 0xb0 */
    uint64_t  GuardLongJumpTargetCount;             /**< 0xb8 */
    uint64_t  DynamicValueRelocTable;               /**< 0xc0 */
    uint64_t  CHPEMetadataPointer;                  /**< 0xc8 */
    uint64_t  GuardRFFailureRoutine;                /**< 0xd0 */
    uint64_t  GuardRFFailureRoutineFunctionPointer; /**< 0xd8 */
    uint32_t  DynamicValueRelocTableOffset;         /**< 0xe0 */
    uint16_t  DynamicValueRelocTableSection;        /**< 0xe4 */
    uint16_t  Reserved2;                            /**< 0xe6 */
    uint64_t  GuardRFVerifyStackPointerFunctionPointer; /**< 0xe8 */
    uint32_t  HotPatchTableOffset;                  /**< 0xf0 */
    uint32_t  Reserved3;                            /**< 0xf4 */
    uint64_t  EnclaveConfigurationPointer;          /**< 0xf8 - seen in bcrypt and bcryptprimitives pointing to the string "L". */
    uint64_t  VolatileMetadataPointer;              /**< 0x100 */
    uint64_t  GuardEHContinuationTable;             /**< 0x108 - virtual address */
    uint64_t  GuardEHContinuationCount;             /**< 0x110 */
    uint64_t  GuardXFGCheckFunctionPointer;         /**< 0x118 */
    uint64_t  GuardXFGDispatchFunctionPointer;      /**< 0x120 */
    uint64_t  GuardXFGTableDispatchFunctionPointer; /**< 0x128 */
} IMAGE_LOAD_CONFIG_DIRECTORY64_V12;
AssertCompileSize(IMAGE_LOAD_CONFIG_DIRECTORY64_V12, 0x130);
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V12 *PIMAGE_LOAD_CONFIG_DIRECTORY64_V12;
typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V12 const *PCIMAGE_LOAD_CONFIG_DIRECTORY64_V12;

typedef IMAGE_LOAD_CONFIG_DIRECTORY64_V12   IMAGE_LOAD_CONFIG_DIRECTORY64;
typedef PIMAGE_LOAD_CONFIG_DIRECTORY64_V12  PIMAGE_LOAD_CONFIG_DIRECTORY64;
typedef PCIMAGE_LOAD_CONFIG_DIRECTORY64_V12 PCIMAGE_LOAD_CONFIG_DIRECTORY64;

/** @} */


/**
 * PE certificate directory.
 *
 * Found in IMAGE_DIRECTORY_ENTRY_SECURITY.
 */
typedef struct WIN_CERTIFICATE
{
    uint32_t    dwLength;
    uint16_t    wRevision;
    uint16_t    wCertificateType;
    uint8_t     bCertificate[8];
} WIN_CERTIFICATE;
AssertCompileSize(WIN_CERTIFICATE, 16);
typedef WIN_CERTIFICATE *PWIN_CERTIFICATE;
typedef WIN_CERTIFICATE const *PCWIN_CERTIFICATE;

/** @name WIN_CERT_REVISION_XXX - Certificate data directory revision.
 * Used WIN_CERTIFICATE::wRevision found in the IMAGE_DIRECTORY_ENTRY_SECURITY
 * data directory.
 * @{ */
#define WIN_CERT_REVISION_1_0               UINT16_C(0x0100)
#define WIN_CERT_REVISION_2_0               UINT16_C(0x0200)
/** @} */

/** @name WIN_CERT_TYPE_XXX - Signature type.
 * Used by WIN_CERTIFICATE::wCertificateType.
 * @{ */
#define WIN_CERT_TYPE_X509                  UINT16_C(1)
#define WIN_CERT_TYPE_PKCS_SIGNED_DATA      UINT16_C(2)
#define WIN_CERT_TYPE_RESERVED_1            UINT16_C(3)
#define WIN_CERT_TYPE_TS_STACK_SIGNED       UINT16_C(4)
#define WIN_CERT_TYPE_EFI_PKCS115           UINT16_C(0x0ef0)
#define WIN_CERT_TYPE_EFI_GUID              UINT16_C(0x0ef1)
/** @} */

/** The alignment of the certificate table.
 * @remarks Found thru signtool experiments.  */
#define WIN_CERTIFICATE_ALIGNMENT           UINT32_C(8)


/**
 * Debug directory.
 *
 * Found in IMAGE_DIRECTORY_ENTRY_DEBUG.
 */
typedef struct _IMAGE_DEBUG_DIRECTORY
{
    uint32_t  Characteristics;
    uint32_t  TimeDateStamp;
    uint16_t  MajorVersion;
    uint16_t  MinorVersion;
    uint32_t  Type;
    uint32_t  SizeOfData;
    uint32_t  AddressOfRawData;
    uint32_t  PointerToRawData;
} IMAGE_DEBUG_DIRECTORY;
AssertCompileSize(IMAGE_DEBUG_DIRECTORY, 28);
typedef IMAGE_DEBUG_DIRECTORY *PIMAGE_DEBUG_DIRECTORY;
typedef IMAGE_DEBUG_DIRECTORY const *PCIMAGE_DEBUG_DIRECTORY;

/** @name IMAGE_DEBUG_TYPE_XXX - Debug format types.
 * Used by IMAGE_DEBUG_DIRECTORY::Type.
 * @{  */
#define IMAGE_DEBUG_TYPE_UNKNOWN            UINT32_C(0x00)
#define IMAGE_DEBUG_TYPE_COFF               UINT32_C(0x01)
#define IMAGE_DEBUG_TYPE_CODEVIEW           UINT32_C(0x02)
#define IMAGE_DEBUG_TYPE_FPO                UINT32_C(0x03)
#define IMAGE_DEBUG_TYPE_MISC               UINT32_C(0x04)
#define IMAGE_DEBUG_TYPE_EXCEPTION          UINT32_C(0x05)
#define IMAGE_DEBUG_TYPE_FIXUP              UINT32_C(0x06)
#define IMAGE_DEBUG_TYPE_OMAP_TO_SRC        UINT32_C(0x07)
#define IMAGE_DEBUG_TYPE_OMAP_FROM_SRC      UINT32_C(0x08)
#define IMAGE_DEBUG_TYPE_BORLAND            UINT32_C(0x09)
#define IMAGE_DEBUG_TYPE_RESERVED10         UINT32_C(0x0a)
#define IMAGE_DEBUG_TYPE_CLSID              UINT32_C(0x0b)
#define IMAGE_DEBUG_TYPE_VC_FEATURE         UINT32_C(0x0c)
#define IMAGE_DEBUG_TYPE_POGO               UINT32_C(0x0d)
#define IMAGE_DEBUG_TYPE_ILTCG              UINT32_C(0x0e)
#define IMAGE_DEBUG_TYPE_MPX                UINT32_C(0x0f)
#define IMAGE_DEBUG_TYPE_REPRO              UINT32_C(0x10)
/** @} */

/** @name IMAGE_DEBUG_MISC_XXX - Misc debug data type.
 * Used by IMAGE_DEBUG_MISC::DataType.
 * @{ */
#define IMAGE_DEBUG_MISC_EXENAME            UINT32_C(1)
/** @} */


/**
 * The format of IMAGE_DEBUG_TYPE_MISC debug info.
 */
typedef struct _IMAGE_DEBUG_MISC
{
    uint32_t   DataType;
    uint32_t   Length;
    uint8_t    Unicode;
    uint8_t    Reserved[3];
    uint8_t    Data[1];
} IMAGE_DEBUG_MISC;
AssertCompileSize(IMAGE_DEBUG_MISC, 16);
typedef IMAGE_DEBUG_MISC *PIMAGE_DEBUG_MISC;
typedef IMAGE_DEBUG_MISC const *PCIMAGE_DEBUG_MISC;



/**
 * The header of a .DBG file (NT4).
 */
typedef struct _IMAGE_SEPARATE_DEBUG_HEADER
{
    uint16_t    Signature;              /**< 0x00 */
    uint16_t    Flags;                  /**< 0x02 */
    uint16_t    Machine;                /**< 0x04 */
    uint16_t    Characteristics;        /**< 0x06 */
    uint32_t    TimeDateStamp;          /**< 0x08 */
    uint32_t    CheckSum;               /**< 0x0c */
    uint32_t    ImageBase;              /**< 0x10 */
    uint32_t    SizeOfImage;            /**< 0x14 */
    uint32_t    NumberOfSections;       /**< 0x18 */
    uint32_t    ExportedNamesSize;      /**< 0x1c */
    uint32_t    DebugDirectorySize;     /**< 0x20 */
    uint32_t    SectionAlignment;       /**< 0x24 */
    uint32_t    Reserved[2];            /**< 0x28 */
} IMAGE_SEPARATE_DEBUG_HEADER;          /* size: 0x30 */
AssertCompileSize(IMAGE_SEPARATE_DEBUG_HEADER, 0x30);
typedef IMAGE_SEPARATE_DEBUG_HEADER *PIMAGE_SEPARATE_DEBUG_HEADER;
typedef IMAGE_SEPARATE_DEBUG_HEADER const *PCIMAGE_SEPARATE_DEBUG_HEADER;

/** The signature of a IMAGE_SEPARATE_DEBUG_HEADER. */
#define IMAGE_SEPARATE_DEBUG_SIGNATURE      UINT16_C(0x4944)


/**
 * The format of IMAGE_DEBUG_TYPE_COFF debug info.
 */
typedef struct _IMAGE_COFF_SYMBOLS_HEADER
{
    uint32_t    NumberOfSymbols;
    uint32_t    LvaToFirstSymbol;
    uint32_t    NumberOfLinenumbers;
    uint32_t    LvaToFirstLinenumber;
    uint32_t    RvaToFirstByteOfCode;
    uint32_t    RvaToLastByteOfCode;
    uint32_t    RvaToFirstByteOfData;
    uint32_t    RvaToLastByteOfData;
} IMAGE_COFF_SYMBOLS_HEADER;
AssertCompileSize(IMAGE_COFF_SYMBOLS_HEADER, 0x20);
typedef IMAGE_COFF_SYMBOLS_HEADER *PIMAGE_COFF_SYMBOLS_HEADER;
typedef IMAGE_COFF_SYMBOLS_HEADER const *PCIMAGE_COFF_SYMBOLS_HEADER;


/**
 * Line number format of IMAGE_DEBUG_TYPE_COFF debug info.
 *
 * @remarks This has misaligned members.
 */
#pragma pack(2)
typedef struct _IMAGE_LINENUMBER
{
    union
    {
        uint32_t    VirtualAddress;
        uint32_t    SymbolTableIndex;
    } Type;
    uint16_t    Linenumber;
} IMAGE_LINENUMBER;
#pragma pack()
AssertCompileSize(IMAGE_LINENUMBER, 6);
typedef IMAGE_LINENUMBER *PIMAGE_LINENUMBER;
typedef IMAGE_LINENUMBER const *PCIMAGE_LINENUMBER;


/** The size of a IMAGE_SYMBOL & IMAGE_AUX_SYMBOL structure. */
#define IMAGE_SIZE_OF_SYMBOL                18
/** The size of a IMAGE_SYMBOL_EX & IMAGE_AUX_SYMBOL_EX structure. */
#define IMAGE_SIZE_OF_SYMBOL_EX             20

/**
 * COFF symbol.
 */
#pragma pack(2)
typedef struct _IMAGE_SYMBOL
{
    union
    {
        uint8_t         ShortName[8];
        struct
        {
            uint32_t    Short;
            uint32_t    Long;
        } Name;
        uint32_t        LongName[2];
    } N;

    uint32_t    Value;
    int16_t     SectionNumber;
    uint16_t    Type;
    uint8_t     StorageClass;
    uint8_t     NumberOfAuxSymbols;
} IMAGE_SYMBOL;
#pragma pack()
AssertCompileSize(IMAGE_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
typedef IMAGE_SYMBOL *PIMAGE_SYMBOL;
typedef IMAGE_SYMBOL const *PCIMAGE_SYMBOL;

/**
 * COFF auxiliary symbol token defintion (whatever that is).
 */
#pragma pack(2)
typedef struct IMAGE_AUX_SYMBOL_TOKEN_DEF
{
    uint8_t     bAuxType;
    uint8_t     bReserved;
    uint32_t    SymbolTableIndex;
    uint8_t     rgbReserved[12];
} IMAGE_AUX_SYMBOL_TOKEN_DEF;
#pragma pack()
AssertCompileSize(IMAGE_AUX_SYMBOL_TOKEN_DEF, IMAGE_SIZE_OF_SYMBOL);
typedef IMAGE_AUX_SYMBOL_TOKEN_DEF *PIMAGE_AUX_SYMBOL_TOKEN_DEF;
typedef IMAGE_AUX_SYMBOL_TOKEN_DEF const *PCIMAGE_AUX_SYMBOL_TOKEN_DEF;

/**
 * COFF auxiliary symbol.
 */
#pragma pack(1)
typedef union _IMAGE_AUX_SYMBOL
{
    struct
    {
        uint32_t    TagIndex;
        union
        {
            struct
            {
                uint16_t    Linenumber;
                uint16_t    Size;
            } LnSz;
        } Misc;
        union
        {
            struct
            {
                uint32_t    PointerToLinenumber;
                uint32_t    PointerToNextFunction;
            } Function;
            struct
            {
                uint16_t    Dimension[4];
            } Array;
        } FcnAry;
        uint16_t    TvIndex;
    } Sym;

    struct
    {
        uint8_t     Name[IMAGE_SIZE_OF_SYMBOL];
    } File;

    struct
    {
        uint32_t    Length;
        uint16_t    NumberOfRelocations;
        uint16_t    NumberOfLinenumbers;
        uint32_t    CheckSum;
        uint16_t    Number;
        uint8_t     Selection;
        uint8_t     bReserved;
        uint16_t    HighNumber;
    } Section;

    IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;
    struct
    {
        uint32_t    crc;
        uint8_t     rgbReserved[14];
    } CRC;
} IMAGE_AUX_SYMBOL;
#pragma pack()
AssertCompileSize(IMAGE_AUX_SYMBOL, IMAGE_SIZE_OF_SYMBOL);
typedef IMAGE_AUX_SYMBOL *PIMAGE_AUX_SYMBOL;
typedef IMAGE_AUX_SYMBOL const *PCIMAGE_AUX_SYMBOL;


/**
 * Extended COFF symbol.
 */
typedef struct _IMAGE_SYMBOL_EX
{
    union
    {
        uint8_t         ShortName[8];
        struct
        {
            uint32_t    Short;
            uint32_t    Long;
        } Name;
        uint32_t        LongName[2];
    } N;

    uint32_t    Value;
    int32_t     SectionNumber;          /* The difference from IMAGE_SYMBOL */
    uint16_t    Type;
    uint8_t     StorageClass;
    uint8_t     NumberOfAuxSymbols;
} IMAGE_SYMBOL_EX;
AssertCompileSize(IMAGE_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
typedef IMAGE_SYMBOL_EX *PIMAGE_SYMBOL_EX;
typedef IMAGE_SYMBOL_EX const *PCIMAGE_SYMBOL_EX;

/**
 * Extended COFF auxiliary symbol.
 */
typedef union _IMAGE_AUX_SYMBOL_EX
{
    struct
    {
        uint32_t    WeakDefaultSymIndex;
        uint32_t    WeakSearchType;
        uint8_t     rgbReserved[12];
    } Sym;

    struct
    {
        uint8_t     Name[IMAGE_SIZE_OF_SYMBOL_EX];
    } File;

    struct
    {
        uint32_t    Length;
        uint16_t    NumberOfRelocations;
        uint16_t    NumberOfLinenumbers;
        uint32_t    CheckSum;
        uint16_t    Number;
        uint8_t     Selection;
        uint8_t     bReserved;
        uint16_t    HighNumber;
        uint8_t     rgbReserved[2];
    } Section;

    IMAGE_AUX_SYMBOL_TOKEN_DEF TokenDef;

    struct
    {
        uint32_t    crc;
        uint8_t     rgbReserved[16];
    } CRC;
} IMAGE_AUX_SYMBOL_EX;
AssertCompileSize(IMAGE_AUX_SYMBOL_EX, IMAGE_SIZE_OF_SYMBOL_EX);
typedef IMAGE_AUX_SYMBOL_EX *PIMAGE_AUX_SYMBOL_EX;
typedef IMAGE_AUX_SYMBOL_EX const *PCIMAGE_AUX_SYMBOL_EX;

/** @name Special COFF section numbers.
 * Used by IMAGE_SYMBOL::SectionNumber and IMAGE_SYMBOL_EX::SectionNumber
 * @{ */
#define IMAGE_SYM_UNDEFINED                 INT16_C(0)
#define IMAGE_SYM_ABSOLUTE                  INT16_C(-1)
#define IMAGE_SYM_DEBUG                     INT16_C(-2)
/** @} */

/** @name IMAGE_SYM_CLASS_XXX - COFF symbol storage classes.
 * @{ */
#define IMAGE_SYM_CLASS_END_OF_FUNCTION     UINT8_C(0xff) /* -1 */
#define IMAGE_SYM_CLASS_NULL                UINT8_C(0)
#define IMAGE_SYM_CLASS_AUTOMATIC           UINT8_C(1)
#define IMAGE_SYM_CLASS_EXTERNAL            UINT8_C(2)
#define IMAGE_SYM_CLASS_STATIC              UINT8_C(3)
#define IMAGE_SYM_CLASS_REGISTER            UINT8_C(4)
#define IMAGE_SYM_CLASS_EXTERNAL_DEF        UINT8_C(5)
#define IMAGE_SYM_CLASS_LABEL               UINT8_C(6)
#define IMAGE_SYM_CLASS_UNDEFINED_LABEL     UINT8_C(7)
#define IMAGE_SYM_CLASS_MEMBER_OF_STRUCT    UINT8_C(8)
#define IMAGE_SYM_CLASS_ARGUMENT            UINT8_C(9)
#define IMAGE_SYM_CLASS_STRUCT_TAG          UINT8_C(10)
#define IMAGE_SYM_CLASS_MEMBER_OF_UNION     UINT8_C(11)
#define IMAGE_SYM_CLASS_UNION_TAG           UINT8_C(12)
#define IMAGE_SYM_CLASS_TYPE_DEFINITION     UINT8_C(13)
#define IMAGE_SYM_CLASS_UNDEFINED_STATIC    UINT8_C(14)
#define IMAGE_SYM_CLASS_ENUM_TAG            UINT8_C(15)
#define IMAGE_SYM_CLASS_MEMBER_OF_ENUM      UINT8_C(16)
#define IMAGE_SYM_CLASS_REGISTER_PARAM      UINT8_C(17)
#define IMAGE_SYM_CLASS_BIT_FIELD           UINT8_C(18)
#define IMAGE_SYM_CLASS_FAR_EXTERNAL        UINT8_C(68)
#define IMAGE_SYM_CLASS_BLOCK               UINT8_C(100)
#define IMAGE_SYM_CLASS_FUNCTION            UINT8_C(101)
#define IMAGE_SYM_CLASS_END_OF_STRUCT       UINT8_C(102)
#define IMAGE_SYM_CLASS_FILE                UINT8_C(103)
#define IMAGE_SYM_CLASS_SECTION             UINT8_C(104)
#define IMAGE_SYM_CLASS_WEAK_EXTERNAL       UINT8_C(105)
#define IMAGE_SYM_CLASS_CLR_TOKEN           UINT8_C(107)
/** @} */

/** @name IMAGE_SYM_TYPE_XXX - COFF symbol base types
 * @{ */
#define IMAGE_SYM_TYPE_NULL                 UINT16_C(0x0000)
#define IMAGE_SYM_TYPE_VOID                 UINT16_C(0x0001)
#define IMAGE_SYM_TYPE_CHAR                 UINT16_C(0x0002)
#define IMAGE_SYM_TYPE_SHORT                UINT16_C(0x0003)
#define IMAGE_SYM_TYPE_INT                  UINT16_C(0x0004)
#define IMAGE_SYM_TYPE_LONG                 UINT16_C(0x0005)
#define IMAGE_SYM_TYPE_FLOAT                UINT16_C(0x0006)
#define IMAGE_SYM_TYPE_DOUBLE               UINT16_C(0x0007)
#define IMAGE_SYM_TYPE_STRUCT               UINT16_C(0x0008)
#define IMAGE_SYM_TYPE_UNION                UINT16_C(0x0009)
#define IMAGE_SYM_TYPE_ENUM                 UINT16_C(0x000a)
#define IMAGE_SYM_TYPE_MOE                  UINT16_C(0x000b)
#define IMAGE_SYM_TYPE_BYTE                 UINT16_C(0x000c)
#define IMAGE_SYM_TYPE_WORD                 UINT16_C(0x000d)
#define IMAGE_SYM_TYPE_UINT                 UINT16_C(0x000e)
#define IMAGE_SYM_TYPE_DWORD                UINT16_C(0x000f)
#define IMAGE_SYM_TYPE_PCODE                UINT16_C(0x8000)
/** @} */

/** @name IMAGE_SYM_DTYPE_XXX - COFF symbol complex types
 * @{ */
#define IMAGE_SYM_DTYPE_NULL                UINT16_C(0x0)
#define IMAGE_SYM_DTYPE_POINTER             UINT16_C(0x1)
#define IMAGE_SYM_DTYPE_FUNCTION            UINT16_C(0x2)
#define IMAGE_SYM_DTYPE_ARRAY               UINT16_C(0x3)
/** @} */

/** @name COFF Symbol type masks and shift counts.
 * @{ */
#define N_BTMASK                            UINT16_C(0x000f)
#define N_TMASK                             UINT16_C(0x0030)
#define N_TMASK1                            UINT16_C(0x00c0)
#define N_TMASK2                            UINT16_C(0x00f0)
#define N_BTSHFT                            4
#define N_TSHIFT                            2
/** @} */

/** @name COFF Symbol type macros.
 * @{  */
#define BTYPE(a_Type)                       ( (a_Type) & N_BTMASK )
#define ISPTR(a_Type)                       ( ((a_Type) & N_TMASK) == (IMAGE_SYM_DTYPE_POINTER  << N_BTSHFT) )
#define ISFCN(a_Type)                       ( ((a_Type) & N_TMASK) == (IMAGE_SYM_DTYPE_FUNCTION << N_BTSHFT) )
#define ISARY(a_Type)                       ( ((a_Type) & N_TMASK) == (IMAGE_SYM_DTYPE_ARRAY    << N_BTSHFT) )
#define ISTAG(a_StorageClass)               (    (a_StorageClass) == IMAGE_SYM_CLASS_STRUCT_TAG \
                                              || (a_StorageClass) == IMAGE_SYM_CLASS_UNION_TAG \
                                              || (a_StorageClass) == IMAGE_SYM_CLASS_ENUM_TAG )
/** @} */


/**
 * COFF relocation table entry.
 *
 * @note The size of the structure is not a multiple of the largest member
 *       (uint32_t), so odd relocation table entry members will have
 *       misaligned uint32_t members.
 */
#pragma pack(1)
typedef struct _IMAGE_RELOCATION
{
    union
    {
        uint32_t    VirtualAddress;
        uint32_t    RelocCount;
    } u;
    uint32_t        SymbolTableIndex;
    uint16_t        Type;
} IMAGE_RELOCATION;
#pragma pack()
/** The size of a COFF relocation entry.   */
#define IMAGE_SIZEOF_RELOCATION 10
AssertCompileSize(IMAGE_RELOCATION, IMAGE_SIZEOF_RELOCATION);
typedef IMAGE_RELOCATION *PIMAGE_RELOCATION;
typedef IMAGE_RELOCATION const *PCIMAGE_RELOCATION;


/** @name IMAGE_REL_AMD64_XXX - COFF relocations for AMD64 CPUs.
 * Used by IMAGE_RELOCATION::Type.
 * @{ */
#define IMAGE_REL_AMD64_ABSOLUTE            UINT16_C(0x0000)
#define IMAGE_REL_AMD64_ADDR64              UINT16_C(0x0001)
#define IMAGE_REL_AMD64_ADDR32              UINT16_C(0x0002)
#define IMAGE_REL_AMD64_ADDR32NB            UINT16_C(0x0003)
#define IMAGE_REL_AMD64_REL32               UINT16_C(0x0004)
#define IMAGE_REL_AMD64_REL32_1             UINT16_C(0x0005)
#define IMAGE_REL_AMD64_REL32_2             UINT16_C(0x0006)
#define IMAGE_REL_AMD64_REL32_3             UINT16_C(0x0007)
#define IMAGE_REL_AMD64_REL32_4             UINT16_C(0x0008)
#define IMAGE_REL_AMD64_REL32_5             UINT16_C(0x0009)
#define IMAGE_REL_AMD64_SECTION             UINT16_C(0x000a)
#define IMAGE_REL_AMD64_SECREL              UINT16_C(0x000b)
#define IMAGE_REL_AMD64_SECREL7             UINT16_C(0x000c)
#define IMAGE_REL_AMD64_TOKEN               UINT16_C(0x000d)
#define IMAGE_REL_AMD64_SREL32              UINT16_C(0x000e)
#define IMAGE_REL_AMD64_PAIR                UINT16_C(0x000f)
#define IMAGE_REL_AMD64_SSPAN32             UINT16_C(0x0010)
/** @} */

/** @name ARM IMAGE_REL_ARM_XXX - COFF relocations for ARM CPUs.
 * Used by IMAGE_RELOCATION::Type.
 * @{ */
#define IMAGE_REL_ARM_ABSOLUTE              UINT16_C(0x0000)
#define IMAGE_REL_ARM_ADDR32                UINT16_C(0x0001)
#define IMAGE_REL_ARM_ADDR32NB              UINT16_C(0x0002)
#define IMAGE_REL_ARM_BRANCH24              UINT16_C(0x0003)
#define IMAGE_REL_ARM_BRANCH11              UINT16_C(0x0004)
#define IMAGE_REL_ARM_TOKEN                 UINT16_C(0x0005)
#define IMAGE_REL_ARM_BLX24                 UINT16_C(0x0008)
#define IMAGE_REL_ARM_BLX11                 UINT16_C(0x0009)
#define IMAGE_REL_ARM_SECTION               UINT16_C(0x000e)
#define IMAGE_REL_ARM_SECREL                UINT16_C(0x000f)
#define IMAGE_REL_ARM_MOV32A                UINT16_C(0x0010)
#define IMAGE_REL_ARM_MOV32T                UINT16_C(0x0011)
#define IMAGE_REL_ARM_BRANCH20T             UINT16_C(0x0012)
#define IMAGE_REL_ARM_BRANCH24T             UINT16_C(0x0014)
#define IMAGE_REL_ARM_BLX23T                UINT16_C(0x0015)
/** @} */

/** @name IMAGE_REL_ARM64_XXX - COFF relocations for ARMv8 CPUs (64-bit).
 * Used by IMAGE_RELOCATION::Type.
 * @{ */
#define IMAGE_REL_ARM64_ABSOLUTE            UINT16_C(0x0000)
#define IMAGE_REL_ARM64_ADDR32              UINT16_C(0x0001)
#define IMAGE_REL_ARM64_ADDR32NB            UINT16_C(0x0002)
#define IMAGE_REL_ARM64_BRANCH26            UINT16_C(0x0003)
#define IMAGE_REL_ARM64_PAGEBASE_REL21      UINT16_C(0x0004)
#define IMAGE_REL_ARM64_REL21               UINT16_C(0x0005)
#define IMAGE_REL_ARM64_PAGEOFFSET_12A      UINT16_C(0x0006)
#define IMAGE_REL_ARM64_PAGEOFFSET_12L      UINT16_C(0x0007)
#define IMAGE_REL_ARM64_SECREL              UINT16_C(0x0008)
#define IMAGE_REL_ARM64_SECREL_LOW12A       UINT16_C(0x0009)
#define IMAGE_REL_ARM64_SECREL_HIGH12A      UINT16_C(0x000a)
#define IMAGE_REL_ARM64_SECREL_LOW12L       UINT16_C(0x000b)
#define IMAGE_REL_ARM64_TOKEN               UINT16_C(0x000c)
#define IMAGE_REL_ARM64_SECTION             UINT16_C(0x000d)
#define IMAGE_REL_ARM64_ADDR64              UINT16_C(0x000e)
/** @} */

/** @name IMAGE_REL_SH3_XXX - COFF relocation for Hitachi SuperH CPUs.
 * Used by IMAGE_RELOCATION::Type.
 * @{ */
#define IMAGE_REL_SH3_ABSOLUTE              UINT16_C(0x0000)
#define IMAGE_REL_SH3_DIRECT16              UINT16_C(0x0001)
#define IMAGE_REL_SH3_DIRECT32              UINT16_C(0x0002)
#define IMAGE_REL_SH3_DIRECT8               UINT16_C(0x0003)
#define IMAGE_REL_SH3_DIRECT8_WORD          UINT16_C(0x0004)
#define IMAGE_REL_SH3_DIRECT8_LONG          UINT16_C(0x0005)
#define IMAGE_REL_SH3_DIRECT4               UINT16_C(0x0006)
#define IMAGE_REL_SH3_DIRECT4_WORD          UINT16_C(0x0007)
#define IMAGE_REL_SH3_DIRECT4_LONG          UINT16_C(0x0008)
#define IMAGE_REL_SH3_PCREL8_WORD           UINT16_C(0x0009)
#define IMAGE_REL_SH3_PCREL8_LONG           UINT16_C(0x000a)
#define IMAGE_REL_SH3_PCREL12_WORD          UINT16_C(0x000b)
#define IMAGE_REL_SH3_STARTOF_SECTION       UINT16_C(0x000c)
#define IMAGE_REL_SH3_SIZEOF_SECTION        UINT16_C(0x000d)
#define IMAGE_REL_SH3_SECTION               UINT16_C(0x000e)
#define IMAGE_REL_SH3_SECREL                UINT16_C(0x000f)
#define IMAGE_REL_SH3_DIRECT32_NB           UINT16_C(0x0010)
#define IMAGE_REL_SH3_GPREL4_LONG           UINT16_C(0x0011)
#define IMAGE_REL_SH3_TOKEN                 UINT16_C(0x0012)
#define IMAGE_REL_SHM_PCRELPT               UINT16_C(0x0013)
#define IMAGE_REL_SHM_REFLO                 UINT16_C(0x0014)
#define IMAGE_REL_SHM_REFHALF               UINT16_C(0x0015)
#define IMAGE_REL_SHM_RELLO                 UINT16_C(0x0016)
#define IMAGE_REL_SHM_RELHALF               UINT16_C(0x0017)
#define IMAGE_REL_SHM_PAIR                  UINT16_C(0x0018)
#define IMAGE_REL_SHM_NOMODE                UINT16_C(0x8000)
/** @} */

/** @name IMAGE_REL_PPC_XXX - COFF relocations for IBM PowerPC CPUs.
 * Used by IMAGE_RELOCATION::Type.
 * @{ */
#define IMAGE_REL_PPC_ABSOLUTE              UINT16_C(0x0000)
#define IMAGE_REL_PPC_ADDR64                UINT16_C(0x0001)
#define IMAGE_REL_PPC_ADDR32                UINT16_C(0x0002)
#define IMAGE_REL_PPC_ADDR24                UINT16_C(0x0003)
#define IMAGE_REL_PPC_ADDR16                UINT16_C(0x0004)
#define IMAGE_REL_PPC_ADDR14                UINT16_C(0x0005)
#define IMAGE_REL_PPC_REL24                 UINT16_C(0x0006)
#define IMAGE_REL_PPC_REL14                 UINT16_C(0x0007)
#define IMAGE_REL_PPC_ADDR32NB              UINT16_C(0x000a)
#define IMAGE_REL_PPC_SECREL                UINT16_C(0x000b)
#define IMAGE_REL_PPC_SECTION               UINT16_C(0x000c)
#define IMAGE_REL_PPC_SECREL16              UINT16_C(0x000f)
#define IMAGE_REL_PPC_REFHI                 UINT16_C(0x0010)
#define IMAGE_REL_PPC_REFLO                 UINT16_C(0x0011)
#define IMAGE_REL_PPC_PAIR                  UINT16_C(0x0012)
#define IMAGE_REL_PPC_SECRELLO              UINT16_C(0x0013)
#define IMAGE_REL_PPC_GPREL                 UINT16_C(0x0015)
#define IMAGE_REL_PPC_TOKEN                 UINT16_C(0x0016)
/** @} */

/** @name IMAGE_REL_I386_XXX - COFF relocations for x86 CPUs.
 * Used by IMAGE_RELOCATION::Type.
 * @{ */
#define IMAGE_REL_I386_ABSOLUTE             UINT16_C(0x0000)
#define IMAGE_REL_I386_DIR16                UINT16_C(0x0001)
#define IMAGE_REL_I386_REL16                UINT16_C(0x0002)
#define IMAGE_REL_I386_DIR32                UINT16_C(0x0006)
#define IMAGE_REL_I386_DIR32NB              UINT16_C(0x0007)
#define IMAGE_REL_I386_SEG12                UINT16_C(0x0009)
#define IMAGE_REL_I386_SECTION              UINT16_C(0x000A)
#define IMAGE_REL_I386_SECREL               UINT16_C(0x000B)
#define IMAGE_REL_I386_TOKEN                UINT16_C(0x000C)
#define IMAGE_REL_I386_SECREL7              UINT16_C(0x000D)
#define IMAGE_REL_I386_REL32                UINT16_C(0x0014)
/** @} */

/** @name IMAGE_REL_IA64_XXX - COFF relocations for "Itanic" CPUs.
 * @{ */
#define IMAGE_REL_IA64_ABSOLUTE             UINT16_C(0x0000)
#define IMAGE_REL_IA64_IMM14                UINT16_C(0x0001)
#define IMAGE_REL_IA64_IMM22                UINT16_C(0x0002)
#define IMAGE_REL_IA64_IMM64                UINT16_C(0x0003)
#define IMAGE_REL_IA64_DIR32                UINT16_C(0x0004)
#define IMAGE_REL_IA64_DIR64                UINT16_C(0x0005)
#define IMAGE_REL_IA64_PCREL21B             UINT16_C(0x0006)
#define IMAGE_REL_IA64_PCREL21M             UINT16_C(0x0007)
#define IMAGE_REL_IA64_PCREL21F             UINT16_C(0x0008)
#define IMAGE_REL_IA64_GPREL22              UINT16_C(0x0009)
#define IMAGE_REL_IA64_LTOFF22              UINT16_C(0x000a)
#define IMAGE_REL_IA64_SECTION              UINT16_C(0x000b)
#define IMAGE_REL_IA64_SECREL22             UINT16_C(0x000c)
#define IMAGE_REL_IA64_SECREL64I            UINT16_C(0x000d)
#define IMAGE_REL_IA64_SECREL32             UINT16_C(0x000e)
#define IMAGE_REL_IA64_DIR32NB              UINT16_C(0x0010)
#define IMAGE_REL_IA64_SREL14               UINT16_C(0x0011)
#define IMAGE_REL_IA64_SREL22               UINT16_C(0x0012)
#define IMAGE_REL_IA64_SREL32               UINT16_C(0x0013)
#define IMAGE_REL_IA64_UREL32               UINT16_C(0x0014)
#define IMAGE_REL_IA64_PCREL60X             UINT16_C(0x0015)
#define IMAGE_REL_IA64_PCREL60B             UINT16_C(0x0016)
#define IMAGE_REL_IA64_PCREL60F             UINT16_C(0x0017)
#define IMAGE_REL_IA64_PCREL60I             UINT16_C(0x0018)
#define IMAGE_REL_IA64_PCREL60M             UINT16_C(0x0019)
#define IMAGE_REL_IA64_IMMGPREL64           UINT16_C(0x001a)
#define IMAGE_REL_IA64_TOKEN                UINT16_C(0x001b)
#define IMAGE_REL_IA64_GPREL32              UINT16_C(0x001c)
#define IMAGE_REL_IA64_ADDEND               UINT16_C(0x001f)
/** @} */

/** @name IMAGE_REL_MIPS_XXX - COFF relocations for MIPS CPUs.
 * Used by IMAGE_RELOCATION::Type.
 * @{ */
#define IMAGE_REL_MIPS_ABSOLUTE             UINT16_C(0x0000)
#define IMAGE_REL_MIPS_REFHALF              UINT16_C(0x0001)
#define IMAGE_REL_MIPS_REFWORD              UINT16_C(0x0002)
#define IMAGE_REL_MIPS_JMPADDR              UINT16_C(0x0003)
#define IMAGE_REL_MIPS_REFHI                UINT16_C(0x0004)
#define IMAGE_REL_MIPS_REFLO                UINT16_C(0x0005)
#define IMAGE_REL_MIPS_GPREL                UINT16_C(0x0006)
#define IMAGE_REL_MIPS_LITERAL              UINT16_C(0x0007)
#define IMAGE_REL_MIPS_SECTION              UINT16_C(0x000a)
#define IMAGE_REL_MIPS_SECREL               UINT16_C(0x000b)
#define IMAGE_REL_MIPS_SECRELLO             UINT16_C(0x000c)
#define IMAGE_REL_MIPS_SECRELHI             UINT16_C(0x000d)
#define IMAGE_REL_MIPS_JMPADDR16            UINT16_C(0x0010)
#define IMAGE_REL_MIPS_REFWORDNB            UINT16_C(0x0022)
#define IMAGE_REL_MIPS_PAIR                 UINT16_C(0x0025)
/** @} */

/** @name IMAGE_REL_M32R_XXX - COFF relocations for Mitsubishi M32R CPUs.
 * Used by IMAGE_RELOCATION::Type.
 * @{ */
#define IMAGE_REL_M32R_ABSOLUTE             UINT16_C(0x0000)
#define IMAGE_REL_M32R_ADDR32               UINT16_C(0x0001)
#define IMAGE_REL_M32R_ADDR32NB             UINT16_C(0x0002)
#define IMAGE_REL_M32R_ADDR24               UINT16_C(0x0003)
#define IMAGE_REL_M32R_GPREL16              UINT16_C(0x0004)
#define IMAGE_REL_M32R_PCREL24              UINT16_C(0x0005)
#define IMAGE_REL_M32R_PCREL16              UINT16_C(0x0006)
#define IMAGE_REL_M32R_PCREL8               UINT16_C(0x0007)
#define IMAGE_REL_M32R_REFHALF              UINT16_C(0x0008)
#define IMAGE_REL_M32R_REFHI                UINT16_C(0x0009)
#define IMAGE_REL_M32R_REFLO                UINT16_C(0x000a)
#define IMAGE_REL_M32R_PAIR                 UINT16_C(0x000b)
#define IMAGE_REL_M32R_SECTION              UINT16_C(0x000c)
#define IMAGE_REL_M32R_SECREL               UINT16_C(0x000d)
#define IMAGE_REL_M32R_TOKEN                UINT16_C(0x000e)
/** @} */


/** @} */

#endif /* !IPRT_INCLUDED_formats_pecoff_h */