[comp.sys.ibm.pc] MS-DOS Load and Execute function

ian@siesoft (ian) (11/09/88)

We are currently in the final stages of writing an MS-DOS
redirector for a networking product.  This is straightforward for
functions such as file I/O, fetching file attributes and getting
directory entries (find first/find next).  However, we need to be
able to store '.exe' files on a remote drive and load and execute
them directly.  We appreciate that this is more complex than
intercepting the appropriate DOS function since DOS calls itself
internally when performing a load and execute function, avoiding
using the int 21h interface, because DOS is not re-entrant.  This
means that we must rewrite all the functions associated with
loading, executing and exiting, i.e.

INT 21h function 00h		Terminate normally
INT 21h function 31h		Terminate and Stay Resident
INT 21h function 4Bh		Load or Execute (EXEC)
	subfunctions		0 load and execute program
				2 load (internal) but do not execute
				3 load overlay; do not create PSP
INT 21h function 4Ch		Quit with Exit Code
INT 21h function 4Dh		Get Exit code of Subprogram 
INT 20h				Same as INT 21 function 00
INT 27h				Similar to INT 21 function 31 

The most complex of these are the int 21 function 4B calls.  The
exact sequence of events which takes place is undocumented by
Microsoft.  I assume it is something like allocate a block of
memory, open and read file, create program segment prefix, create
environment block, fixup program addresses, and pass control to
program.  The function 4C call has the reverse effect, i.e. it must
release the memory and pass a return code back to the calling
program.

If anybody out there has any detailed knowledge of these
functions, or knows where we could purchase source code for a
loader, I would be very grateful for the information.  The best
solution, as far as we are concerned, would be to obtain the source
code of an existing loader, but otherwise exact details of what
needs to be done to implement the above functions would be
appreciated.

Thanks in advance.

Please reply direct by email, post or telephone.

----------------------------------------------------------------------------
Ian Chapman                           Telephone +44 734 443042 (Direct line)
Siemens Limited                                 +44 734 691994 (Switchboard)
Systems Development Group              
Woodley House                         Fax       +44 734 698847
65-73 Crockhamwell Road               Telex      846053 SIESOF G 
Woodley, Reading 
Berkshire RG5 3JP                     E-Mail    ian@siesoft.uucp 
Great Britain                                ...ukc!siesoft!ian 
----------------------------------------------------------------------------