Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!apple!altos!gumby!jesse From: jesse@gumby.Altos.COM (Jesse Chisholm AAC-RjesseD) Newsgroups: comp.os.msdos.programmer Subject: Re: How can a TSR detect if it has been installed? Message-ID: <4944@gumby.Altos.COM> Date: 23 Jun 91 19:22:28 GMT References: <1991Jun23.145337.20537@netcom.COM> Organization: Altos Computer Systems, San Jose, CA Lines: 31 resnicks@netcom.COM (Steve Resnick) writes: | In article <0094A83A.9AE8E1A0@MAPLE.CIRCA.UFL.EDU> sorrow@oak.circa.ufl.edu writes: | >I have written a TSR that takes over the command line input for INT21H, in | >other words an INT21H replacement. | > | >How can it prevent itself from being re-installed? I know programs such as | >NORTON SI will show you who "owns" an interrupt, and my program comes up | >as the owner. 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. | The way I have handled this, when using an interrupt vector which may | already be used by some other utility/tsr/system function is to | grab a few bytes in the CS of the ISR as a "signature", then when installing | my TSR, look at that segment address and the specific offset. If my signature | is there, I know my TSR has been installed, otherwise it's not and I can | install it.... Many TSRs chain their interrupt and so it might be installed but no longer be the first in the chain. A way of checking for the signature you mention that gets around this is to check at that offset for ALL segments from 0000 up to your current CS. when you find the signature if the segment is not equal to the current CS, then your TSR has been installed before and is still in memory. If the first time you find the signature is in your current CS segment, then your TSR has not yet been installed. Go for it. -jesse -- /* jesse@altos86.altos.com jesse@gumby.altos.com 1-408-432-6200 */ main(){int i;for(i=6;--i;){printf("%c",97^((i>4)*43)|((i&2)?18:(i<5) <<2));}printf(" ");for(i=9;--i;){printf("%c",((104^(i>7)*43^((i==5)* 24))|(((i&1)&(i<6))*3)|(i==6)|((i<4)*4))^((i==1)*2));}printf("\n");}