Function 4Bh Load or Execute a Program (EXEC) entry AH 4Bh AL 00h load and execute program. A PSP is built for the program the ctrl-break and terminate addresses are set to the new PSP. *01h load but don't execute (note 1) *01h load but don't execute (internal, DOS 3.x & DESQview) *02h load but do not execute (internal, DOS 2.x only) 03h load overlay (do not create PSP, do not begin execution) DS:DX points to the ASCIIZ string with the drive, path, and filename to be loaded ES:BX points to a parameter block for the load (AL=00h) word segment address of environment string to be passed dword pointer to the command line to be placed at PSP+80h dword pointer to default Struct -FCB to be passed at PSP+5Ch dword pointer to default Struct -FCB to be passed at PSP+6Ch (*AL=01h) word segment of environment (0 = use current) dword pointer to command line dword pointer to Struct -FCB 1 dword pointer to Struct -FCB 2 dword will hold SS:SP on return dword will hold program entry point (CS:IP) on return (*AL=02h) word segment of environment (0 = use current) dword pointer to command line dword pointer to Struct -FCB 1 dword pointer to Struct -FCB 2 (AL=03h) word segment address where file will be loaded word relocation factor to be applied to the image return CF set error AX error code (1, 2, 8, 0Ah, 0Bh) note 1) If you make this call with AL=1 the program will be loaded as if you made the call with AL=0 except that the program will not be executed. Additionally, with AL=1 the stack segment and pointer along with the program's CS:IP entry point are returned to the program which made the 4B01h call. These values are put in the four words at ES:BX+0Eh. On entry to the call ES:BX points to the environment address, the command line and the two default Struct -FCBs. This form of EXEC is used by DEBUG.COM. 2) Application programs may invoke a secondary copy of the command processor (normally COMMAND.COM) by using the EXEC function. Your program may pass a DOS command as a parameter that the secondary command processor will execute as though it had been entered from the standard input device. The procedure is: A. Assure that adequate free memory (17k for 2.x and 3.0, 23k for 3.1 up) exists to contain the second copy of the command processor and the command it is to execute. This is accomplished by executing function call 4Ah to shrink memory allocated to that of your current requirements. Next, execute function call 48h with BX=0FFFFh. This returns the amount of memory availible. B. Build a parameter string for the secondary command processor in the form: 1 byte length of parameter string xx bytes parameter string 1 byte 0Dh (carriage return) For example, the assembly language statement below would build the string to cause execution of the command FOO.EXE: DB 19,"/C C:FOO",13 C. Use the EXEC function call (4Bh), function value 0 to cause execution of the secondary copy of the command processor. (The drive, directory, and name of the command processor can be gotten from the COMSPEC variable in the DOS environment passed to you at PSP+2Ch.) D. Remember to set offset 2 of the EXEC control block to point to the string built above. 3) All open files of a process are duplicated in the newly created process after an EXEC, except for files originally opened with the inheritance bit set to 1. 4) The environment is a copy of the original command processor's environment. Changes to the EXECed environment are not passed back to the original. The environment is followed by a copy of the DS:DX filename passed to the child process. A zero value will cause the child process to inherit the environment of the calling process. The segment address of the environment is placed at offset 2Ch of the PSP of the program being invoked. 5) This function uses the same resident part of COMMAND.COM, but makes a duplicate of the transient part. 6) How EXEC knows where to return to: Basically the vector for int\22 holds the terminate address for the current process. When a process gets started, the previous contents of int\22 get tucked away in the PSP for that process, then int\22 gets modified. So if Process A EXECs process B, while Process B is running, the vector for int\22 holds the address to return to in Process A, while the save location in Process B's PSP holds the address that process A will return to when *it* terminates. When Process B terminates by one of the usual legal means, the contents of int\22 are (surmising) shoved onto the stack, the old terminate vector contents are copied back to int\22 vector from Process B's PSP, then a RETF or equivalent is executed to return control to process A. 7) To load an overlay file with 4B: first, don't de-allocate the memory that the overlay will load into. With the other 4Bh functions, the opposite is true--you have to free the memory first, with function 4Ah. Second, the "segment address where the file will be loaded" (first item in the parameter block for sub-function 03) should be a paragraph boundary within your currently-allocated memory. Third, if the procedures within the overlay are FAR procs (while they execute, CS will be equal to the segment address of the overlay area), the relocation factor should be set to zero. On the other hand, if the CS register will be different from the overlay area's segment address, the relocation factor should be set to represent the difference. You determine where in memory the overlay file will load by using the segment address mentioned above. Overlay files are .EXEs (containing header, relocation table, and memory image). 8) When function 00h returns, all registers are changed, including the stack. You must resore SS, SP, and any other required registers.
file: /Techref/int/21f/4b.htm, 6KB, , updated: 2001/5/16 10:50, local time: 2024/11/9 07:47,
3.144.99.134:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://linistepper.com/Techref/int/21f/4b.htm"> int 21f 4b</A> |
Did you find what you needed? |