tags:

views:

1227

answers:

6

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, as I cannot find this on the list of machine types that these 2 bytes are supposed to represent.

Can anyone clarify?

A: 

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

Dos executable

abababa22
+2  A: 

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.

Daniel Persson
A: 

Check out this

Nick D
+2  A: 

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.

anon
+4  A: 

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:

Michael Burr
For some historic info on the origins of the MZ header (initials of Mark Zbikowski, an MS-DOS developer), you may want to check out wikipedia: http://en.wikipedia.org/wiki/DOS_executable
none
A: 

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.

Michael
If it doesn't have a dos stub, it's not a valid PE/COFF as there's a field in the DOS header that tells where the PE header starts.
Rob K