I have made some com files with debug which can be aggrevating and rewarding at the same time. My question is what is the actual difference between a com file and an executable. What i really need to know is the foramat of an EXE. Is there some info file on EXEs that i can download. I know that a exe must be somewhat like a jpeg or bmp in that certain info is stored at the beginning of the file. What is this info and why is it there. I assume its MS at work.

Any help appreciated.
:alright:
Posted on 2002-03-02 20:00:36 by titan
here's something you can read about the pe file:

http://msdn.microsoft.com/library/default.asp?url=/msdnmag/issues/02/02/PE/TOC.asp?frame=true

iczelion also has some pe file tutorials you can take a look at.
Posted on 2002-03-02 20:20:31 by smurf
I'm sure the previously posted links have answered you're question, but I think a concise answer might help anyone else following this thread.

The com file, as you probably know, is pretty much raw data. It's simple to load into memory and execute, but it's a legacy from a time when sharing memory with other proccesses was rare. Normally, a com file is loading by an OS and given free reign to available memory.

The exe file format from dos, is a bit more complicated. It contains a header with information about the files memory requirements, size, etc. It also contains a table of segment references that must be adjusted to point to where the program has been loaded into memory.

The PE file format, though straight forward once understood (and I'm still shaky with it) is a bit more complicated. First, it contains a dos executeable (the stub) which is usually a short program that informs the user that windows is required to run the program. This is followed by the PE header, import and export tables, section tables, and other things which Iczelion's tut can explain better than I.

If you plan on hand coding an exe with DEBUG, more power to you. Let me know if you get it accomplished. Sounds like quite a task.
Posted on 2002-03-02 22:37:14 by Canite
titan,

Dos COM and EXE files are different due to their respective tasks. A COM file is a memory image and the file holds no more than that. You will see a directive ORG 100h that tells the prog where to start in memory as the COM file is appended to the program segment prefix when its loaded. COM files are restricted to one segment so they can never be larger that 64k where an EXE file depending on the memory model use can be up near the limit of DOS memory.

A DOS EXE header is a lot more complicated, you can get a look at it by using an old microsoft utility called EXEHDR.EXE which will dump a lot of info for you.

A DOS COM file is much closer to a 32 bit PE file because both are written in one segment and both can contain code and data in the same segment, its just that a DOS COM file can be no larger than 64k where a 32 bit PE file can be over a gigabyte theoretically.

Regards,

hutch@movsd.com
Posted on 2002-03-03 02:09:32 by hutch--
Hello,
I am new to the board, but I do have some good references to file formats. www.wotsit.org is a very good collection of file format documentations. For dos exes you will want to search for MZ file format, The PE file format (32bit) is just an addition to the mz file format. After the MZ header their is a "pointer" to the PE header. The reason for this, incase you were wondering, is if the program is ran in dos you can run the "stub" program which can be as simple as a message saying "This program needs windows to run". Or it can be a complex dos program. But if the program is ran in windows, Windows just skips the MZ header and loads the windows program (PE). Hope this helps. Wotsit also has a com file format document. Jag
Posted on 2002-03-03 11:47:27 by Jag
Interesting enough if you rename a .exe to .com on Win2K it will still function.

Try to do that on plain DOS and hope you have a parachute, because it will crash :)
Posted on 2002-03-04 08:02:04 by dxantos
are you sure .com/.exe extensions matter on dos, dxantos? I recall
using a .com file to make sure my app launched before a .exe.
I also remember some v1r11 using this method...
Posted on 2002-03-04 10:54:24 by f0dder
command.com is exe file, you can rename a file even to bat file...it will still run :-] ...
Posted on 2002-03-05 16:35:50 by me8
I never found any problems in renaming dos EXE files to COM files in versions of DOS from 5.0 upwards to win98se DOS.

=========
command.com is exe file, you can rename a file even to bat file...it will still run :-]...
=========

Actually you could have a lot of fun here, getting command.com to read a binary file line by line as it normally processes batch files could give some "very interesting" results. :tongue:

Regards,

hutch@movsd.com
Posted on 2002-03-05 18:01:30 by hutch--
===
Actually you could have a lot of fun here, getting command.com to read a binary file line by line as it normally processes batch files could give some "very interesting" results.
===

I Know disassemble .exe file(Windows) but
How Can I disassemble command.com?
Posted on 2002-03-05 19:10:16 by muzidowa
I just remember vaguely from the past the name SOURCER 7 as being the best around for disassembling dos com and exe files.

Just make sure you are not doing anything naughty or Microsoft will be unhappy about you playing with their command interpreter.

Regards,

hutch@movsd.com
Posted on 2002-03-05 19:53:42 by hutch--