Category : Files from Magazines
Archive   : ISSUE-38.ZIP
Filename : 86WRLD38.FIG
{--------------------------- Exec ----------------------------}
{ execute 'Command' as if it was typed at the A> prompt }
{ requires Getenvironment function from Micro C. 32 }
{-------------------------------------------------------------}
FUNCTION Exec (Command : string128) : INTEGER;
CONST
SSSave : INTEGER = 0;
SPSave : INTEGER = 0;
RetAX : INTEGER = 0;
RetFlags : INTEGER = 0;
TYPE
ExecPacketRec = RECORD
EnvironmentSeg : INTEGER;
CommandPtr,
FCB1,
FCB2 : ^CHAR;
end; { ExecPacketRec }
VAR ComFile : String20;
ExecPack : ExecPacketRec;
begin
ComFile := GetEnvironment('COMSPEC')+chr(0);{ execute command.com }
IF (length(command) > 0) THEN { sending it this line }
Insert ('/c ',Command,1); { 'c' switch means 'do this' }
command[length(command)+1] := ^M;
ExecPack.EnvironmentSeg := $0000; { use parent's environment }
ExecPack.CommandPtr := Ptr(seg(Command),ofs(Command));
ExecPack.FCB1 := Ptr(0,0);
ExecPack.FCB2 := Ptr(0,0);
{ START OF MODIFIED AREA }
inline($06/$1E/$55/$9C/ { push es, ds, bp, flags }
$8C/$D0/$8E/$D8/ { mov ax,ss mov ds,ax (seg(ComFile)) }
$BA/ComFile/ { mov dx,offset ComFile[0] }
$01/$EA/$42/ { add dx,bp inc dx }
$8E/$C0/ { mov es,ax (seg(ExecPack)) }
$BB/ExecPack/ { mov bx,offset ExecPack }
$01/$EB/ { add bx,bp }
$B8/$00/$4B/ { mov ax,4B00h }
$2E/$8C/$16/SSSave/ { mov cs:[SSSave],ss <<-}
$2E/$89/$26/SPSave/ { mov cs:[SPSave],sp <<-}
$CD/$21/ { int 21h }
$2E/$8E/$16/SSSave/ { mov ss,cs:[SSSave] <<-}
$2E/$8B/$26/SPSave/ { mov sp,cs:[SPSave] <<-}
$2E/$A3/RetAX/ { mov cs:[RetAX],ax }
$9C/$58/ { pushf pop ax }
$2E/$A3/RetFlags/ { mov cs:[RetFlags],ax }
$9D/$5D/$1F/$07); { pop flags, bp, ds, es }
IF ((RetFlags and CARRY) = 0) THEN
Exec := 0
ELSE
Exec := RetAX;
{ END OF MODIFIED AREA }
end; { Exec }
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/