emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/w32proc.c,v [EMACS_22_BASE]


From: Jason Rumney
Subject: [Emacs-diffs] Changes to emacs/src/w32proc.c,v [EMACS_22_BASE]
Date: Wed, 18 Jul 2007 22:19:57 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Branch:         EMACS_22_BASE
Changes by:     Jason Rumney <jasonr>   07/07/18 22:19:57

Index: w32proc.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32proc.c,v
retrieving revision 1.70
retrieving revision 1.70.2.1
diff -u -b -r1.70 -r1.70.2.1
--- w32proc.c   21 Jan 2007 04:18:15 -0000      1.70
+++ w32proc.c   18 Jul 2007 22:19:57 -0000      1.70.2.1
@@ -650,18 +650,43 @@
        }
       else if (nt_header->Signature == IMAGE_NT_SIGNATURE)
        {
+          IMAGE_DATA_DIRECTORY *data_dir = NULL;
+          if (nt_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
+            {
+              /* Ensure we are using the 32 bit structure.  */
+              IMAGE_OPTIONAL_HEADER32 *opt
+                = (IMAGE_OPTIONAL_HEADER32*) &(nt_header->OptionalHeader);
+              data_dir = opt->DataDirectory;
+              *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI);
+            }
+          /* MingW 3.12 has the required 64 bit structs, but in case older
+             versions don't, only check 64 bit exes if we know how.  */
+#ifdef IMAGE_NT_OPTIONAL_HDR64_MAGIC
+          else if (nt_header->OptionalHeader.Magic
+                   == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
+            {
+              IMAGE_OPTIONAL_HEADER64 *opt
+                = (IMAGE_OPTIONAL_HEADER64*) &(nt_header->OptionalHeader);
+              data_dir = opt->DataDirectory;
+              *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI);
+            }
+#endif
+          if (data_dir)
+            {
          /* Look for cygwin.dll in DLL import list. */
          IMAGE_DATA_DIRECTORY import_dir =
-           
nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
+                data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT];
          IMAGE_IMPORT_DESCRIPTOR * imports;
          IMAGE_SECTION_HEADER * section;
 
          section = rva_to_section (import_dir.VirtualAddress, nt_header);
-         imports = RVA_TO_PTR (import_dir.VirtualAddress, section, executable);
+              imports = RVA_TO_PTR (import_dir.VirtualAddress, section,
+                                    executable);
 
          for ( ; imports->Name; imports++)
            {
-             char * dllname = RVA_TO_PTR (imports->Name, section, executable);
+                  char * dllname = RVA_TO_PTR (imports->Name, section,
+                                               executable);
 
              /* The exact name of the cygwin dll has changed with
                 various releases, but hopefully this will be reasonably
@@ -672,11 +697,7 @@
                  break;
                }
            }
-
-         /* Check whether app is marked as a console or windowed (aka
-             GUI) app.  Accept Posix and OS2 subsytem apps as console
-             apps.  */
-         *is_gui_app = (nt_header->OptionalHeader.Subsystem == 
IMAGE_SUBSYSTEM_WINDOWS_GUI);
+            }
        }
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]