Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!pshuang From: pshuang@athena.mit.edu (Ping-Shun Huang) Newsgroups: comp.os.msdos.programmer Subject: Re: How can a TSR detect if it has been installed? Message-ID: Date: 23 Jun 91 20:44:12 GMT References: <0094A83A.9AE8E1A0@MAPLE.CIRCA.UFL.EDU> Sender: news@athena.mit.edu (News system) Organization: Massachusetts Institute of Technology Lines: 35 In-Reply-To: sorrow@oak.circa.ufl.edu's message of 22 Jun 91 20:57:01 GMT In article <0094A83A.9AE8E1A0@MAPLE.CIRCA.UFL.EDU> sorrow@oak.circa.ufl.edu writes: > If there was a way to see if the owner was NOT DOS (i.e. another > program, such as a TSR, owned it) and to not install itself in that > case, I would like to know. I think there are two fairly common ways to do it. (1) Grab a completely unused interrupt/service and have your TSR return identification codes when that interrupt/service is called: e.g. Interrupt $21, AX=$FEED is probably unused, your TSR could grab it and return non-trivial data in the registers, BX=$DEAF and CX=$BEAD and DX=$FEED, the combination of which is unlikely to be accidentally duplicated by another program. Your TSR's installation routine can then check before continuing. Problem with this method: potential (although darn unlikely) conflicts with other TSR's if by chance two programmer decide on the same interrupt/service and ID codes. (2) In your program, make sure somehow that near your ISR (interrupt service routine) you place some identifying text string. This is not trivial to do, except in assembler, because your compiler is permitted to move things like constant strings from one place to another, so having the string adjacent to the routine in your source code does not guarantee anything. If you can do this, the installation routine would need to do a search on memory locations near to where the interrupt points. Problem: if another program hooks the interrupt between the previous installation of the TSR and now, you're scrod; in this case, if someone loads CED after your INT21H program, the pointer now points into CED code and not yours, and you have no easy way of tracing back the interrupt chain since you don't know for sure where CED stored the old copy of the Int $21 pointer. -- Above text where applicable is (c) Copyleft 1991, all rights deserved by: UNIX:/etc/ping instantiated (Ping Huang) [INTERNET: pshuang@athena.mit.edu]