[comp.os.msdos.programmer] .EXE format, overlays, DOS fn 4B03h

peter@atlas.abccomp.oz.au (Peter Barker) (05/21/91)

We are writing an overlay manager, using DOS function 4B03h (load overlay).
We want to append some information to the overlay file so our program can
read it, but have it ignored by DOS function 4B03h (perhaps in a similar
way to that used by MicroSoft's CodeView). We originally assumed that the
DOS loader obtained all its information about the contents of the file 
being loaded from the header at the start of the .EXE file. In this case
we would be able to append information to the end of the file, and the loader
would ignore it, as it does with symbol information provided by the linker
for CodeView. Unfortunately this is not the case - the file does not load
correctly. Does anyone have any information about how symbolic information
is stored in the .EXE by linkers? We should then be able to use the same
method.
Thankyou,
-- 
Peter Barker               |   Internet   peter@atlas.abccomp.oz.au
TurboSoft Pty Ltd          |   JANET      peter%atlas.abccomp.oz.au@uk.ac.ukc
248 Johnston St, Annandale |   UUCP       uunet!munnari!atlas.abccomp.oz!peter
NSW 2038    Australia      |  Telephone   +(612) 552 1266

byang@wiliki.eng.hawaii.edu (Bojiang Yang) (05/24/91)

In article <1991May21.044539.7291@atlas.abccomp.oz.au> peter@atlas.abccomp.oz.au (Peter Barker) writes:
>We are writing an overlay manager, using DOS function 4B03h (load overlay).
>We want to append some information to the overlay file so our program can
>read it, but have it ignored by DOS function 4B03h (perhaps in a similar
>way to that used by MicroSoft's CodeView). We originally assumed that the
>DOS loader obtained all its information about the contents of the file 
>being loaded from the header at the start of the .EXE file. In this case
>we would be able to append information to the end of the file, and the loader
>would ignore it, as it does with symbol information provided by the linker
>for CodeView. Unfortunately this is not the case

Are you sure the symbolic information for debugging are stored at the end
of the .EXE file, and it's ignored by function 4B03? 

If the answer is yes, I bet the first few bytes of this symbolic information
are some kind of signature, such as a string saying "Symbolic Info version xx".
The signature tells DOS that the following data is for debugging only and 
should be ignored by function 4B03.

So, you can compile a program with one of Microsoft's compilers with debugging
option turned on, get the first 256 or 512 bytes of the symbolic information
from the .EXE file (I guess no one makes the signature longer than 512 bytes), 
the put these 256 or 512 bytes in front of the information you want to append
to the .EXE file you are building, so your .EXE file looks something 
like this:

  [.EXE header]
  [regular .EXE file stuff]
  [1st 256 or 512 bytes of symbolic info]   
  [your info here]

This way, you might be able to fool DOS into thinking that the stuff at the
end of the file is valid symbolic info and should be ignored.  

Of course, my all assumptions in paragraph 2 got to be right for this shit
to work, and even if it does, you only know the know-how, 
but not the know-why.