dragheb@isis.UUCP (Darius "OPRDRT" Ragheb) (01/12/87)
I have noticed that out of the many memory resident programs out in the market, only one checks to see that it is already loaded (i.e. will not install itself more than once): SideKick. I am in need of the knowledge on how they do that...does anyone have a working method for this? Thanks, Dart -- Functionality, Efficiency, Luxury. isis!dragheb | dragheb@isis.cs.du.edu
mmm@nbires.UUCP (Michelle Melvin) (01/15/87)
in order to check to see if you are already loaded insert a string in your program that is likely to be unique like 'RES_PROG'. In the byte imediately following the string stick a status flag. Set the flag once you are running. This way, when you start up you can search all of memory for the string with the correctly set flag. If you find the string and the flag is set you are already loaded. the reason you need the flag is that there may be a partial copy of your program in one of DOS's disk buffers. You don't want to identify that as a copy of your program. hope this helps. lloyd w. tabb nbi engineering 3450 mitchell lane boulder, colorado 80301 {hao|ucbval|allegra}!nbires!mmm
bill@hpcvlo.HP.COM (Bill Frolik) (01/16/87)
If your memory resident program takes over some interrupt, one way for it to determine if a copy of itself has already been made resident is to examine the handler of any interrupt that it takes over: ; replace "XX" with your favorite interrupt number org 100h begin: jmp discard ;Jump over resident stuff oldXX dd ? ; intXX: nop ;Everything before the label nop ; "discard" will become resident nop ; jmp far ptr cs:oldXX; matlen equ $-intXX ;Match length for determing residency discard: xor ax,ax ;ES -> mov es,ax ; Segment zero les di,es:[XX*4] ;ES:DI -> Current Int XX handler mov si,offset intXX ;DS:SI -> Our new Int XX handler mov cx,matlen ;Number of bytes that must match rep cmpsb ;Compare the two handlers je AlreadyThere ;Jump if they're the same ; Our code has not yet been installed: ; - Save old intXX vector in 'oldXX' ; - Point intXX at our new routine 'intXX' ; - Do anything else that may need to be done at install time mov dx,offset discard ;Figure out add dx,0Fh ; how many paragraphs mov cl,4 ; are to remain shr dx,cl ; resident, then call mov ax,3100h ; terminate/stay resident. int 21h AlreadyThere: ; Our code has already been installed. mov ax,4C00h ;Normal int 21h ; temination Bill Frolik hp-pcd!bill Hewlett-Packard Portable Computer Division Corvallis, Oregon
mmm@nbires.UUCP (Michelle Melvin) (01/20/87)
the proposed method of comparing interrupt handlers to determine if a TSR program is already loaded is not sound. it is possible that some other TSR program has stolen your vector (has been loaded after you and chained to that interrupt). in this case your handlers would NOT match but the program would be already loaded. while this would work most of the time it is not bullet proof. flamingly, lloyd w. tabb
dragheb@isis.UUCP (Darius "OPRDRT" Ragheb) (01/20/87)
In article <966@nbires.UUCP> mmm@nbires.UUCP (lloyd w. tabb) writes: >the proposed method of comparing interrupt handlers to determine >if a TSR program is already loaded is not sound. it >is possible that some other TSR program has stolen your vector (has been >loaded after you and chained to that interrupt). in this case your >handlers would NOT match but the program would be already loaded. while >this would work most of the time it is not bullet proof. This is the exact problem (I think) that occurs when you load sidekick. As Borland "recommends" loading SK last, it seems to "jump" in front of all the other interrupt handlers. Another method was proposed (and has not yet been tried) is: place a unique sequence of bytes in the data segment, and when loaded scan memory for it (not too bad timewise, i suppose) BUT also have a flag right after the sequence, and when determined that it is the first time the program is run, change the flag. -- Functionality, Efficiency, Luxury. isis!dragheb | dragheb@isis.cs.du.edu