What is the MZ signature in a PE file for?

前端 未结 6 1996
孤独总比滥情好
孤独总比滥情好 2021-02-06 03:25

I\'m working on a program that will parse a PE object for various pieces of information.

Reading the specifications though, I cannot find out why the MZ bytes are there,

相关标签:
6条回答
  • 2021-02-06 03:56

    Thety are the initials of a Microsoft programmer and identify the file as a DOS executable see http://en.wikipedia.org/wiki/DOS_executable for a bit more info.

    0 讨论(0)
  • 2021-02-06 03:57

    Mark Zbikowski put his initials into the original MS-DOS exe format. This signature was necessary to distinguish .EXE files from the much simpler .COM format on DOS.

    Every PE file also contains a 16-bit DOS program and thus starts with this .EXE header. This DOS program would typically print out "This program requires Microsoft Windows" or similar. I don't know if modern compilers still produce the DOS stub, but the PE standard still says a PE starts with a 16-bit EXE header.

    0 讨论(0)
  • 2021-02-06 04:00

    As I see it, by reading the wikipedia article and Iczelion's PE Tutorial, it is there just to keep up compatibility and enable dos or HX DOS Extender to execute certain code next to the MZ header.

    From devsource one can find more information like MZ stands for Mark Zbikowski, one of MS-DOS's developers. And how the operating system behaves and handles the data from the MZ header.

    0 讨论(0)
  • 2021-02-06 04:03

    It's the "magic number" of dos executable. Legacy stuff you can ignore.

    Dos executable

    0 讨论(0)
  • 2021-02-06 04:12

    The MZ signature is a signature used by the MS-DOS relocatable 16-bit EXE format.

    The reason a PE binary contains an MZ header is for backwards compatibility. If the executable is run on a DOS-based system it will run the MZ version (which is nearly always just stub that says you need to run the program on a Win32 system).

    Of course this is not as useful nowadays as it was back when the world was transitioning from DOS to whatever would come after it.

    Back then there were a few programs that would actually bind together a DOS version and a Win32 version in a single binary.

    And as with most things dealing with Windows history, Raymond Chen has some interesting articles about this subject:

    • Why does a corrupted binary sometimes result in "Program too big to fit in memory"?
    • What's the difference between the COM and EXE extensions?
    0 讨论(0)
  • 2021-02-06 04:13

    In the early days of Microsoft® Windows, The Windows™ 1.x, 2.x and 3.xx OS not only existed in the same volumes as Microsoft® DOS, but also ran on top of an MS-DOS OS. It was not only possible, but very probable that a user might attempt to run some of the Windows® programs under DOS. Therefore, Microsoft® programmers made sure all Windows® programs would have a simple 16-bit DOS program placed at the front of each Windows executable that would alert the user if they were attempting to run a Windows® program under DOS. This is all the DOS "Stub" program does. resource: http://thestarman.pcministry.com/asm/debug/DOSstub.htm

    0 讨论(0)
提交回复
热议问题