DOSferatu hat geschrieben:
(...Wenn normaler Befehl, dann Command.Com mit dem Befehl als Parameter ausführen...)
Internen COMMAND.COM-Befehl ausführen ohne eine neue Instanz von Command.Com zu starten:
RBIL->inter61c.zip->INTERRUP.K
--------l-2E---------------------------------
INT 2E U - DOS 2+ - PASS COMMAND TO COMMAND INTERPRETER FOR EXECUTION
DS:SI -> commandline to execute (see #02585)
Return: all registers except CS:IP destroyed
AX = status (4DOS v4.0)
0000h successful
FFFFh error before processing command (not enough memory, etc)
other error number returned by command
Notes: this call allows execution of arbitrary commands (including COMMAND.COM
internal commands) without loading another copy of COMMAND.COM
if COMMAND.COM is the user's command interpreter, the primary copy
executes the command; this allows the master environment to be
modified by issuing a "SET" command, but changes in the master
environment will not become effective until all programs descended
from the primary COMMAND.COM terminate
since COMMAND.COM processes the string as if typed from the keyboard,
the transient portion needs to be present, and the calling program
must ensure that sufficient memory to load the transient portion can
be allocated by DOS if necessary
results are unpredictable if invoked by a program run from a batch file
because this call is not reentrant and COMMAND.COM uses the same
internal variables when processing a batch file
hooked but ignored by 4DOS v3.0 COMMAND.COM replacement unless SHELL2E
has been loaded
the MS-DOS 5 Programmer's Reference calls this "Reload Transient"
Format of DOS commandline:
Offset Size Description (Table 02585)
00h BYTE length of command string, not counting trailing CR
01h var command string
N BYTE 0Dh (CR)
-----------------------------------------------------------------------------------
Hinweis: Das funktioniert auch mit allen Batch-Befehlen wie etwa ein: "call xy.bat"!
Wenn der Befehl ein Programm (also EXE oder COM) starten soll, also keine BAT, dann kann man auch den INT21h für "EXEC" (execute) benutzen. Funktion 4Bh.
Aus einer Anwendung heraus eine andere Child-Anwendung ausführen:
RBIL->inter61b.zip->INTERRUP.G
--------D-214B-------------------------------
INT 21 - DOS 2+ - "EXEC" - LOAD AND/OR EXECUTE PROGRAM
AH = 4Bh
AL = type of load
00h load and execute
01h load but do not execute
03h load overlay (see #01591)
04h load and execute in background (European MS-DOS 4.0 only)
"Exec & Go" (see also AH=80h)
DS:DX -> ASCIZ program name (must include extension)
ES:BX -> parameter block (see #01590,#01591,#01592)
CX = mode (subfunction 04h only)
0000h child placed in zombie mode after termination
0001h child's return code discarded on termination
Return: ......
----------------------------------------------------------------------------------------
Beispiel für einen "parameter block" im Code-Segment:
Code: Alles auswählen
;----------
PARBLOCK equ THIS WORD ; Parameter-Block für die EXEC-Funktion
DW 0 ; gleicher Environment-Block
DW OFFSET COMLINE ; Offset- und Segmentadresse der
DW SEG CODE ; Kommandozeile
DD 0 ; keine Daten in PSP #1
DD 0 ; keine Daten in PSP #2
COMLINE DB 80h dup (0) ; Kommandozeile
;----------
RETT_SS DW ?
RETT_SP DW ?
Anmerkungen:
a) Bevor die zweite Anwendung(child process) damit gestartet wird müssen die Register "SS" und "SP" in einen dafür reservierten Speicherbereich gerettet werden und nach dem Beenden der zweiten Anwendung wieder damit geladen werden.
b) Oft werden angehängte Parameter einer Anwendung einfach nur aus dem PSP ab Adresse 80h herausgelesen. Besser wäre es jedoch vorher die jeweilige Adresse des PSPs erstmal zu ermitteln bevor das geschieht, denn die zweite Anwendung bringt ja ggf. ihre eigene Kommandozeile im übergebenen Parameter-Block mit.
RBIL->inter61b.zip->INTERRUP.H
--------D-2162-------------------------------
INT 21 - DOS 3.0+ - GET CURRENT PSP ADDRESS
AH = 62h
Return: BX = segment of PSP for current process
Notes: this function does not use any of the DOS-internal stacks and may
thus be called at any time, even during another INT 21h call
the current PSP is not necessarily the caller's PSP
identical to the undocumented AH=51h
-----------------------------------------------
Dirk