Added high-entropy-va and control-flow-guard flags.

Also fixed an apparent copy-paste error on posix subsystem, and added
numeric value to XBOX subsystem for consistency with the others.

Signed-off-by: Jeremy Drake <[email protected]>
---
 mingw-w64-tools/genpeimg/src/genpeimg.c | 12 +++++++++++-
 mingw-w64-tools/genpeimg/src/img_pe.c   |  8 +++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/mingw-w64-tools/genpeimg/src/genpeimg.c 
b/mingw-w64-tools/genpeimg/src/genpeimg.c
index 1ebe607d9..c18d9ab9f 100644
--- a/mingw-w64-tools/genpeimg/src/genpeimg.c
+++ b/mingw-w64-tools/genpeimg/src/genpeimg.c
@@ -46,7 +46,8 @@ show_usage (void)
     " -d  Takes as addition argument one or more of the following\n"
     "     options:\n"
     "  +<flags> and/or -<flags>\n"
-    "  flags are: d, f, n, i, s, b, a, w, t\n"
+    "  flags are: e, d, f, n, i, s, b, a, w, c, t\n"
+    "    e: high entropy va\n"
     "    d: dynamic base\n"
     "    f: force integrity\n"
     "    n: nx compatible\n"
@@ -55,6 +56,7 @@ show_usage (void)
     "    b: no-bind\n"
     "    a: app-container\n"
     "    w: WDM-driver\n"
+    "    c: control-flow-guard\n"
     "    t: terminal-server-aware\n");
   fprintf (stderr,
     " -h: Show this page.\n"
@@ -150,6 +152,10 @@ pass_args (int argc, char **argv)
                {
                case '-': is_pos = 0; break;
                case '+': is_pos = 1; break;
+               case 'e':
+                 if (is_pos) set_pe_opt_hdr_dll_chara |= 0x20;
+                 else mask_pe_opt_hdr_dll_chara &= ~0x20;
+                 break;
                case 'd':
                  if (is_pos) set_pe_opt_hdr_dll_chara |= 0x40;
                  else mask_pe_opt_hdr_dll_chara &= ~0x40;
@@ -182,6 +188,10 @@ pass_args (int argc, char **argv)
                  if (is_pos) set_pe_opt_hdr_dll_chara |= 0x2000;
                  else mask_pe_opt_hdr_dll_chara &= ~0x2000;
                  break;
+               case 'c':
+                 if (is_pos) set_pe_opt_hdr_dll_chara |= 0x4000;
+                 else mask_pe_opt_hdr_dll_chara &= ~0x4000;
+                 break;
                case 't':
                  if (is_pos) set_pe_opt_hdr_dll_chara |= 0x8000;
                  else mask_pe_opt_hdr_dll_chara &= ~0x8000;
diff --git a/mingw-w64-tools/genpeimg/src/img_pe.c 
b/mingw-w64-tools/genpeimg/src/img_pe.c
index 98d63c428..e7ecbcd5b 100644
--- a/mingw-w64-tools/genpeimg/src/img_pe.c
+++ b/mingw-w64-tools/genpeimg/src/img_pe.c
@@ -272,14 +272,14 @@ peimg_show (pe_image *ppeimg, FILE *outfp)
     case 2: fprintf (outfp, "Windows GUI (2)\n"); break;
     case 3: fprintf (outfp, "Windows CUI (3)\n"); break;
     case 5: fprintf (outfp, "OS/2 CUI (5)\n"); break;
-    case 7: fprintf (outfp, "Posix CUI (4)\n"); break;
+    case 7: fprintf (outfp, "Posix CUI (7)\n"); break;
     case 8: fprintf (outfp, "Native Windows (8)\n"); break;
     case 9: fprintf (outfp, "Windows CE GUI (9)\n"); break;
     case 10: fprintf (outfp, "EFI Application (10)\n"); break;
     case 11: fprintf (outfp, "EFI Service Driver (11)\n"); break;
     case 12: fprintf (outfp, "EFI Runtime Driver (12)\n"); break;
     case 13: fprintf (outfp, "EFI ROM (13)\n"); break;
-    case 14: fprintf (outfp, "XBOX\n"); break;
+    case 14: fprintf (outfp, "XBOX (14)\n"); break;
     case 16: fprintf (outfp, "Windows Boot Application (16)\n"); break;
     default:
       fprintf (outfp, "Unkown (%u)\n", PEIMG_GET_USHORT (ppeimg, 
ppeimg->optional_hdr_pos + 68));
@@ -290,7 +290,7 @@ peimg_show (pe_image *ppeimg, FILE *outfp)
     {
       fprintf (outfp, "  Optional Characteristics:\n   ");
       if ((hdr_cha & 0x20) != 0)
-       fprintf (outfp, " large-address-aware");
+       fprintf (outfp, " high-entropy-va");
       if ((hdr_cha & 0x40) != 0)
         fprintf (outfp, " dynamic-base");
       if ((hdr_cha & 0x80) != 0)
@@ -307,6 +307,8 @@ peimg_show (pe_image *ppeimg, FILE *outfp)
        fprintf (outfp, " app-container");
       if ((hdr_cha & 0x2000) != 0)
         fprintf (outfp, " wdm-Driver");
+      if ((hdr_cha & 0x4000) != 0)
+        fprintf (outfp, " control-flow-guard");
       if ((hdr_cha & 0x8000) != 0)
         fprintf (outfp, " terminal-server-aware");
       hdr_cha &= ~(0xbfef);
-- 
2.32.0.windows.2



_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to