Updated: Cygwin 1.1.5-7

DJ Delorie dj@delorie.com
Sun Nov 12 13:54:00 GMT 2000

> >How can we read this `magic number' ?
> Huh?  Use 'read()', I guess.  Is this a trick question?

It is if you don't know where or what to read.

Here are some details:

open the file in binary mode.

Read the first two characters.

If they are "MZ" or "ZM" then you have an MS-DOS executable.

One of the fields in the DOS header has a pointer to a *second* magic
number.  If this second magic number is "PE\0\0" then you have a
32-bit Windows executable.

If you need more information than that, look up Ralf Brown's interrupt
list, which details all the executable header types.

Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

More information about the Cygwin mailing list