;***********************************************************************
; Author : James Bischoff
; Purpose : Display the program path and command tail of DOS
; load & execute function calls prior to executing them.
; Date : 10-16-91 03:45am
; Version : 2.0
;***********************************************************************
CodeSeg SEGMENT
ASSUME cs:CodeSeg
ORG 100h ;COM program, use EXE2BIN
Start: jmp SetUp ;Code between Start and
;SetUp stays resident
;***********************************************************************
; Constants
;***********************************************************************
cr equ 0Dh ;Carriage Return
lf equ 0Ah ;Line Feed
ProgName db cr,lf,'SHOWEXEC Version 2.0$'
Author db cr,lf,'By : James Bischoff$'
Notice db cr,lf,'Copyright 1991 James Bischoff$'
Installed db cr,lf,cr,lf,'Interrupt 21h taken over!',cr,lf,'$'
Message db 'Press any key to continue ...',cr,lf
MsgSize equ 31
MsgHandle equ 2
;*** DOS Interrupt ***
DOS equ 21h ;DOS Interrupt
DispStr equ 09h ;Display string
GetVector equ 35h ;Get Interrupt Vector
WrDev equ 40h ;Write file or device
LoadExec equ 4B00h ;Load & Execute a program
;*** Video Interrupt ***
Video equ 10h ;Video Interrupt
DispChar equ 0Eh ;Display
;*** Keyboard Interrupt ***
KeyBoard equ 16h ;Keyboard Interrupt
GetChar equ 00h ;Get Character & Scan Code
;***********************************************************************
; The Interrupt Handler
;***********************************************************************
Org21 label dword ;Origirnal int 21h address
Offset21 dw 0 ;Offset (Low byte)
Segment21 dw 0 ;Segment (High byte)
NewtInt21: cmp ax,LoadExec ;Is this a LOAD and EXEC?
jz ShowExec ;Yes - Display information
jmp cs:[Org21] ;No - Go to original int 21h
ShowExec: push ds ;Save registers
push es
push si
push dx
push cx
push bx
push ax
cld ;Clear direction flag
;String instrucions (lodsb)
;increment from low to
;high memory
mov ah,DispChar ;Display a character
mov al,cr ;CR
int Video ;Do it
mov ah,DispChar ;Display a character
mov al,lf ;LF
int Video ;Do it
mov ah,DispChar ;Display a character
mov al,'[' ;"["
int Video ;Do it
mov si,dx ;Load offset of program path
;into SI
;Note : On call to int 21h
;DS:DX = program path
ShowProgPath: lodsb ;Load byte from DS:SI into AL
;and increment SI
or al,al ;Test if 0 (end of program path)
jz SetUpCmdLine ;Yes - Goto cmd line display
mov ah,DispChar ;Display a character
int Video ;Do it
loop ShowProgPath ;Show next character
SetUpCmdLine: lds si,es:[bx+2] ;Load offset:segment address
;of bx+2:bx+4 into DS:SI
;Note : On call to int 21h
;ES:BX = parameter block
;bx+2 = offset command line
;bx+4 = segment command line
;First byte in command line
;is the command line length
lodsb ;Load byte from DS:SI into AL
;and increment SI
or al,al ;Test if 0 (command line length)
jz NoCmdLine ;Yes - Skip cmd line display
xor ah,ah ;Clear AH
mov cx,ax ;Load CX with loop count
ShowCmdLine: lodsb ;Load byte from DS:SI into AL
;and increment SI
mov ah,DispChar ;Display a character
int Video ;Do it
loop ShowCmdLine ;Show next character
NoCmdLine: mov ah,DispChar ;Display a character
mov al,']' ;"]"
int Video ;Do it
mov ah,DispChar ;Display a character
mov al,cr ;CR
int Video ;Do it
mov ah,DispChar ;Display a character
mov al,lf ;LF
int Video ;Do it
push cs ;Prepare to display string
pop ds
mov dx,offset Message ;Use write device with
mov bx,MsgHandle ;stderr handle so message
mov cx,MsgSize ;displays through pipes
mov ah,WrDev ;Write file handle
int DOS ;Do it
mov ah,GetChar ;Get keyboard input
int KeyBoard ;Do it
pop ax ;Restore registers
pop bx
pop cx
pop dx
pop si
pop es
pop ds
jmp cs:[Org21] ;Go to original int 21h
;***********************************************************************
; The Interrupt Handler Loader
;***********************************************************************
SetUp: mov dx,offset ProgName
mov ah,DispStr ;Display string
int DOS ;Do it
mov dx,offset Author
mov ah,DispStr ;Display string
int DOS ;Do it
mov dx,offset Notice
mov ah,DispStr ;Display string
int DOS ;Do it
mov ah,GetVector ;Put interrupt address in ES:BX
mov al,21h ;For interrupt 21h
int DOS ;Do it
mov [Offset21],bx ;Save address of original
mov [Segment21],es ;interrupt 21h in [Org21]
mov ax,0000h ;Segment of vector is 0000h
mov es,ax ;Segment of vector to ES
mov bx,4*21h ;Offset of int 21 to BX
;Note : Each interrupt vector
; is 4 bytes
lea dx,NewtInt21 ;Offset of NewInt21 to DX
mov ax,cs ;Segment of NewInt21 to AX
cli ;Disable interrupts
mov es:[bx],dx ;Offset of NewInt21 to vector
mov es:[bx+2],ax ;Segment of NewInt21 to vector
sti ;Re-enable interrupts
mov dx,offset Installed
mov ah,DispStr ;Display string
int DOS ;Do it
lea dx,SetUp ;Offset of last byte to remain
;resident
int 27h ;Terminate and stay resident
CodeSeg ENDS
END Start |