#pragma inline

#include "dos.h"

struct INTERRUPT

      {

            unsigned bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,fl;

      };

void interrupt dispopen(struct INTERRUPT);

void interrupt (*prev)();

char far *vdu=(char far*)0xb8000000l;

char far *fname;

 

main()

{

//AIM : to display name of every file that is open when the TSR is active

      unsigned long far *int21ptr;

      int21ptr=(unsigned long far*)(0x21*4);

      prev=(void (interrupt far*)())*int21ptr;

      *int21ptr=(unsigned long)dispopen;

      keep(0,1000);

      return 0;

}

 

void interrupt dispopen(struct INTERRUPT r)

{

      void writestr(char far*);

      if  ((_AH==61)||(_AH==62)|(_AH==75))

            {

                  fname=(char far*)MK_FP(r.ds,r.dx);

                  writestr(fname);

            }

      asm pop bp;

      asm pop di;

      asm pop si;

      asm pop ds;

      asm pop es;

      asm pop dx;

      asm pop cx;

      asm pop bx;

      asm pop ax;

      asm jmp cs:_prev;

}

 

void writestr(char far *fname)

{

      int row,col,i;

      void writechr(char,int,int,int);

      row=col=10;

      for(i=0;(fname[i]);i++)

            {

                  writechr(fname[i],row,col,240);

                  fname++;

                  col++;

            }

 

}

 

void writechr(char fchar,int row,int col,int attr)

{

      *(vdu+(row*160)+(col*2))=fchar;

      *(vdu+(row*160)+(col*2)+1)=attr;

}