[comp.os.msdos.programmer] Intercepting DOS opens?

ted@usasoc.soc.mil (Ted Nolan) (09/12/90)

I've got a braindead DOS application that insists on opening and writing
to files it's not really going to change.  I can't change the application,
but I want to put the data files in question on a PC-NFS network drive and
make them read-only.

My initial thought (well OK, maybe not my inital thought, but..) was to
run the application from another program with intercepts DOS int 21h,
traps all the open calls for these particular files, and saves the file
handles.  Then when write requests go through int 21h, I could make writes
to these handles appear to work, but in fact do nothing.

There's a program called intercep in the Simtel20 archives that almost
fills the bill.  Modifying it, I can easily examine every int 21h call
before it goes through.  The catch is I need to examine open calls both
before and AFTER they go through (so I can see if it was successful and
snarf the file handle).  Does anyone know how to do this?  (Preferably
in Turbo C).

Also, if I do figure this out, when int21h is called, is it safe to
make the int to get the DOS pid, and will it be that of the process
that actually made the int 21h call (given that TSRs may be around)?  I
think I need the pid along with the file handle to uniquely qualify my
file references.

Also, is any of this at all reasonable, or am I ignoring a simple way
to do what I need?

				Thanks,

				Ted Nolan
				ted@usasoc.soc.mil