Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!iuvax!bsu-cs!dhesi From: dhesi@bsu-cs.UUCP (Rahul Dhesi) Newsgroups: comp.sys.ibm.pc Subject: Re: unexpected "TSR's" Message-ID: <1254@bsu-cs.UUCP> Date: Sat, 10-Oct-87 15:12:31 EDT Article-I.D.: bsu-cs.1254 Posted: Sat Oct 10 15:12:31 1987 Date-Received: Mon, 12-Oct-87 07:20:24 EDT References: <307@gvgspd.UUCP> Reply-To: dhesi@bsu-cs.UUCP (Rahul Dhesi) Organization: CS Dept, Ball St U, Muncie, Indiana Lines: 40 Summary: not TSR; poor technique In article <307@gvgspd.UUCP> mrk@gvgspd.UUCP (Michael R. Kesti) writes: >Since I have begun to use Bob Frolick's AT program, I have discovered that >some programs (notably Procomm and TurboC) appear to attach themselves to >DOS in TSR fashion. Especially, they reassign the vector for interrupt 16 >(keyboard services) in the course of their execution, and do *NOT* restore >this vector upon termination. I doubt very much that Turbo C traps INT 16h without restoring it. That would cause chaos, and Turco C hasn't caused chaos on my system so far. >This causes failure of AT, as it compares the >code pointed to by this vector to determine whether it is already installed. >When this vector is changed, it fails to recognize itself, and re-installs >itself, losing any previously scheduled events! This is purely AT's fault. A program that traps a keyboard interrupt must always be prepared to have other programs trap it too. Programs that claim exclusive use of vectors such as the keyboard software interrupt are using a bad programming technique. (Aside: Prokey used to use this bad programming technique and would therefore not work with SideKick. David Rose, the author, refused to fix it. One Sunday morning, in a fit of exasperation, Phillippe Kahn declared he would write his own keyboard enhancer. The rest is history.) The correct technique for a terminate-and-stay-resident program to avoid loading itself twice is to trap an unused interrupt vector (or MS-DOS function call), and install a service routine that returns a known value. Then, when it is loaded, the TSR program first calls this vector and examines the return value. Return values for unused interrupt vectors and MS-DOS calls are usually well-defined though not always well-documented. If the value returned is that expected to be returned by an already-installed TSR program, the newly-loaded program prints a message and gracefully exits. For safety's sake, allow the user to change the value of the unused vector used in case other software happens to use the value you choose. -- Rahul Dhesi UUCP: !{iuvax,pur-ee,uunet}!bsu-cs!dhesi