motti@ocsmd.ocs.com (Motti Bazar) (01/22/90)
I'm developing a DOS shell that plays with Interrupt 21H. One function (4B - Exec) is a tough one to emulate. Is there anybody that knows about any public domain code to emulete this function ??? If there is interest, I'll post the answer. Thanks in advance ... Motti.
fredex@cg-atla.UUCP (Fred Smith) (01/23/90)
In article <844@ocsmd.ocs.com> motti@ocsmd.ocs.com (Motti Bazar) writes: >I'm developing a DOS shell that plays with Interrupt 21H. >One function (4B - Exec) is a tough one to emulate. Is there >anybody that knows about any public domain code to emulete this >function ??? If there is interest, I'll post the answer. >Thanks in advance ... Motti. I don't understand--Int 21 function 0x4B is a function of DOS, not the shell ( command.com) `As long as you have DOS you don't need to "emulate" function 4B. Function 4B is also kinda hard to use, since in many versions of DOS it trashes (almost) all the registers, including the stack pointer! Fred
bk0y+@andrew.cmu.edu (Brian Christopher Kircher) (01/23/90)
In article <8283@cg-atla.UUCP> fredex@cg-atla.UUCP (Fred Smith) writes: >In article <844@ocsmd.ocs.com> motti@ocsmd.ocs.com (Motti Bazar) writes: >>I'm developing a DOS shell that plays with Interrupt 21H. >>One function (4B - Exec) is a tough one to emulate. Is there >>anybody that knows about any public domain code to emulete this >>function ??? If there is interest, I'll post the answer. >>Thanks in advance ... Motti. > >I don't understand--Int 21 function 0x4B is a function of DOS, not >the shell ( command.com) `As long as you have DOS you don't need >to "emulate" function 4B. But Int 21 function 0x4B is part of command.com. Quoting IBM's DOS Technical Reference Manual under its description of the various parts of command.com: "A transient portion is loaded at the high end of memory. This is the command processor itself, containing ... a routine to load and execute external commands. This 'loader' is at the highest end of memory, and is invoked by the EXEC function call to load programs." This explains why calling EXEC to load another program from within a program causes DOS to reload command.com (in the case that the transient portion was wiped by the program's execution before the EXEC). As far as actually implementing 0x4B, I would try: (but have never done this before :-) 1) two calls to 0x48, one to allocate a block to copy the environment into and the other to allocate the remainder of free memory to load the program into. 2) copy the current environment into the block allocated for the environment. 3) a call to 0x26 to create a PSP in the program's memory block 4) change some of the values in the PSP (such as the environment segment at 0x2c of the PSP, etc.) 5) if the program is a .com, load it starting at offset 0x100 in the program's memory block 6) if the program is a .exe, interpret the EXE header (I have no clue as to how this should be done) and load the program 7) set up the program's stack and jump to the first instruction of the program. I can't think of much else that would need to be done, but I'm not guaranteeing that this is complete or accurate. :-) Good Luck... Brian Kircher
ralf@b.gp.cs.cmu.edu (Ralf Brown) (01/23/90)
In article <8ZiwoM600WB8QxSWwE@andrew.cmu.edu> bk0y+@andrew.cmu.edu (Brian Christopher Kircher) writes: }In article <8283@cg-atla.UUCP> fredex@cg-atla.UUCP (Fred Smith) writes: }>I don't understand--Int 21 function 0x4B is a function of DOS, not }>the shell ( command.com) `As long as you have DOS you don't need }>to "emulate" function 4B. } }But Int 21 function 0x4B is part of command.com. Quoting IBM's DOS }Technical Reference Manual under its description of the various parts }of command.com: } "A transient portion is loaded at the high end of memory. } This is the command processor itself, containing ... a } routine to load and execute external commands. This 'loader' } is at the highest end of memory, and is invoked by the EXEC } function call to load programs." This, however, is true ONLY of PC-DOS 2.x. MS-DOS 2.x and up, as well as PC-DOS 3.0 and up, contain the INT 21/AH=4Bh code in IBMDOS.COM/MSDOS.SYS. (the description is in fact not quite correct, since the PCDOS 2.x EXEC code is contained in a *second* transient portion of COMMAND.COM which is not loaded until EXEC is called) -- {backbone}!cs.cmu.edu!ralf ARPA: RALF@CS.CMU.EDU FIDO: Ralf Brown 1:129/46 BITnet: RALF%CS.CMU.EDU@CMUCCVMA AT&Tnet: (412)268-3053 (school) FAX: ask DISCLAIMER? | _How_to_Prove_It_ by Dana Angluin 24. by appeal to intuition: What's that?| Cloud-shaped drawings frequently help here.
pipkins@qmsseq.imagen.com (Jeff Pipkins) (01/24/90)
In article <844@ocsmd.ocs.com> motti@ocsmd.ocs.com (Motti Bazar) writes: >I'm developing a DOS shell that plays with Interrupt 21H. >One function (4B - Exec) is a tough one to emulate. Is there >anybody that knows about any public domain code to emulete this >function ??? If there is interest, I'll post the answer. Don't let it intimidate you; it's not as difficult as it may first appear. I've written such a function, but I'm unable to send it to you since it belongs to my employer now. But here are some hints: First, get a copy of the DOS technical reference guide. It documents the format of the .EXE header and tells how it is loaded. The MS-DOS encyclo- pedia is recommended and probably also has this info. There is an operating system called Wendin-DOS that comes with source code (for about $100) that contains an .EXE loader, but of course, that belongs to Wendin... BEST BET: I noticed several progams on SIMTEL that were replacements for the DOS EXE2BIN program. Such a program is almost identical to an .EXE loader. Hope this helps. -Jeff pipkins@imagen.com