Fog Creek Software
Discussion Board




MZ?

Dear Joel,

I can't find a useful description of this from any source I try.
Since you worked at Microsoft I thought you might know
the answer to this question:

How does the DOS header work in the PE file format?

Also, if I want to include a message like 'This is not a DOS
program, please run under Windows', what tutorials are
there for me to follow?

Many Thanks,
Ali

PS
The intent is to write a program for Win95 (Chinese(simple))
in machine code

Ali
Saturday, March 06, 2004

When you link your windows program, add "/stub:foo.com" to the command line passed to link, where foo.com is an MS-DOS based program. In DOS foo.com will run and in Windows your main EXE will run.

Joel Spolsky
Fog Creek Software
Saturday, March 06, 2004

Many Thanks.
If I want to actually find the machine code byte
format of the DOS header part, where do I look?
It is not clearly explained in the Intel standard
document for the PE format.

Ali
Saturday, March 06, 2004

You've got to track down an old, out of print book called the MS-DOS Encyclopedia, put out by Microsoft Press. (Great book, that was.)

Joel Spolsky
Fog Creek Software
Saturday, March 06, 2004

Thanks Again

Ali
Saturday, March 06, 2004

Maybe you can find it on this site:

http://www.wotsit.org/

Has descriptions of all existing file formats.

Alex.ro
Sunday, March 07, 2004

I have been using the files on wotsit.
Thanks.

Ali
Sunday, March 07, 2004

Trivia: The file header is "MZ" after the initials of Mark Zbikowski, one of the MS-DOS developers.

The magic number for Java class files is 3405691582. Can anyone guess why?

John Topley (www.johntopley.com)
Sunday, March 07, 2004

Well, 3405691582 is CAFEBABE in hex. The "cafe" part makes sense, but I'm not sure who the "babe" would be.

John C.
Sunday, March 07, 2004

Google shall set you free....

This reply is the actual answer to the question, supplied by Patrick Naughton, one of the original members of the team that eventually produced Java. I quoted Patrick in my JavaWorld article.

Subject: Re: Why CAFEBABE?
Date: Sun, 26 May 1996 22:12:58 -0700
From: Patrick Naughton <naughton@starwave.com>
To: comp.lang.java
Bill Venners wrote:

The first 4 bytes of every Java class file has the magic value 0xCAFEBABE. I am curious. Does anyone know how this value was chosen? Does anyone who doesn't know want to venture a guess?

Strangely enough the magic number for .class files was chosen long before the name Java was ever uttered in reference to this language. We were looking for something fun, unique and easy to remember. 0xcafebabe was better than the second runner-up, 0xdeadbabe. :-)

It is only a coincidence that the oblique reference to the cute barristas at Peet's Coffee was foreshadowing for the name Java.

Philo
Sunday, March 07, 2004

Gee, I always thought that it got the name from a sleepy programmer telling his computer to "make java"...and getting annoyed with the fact that nothing happened.  :)

Aaron F Stanton
Sunday, March 07, 2004

Hi,

also check out this site :

http://www.nondot.org/sabre/os/articles/ExecutableFileFormats/

It has a lot of information about various executable file formats (MZ,EXE,PE,LE,LX and UNIX a.out and ELF)


Jeroen

Jeroen Jacobs
Thursday, March 11, 2004

There's a good online book (in progress) about writing windows programs in Asm here:

http://webster.cs.ucr.edu/Page_win32/WindowsAsmPgm/html/WinAsmPgm.html

Ged Byrne
Friday, March 12, 2004

Victory is mine!

http://www.microsoft.com
/hwdev/download/hardware/PECOFF.doc

Ali
Saturday, March 20, 2004

*  Recent Topics

*  Fog Creek Home