Fog Creek Software
Discussion Board


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,

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

Saturday, March 6, 2004

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

Joel Spolsky
Fog Creek Software
Saturday, March 6, 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.

Saturday, March 6, 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 6, 2004

Thanks Again

Saturday, March 6, 2004

Maybe you can find it on this site:

Has descriptions of all existing file formats.
Sunday, March 7, 2004

I have been using the files on wotsit.

Sunday, March 7, 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 (
Sunday, March 7, 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 7, 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 <>
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.

Sunday, March 7, 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 7, 2004


also check out this site :

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


Jeroen Jacobs
Thursday, March 11, 2004

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

Ged Byrne
Friday, March 12, 2004

Victory is mine!

Saturday, March 20, 2004

*  Recent Topics

*  Fog Creek Home