TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ROBERT HORNE
from: JONATHAN DE BOYNE POLLARD
date: 1998-01-02 02:01:00
subject: EXE files

 RH> Can anybody tell me how to tell where the end of an EXE or COM file
 RH> is?  
There is no structure at all to a "COM format" DOS executable.  It is a raw 
memory image of the program, starting at offset 0x0100.  The other DOS format 
is the so-called "MZ" format, named after its signature in the first two 
bytes of the file, which is in turn derived from the initials of a programmer 
at Microsoft many years ago.  The structure of an MZ-format executable is 
widely documented.  Check your nearest files site for one of the many text 
files on the subject, or pick up any decent DOS programming reference book.  
Notice that the format of a file is not determined by the file's actual 
extension.  A file with the extension ".COM" can quite legally be in "MZ" 
format, and a file with the extension ".EXE" can quite legally be in "COM" 
format.  DOS reads the first two bytes of the file and checks for the 
signature word to distinguish between the two when loading a program.
Incidentally, if your executable has been compressed with PKLite, Diet, or 
whatever, then reading raw data from your executable is possible, but to a 
large extent completely impractical, because it involves knowing the 
particular compression algorithm used.  Programs that read from and write to 
their own executables are the reason why the instructions for PKLite, Diet, 
and others contain so many warnings about "certain programs" that will stop 
working if they are compressed.  The best advice that I can give, therefore, 
is not to do what you are trying to do.  There is, after all, nothing wrong 
with putting data in a separate data file, rather than embedding it in the 
executable itself.
 ¯ JdeBP ®
--- FleetStreet 1.19 NR
---------------
* Origin: JdeBP's point, using Squish (2:440/4.3)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.