aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32proc.c
diff options
context:
space:
mode:
authorMiles Bader2007-07-24 01:23:55 +0000
committerMiles Bader2007-07-24 01:23:55 +0000
commitd918f936d5bfc7e126cc3b1bbf6ce80836c8d6f1 (patch)
treec2dad763df03a5380928485043f9999c7a3533a6 /src/w32proc.c
parenta1ef75fc233b19951f65bd2a177751751f9676a3 (diff)
parent1e8995158740b15936887264a3d7183beb5c51d9 (diff)
downloademacs-d918f936d5bfc7e126cc3b1bbf6ce80836c8d6f1.tar.gz
emacs-d918f936d5bfc7e126cc3b1bbf6ce80836c8d6f1.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 816-823) - Update from CVS - Merge from emacs--rel--22 * emacs--rel--22 (patch 59-69) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 237-238) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-235
Diffstat (limited to 'src/w32proc.c')
-rw-r--r--src/w32proc.c82
1 files changed, 55 insertions, 27 deletions
diff --git a/src/w32proc.c b/src/w32proc.c
index ab768527658..a7c2cff450d 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -591,6 +591,13 @@ get_result:
591 return pid; 591 return pid;
592} 592}
593 593
594/* Old versions of w32api headers don't have separate 32-bit and
595 64-bit defines, but the one they have matches the 32-bit variety. */
596#ifndef IMAGE_NT_OPTIONAL_HDR32_MAGIC
597# define IMAGE_NT_OPTIONAL_HDR32_MAGIC IMAGE_NT_OPTIONAL_HDR_MAGIC
598# define IMAGE_OPTIONAL_HEADER32 IMAGE_OPTIONAL_HEADER
599#endif
600
594void 601void
595w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app, int * is_gui_app) 602w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app, int * is_gui_app)
596{ 603{
@@ -651,33 +658,54 @@ w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app, int
651 } 658 }
652 else if (nt_header->Signature == IMAGE_NT_SIGNATURE) 659 else if (nt_header->Signature == IMAGE_NT_SIGNATURE)
653 { 660 {
654 /* Look for cygwin.dll in DLL import list. */ 661 IMAGE_DATA_DIRECTORY *data_dir = NULL;
655 IMAGE_DATA_DIRECTORY import_dir = 662 if (nt_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
656 nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]; 663 {
657 IMAGE_IMPORT_DESCRIPTOR * imports; 664 /* Ensure we are using the 32 bit structure. */
658 IMAGE_SECTION_HEADER * section; 665 IMAGE_OPTIONAL_HEADER32 *opt
659 666 = (IMAGE_OPTIONAL_HEADER32*) &(nt_header->OptionalHeader);
660 section = rva_to_section (import_dir.VirtualAddress, nt_header); 667 data_dir = opt->DataDirectory;
661 imports = RVA_TO_PTR (import_dir.VirtualAddress, section, executable); 668 *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI);
662 669 }
663 for ( ; imports->Name; imports++) 670 /* MingW 3.12 has the required 64 bit structs, but in case older
664 { 671 versions don't, only check 64 bit exes if we know how. */
665 char * dllname = RVA_TO_PTR (imports->Name, section, executable); 672#ifdef IMAGE_NT_OPTIONAL_HDR64_MAGIC
666 673 else if (nt_header->OptionalHeader.Magic
667 /* The exact name of the cygwin dll has changed with 674 == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
668 various releases, but hopefully this will be reasonably 675 {
669 future proof. */ 676 IMAGE_OPTIONAL_HEADER64 *opt
670 if (strncmp (dllname, "cygwin", 6) == 0) 677 = (IMAGE_OPTIONAL_HEADER64*) &(nt_header->OptionalHeader);
671 { 678 data_dir = opt->DataDirectory;
672 *is_cygnus_app = TRUE; 679 *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI);
673 break; 680 }
674 } 681#endif
675 } 682 if (data_dir)
676 683 {
677 /* Check whether app is marked as a console or windowed (aka 684 /* Look for cygwin.dll in DLL import list. */
678 GUI) app. Accept Posix and OS2 subsytem apps as console 685 IMAGE_DATA_DIRECTORY import_dir =
679 apps. */ 686 data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT];
680 *is_gui_app = (nt_header->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI); 687 IMAGE_IMPORT_DESCRIPTOR * imports;
688 IMAGE_SECTION_HEADER * section;
689
690 section = rva_to_section (import_dir.VirtualAddress, nt_header);
691 imports = RVA_TO_PTR (import_dir.VirtualAddress, section,
692 executable);
693
694 for ( ; imports->Name; imports++)
695 {
696 char * dllname = RVA_TO_PTR (imports->Name, section,
697 executable);
698
699 /* The exact name of the cygwin dll has changed with
700 various releases, but hopefully this will be reasonably
701 future proof. */
702 if (strncmp (dllname, "cygwin", 6) == 0)
703 {
704 *is_cygnus_app = TRUE;
705 break;
706 }
707 }
708 }
681 } 709 }
682 } 710 }
683 711