aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2007-07-18 22:20:42 +0000
committerJason Rumney2007-07-18 22:20:42 +0000
commit2b6e2f4db6ab7e1bc18962ae50c9c539f909c741 (patch)
tree4ae53e3c329ea4feb131825381f72d7edac037ef /src
parentebdf47ca11d183e63f72d981ca45b29ee0af16f5 (diff)
downloademacs-2b6e2f4db6ab7e1bc18962ae50c9c539f909c741.tar.gz
emacs-2b6e2f4db6ab7e1bc18962ae50c9c539f909c741.zip
(w32_executable_type): Handle 64 bit executables.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/w32proc.c75
2 files changed, 52 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c5d7ac769ba..af13ba0f303 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
12007-07-18 Jason Rumney <jasonr@gnu.org>
2
3 * w32proc.c (w32_executable_type): Handle 64 bit executables.
4
12007-07-16 Juanma Barranquero <lekktu@gmail.com> 52007-07-16 Juanma Barranquero <lekktu@gmail.com>
2 6
3 * coding.c (Ffind_operation_coding_system): 7 * coding.c (Ffind_operation_coding_system):
diff --git a/src/w32proc.c b/src/w32proc.c
index 2120a51fb89..7d1717792ab 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -650,33 +650,54 @@ w32_executable_type (char * filename, int * is_dos_app, int * is_cygnus_app, int
650 } 650 }
651 else if (nt_header->Signature == IMAGE_NT_SIGNATURE) 651 else if (nt_header->Signature == IMAGE_NT_SIGNATURE)
652 { 652 {
653 /* Look for cygwin.dll in DLL import list. */ 653 IMAGE_DATA_DIRECTORY *data_dir = NULL;
654 IMAGE_DATA_DIRECTORY import_dir = 654 if (nt_header->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
655 nt_header->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]; 655 {
656 IMAGE_IMPORT_DESCRIPTOR * imports; 656 /* Ensure we are using the 32 bit structure. */
657 IMAGE_SECTION_HEADER * section; 657 IMAGE_OPTIONAL_HEADER32 *opt
658 658 = (IMAGE_OPTIONAL_HEADER32*) &(nt_header->OptionalHeader);
659 section = rva_to_section (import_dir.VirtualAddress, nt_header); 659 data_dir = opt->DataDirectory;
660 imports = RVA_TO_PTR (import_dir.VirtualAddress, section, executable); 660 *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI);
661 661 }
662 for ( ; imports->Name; imports++) 662 /* MingW 3.12 has the required 64 bit structs, but in case older
663 { 663 versions don't, only check 64 bit exes if we know how. */
664 char * dllname = RVA_TO_PTR (imports->Name, section, executable); 664#ifdef IMAGE_NT_OPTIONAL_HDR64_MAGIC
665 665 else if (nt_header->OptionalHeader.Magic
666 /* The exact name of the cygwin dll has changed with 666 == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
667 various releases, but hopefully this will be reasonably 667 {
668 future proof. */ 668 IMAGE_OPTIONAL_HEADER64 *opt
669 if (strncmp (dllname, "cygwin", 6) == 0) 669 = (IMAGE_OPTIONAL_HEADER64*) &(nt_header->OptionalHeader);
670 { 670 data_dir = opt->DataDirectory;
671 *is_cygnus_app = TRUE; 671 *is_gui_app = (opt->Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI);
672 break; 672 }
673 } 673#endif
674 } 674 if (data_dir)
675 675 {
676 /* Check whether app is marked as a console or windowed (aka 676 /* Look for cygwin.dll in DLL import list. */
677 GUI) app. Accept Posix and OS2 subsytem apps as console 677 IMAGE_DATA_DIRECTORY import_dir =
678 apps. */ 678 data_dir[IMAGE_DIRECTORY_ENTRY_IMPORT];
679 *is_gui_app = (nt_header->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_GUI); 679 IMAGE_IMPORT_DESCRIPTOR * imports;
680 IMAGE_SECTION_HEADER * section;
681
682 section = rva_to_section (import_dir.VirtualAddress, nt_header);
683 imports = RVA_TO_PTR (import_dir.VirtualAddress, section,
684 executable);
685
686 for ( ; imports->Name; imports++)
687 {
688 char * dllname = RVA_TO_PTR (imports->Name, section,
689 executable);
690
691 /* The exact name of the cygwin dll has changed with
692 various releases, but hopefully this will be reasonably
693 future proof. */
694 if (strncmp (dllname, "cygwin", 6) == 0)
695 {
696 *is_cygnus_app = TRUE;
697 break;
698 }
699 }
700 }
680 } 701 }
681 } 702 }
682 703