[comp.sys.ibm.pc] Q 2of3 Assembly TSR interupt stealing.

u-dmfloy%ug.utah.edu@wasatch.utah.edu (Daniel M Floyd) (04/19/89)

In article <4497@tekigm2.MEN.TEK.COM> alanr@tekigm2.MEN.TEK.COM (Alan Rovner) writes:
>If I wanted to hook onto the keyboard interrupt handler to write my own
>TSR in assembly language how would I call the original handler(s) that
>were already in use?  I understand that when grabbing onto an existing
>interrupt vector you should call however many functions have already been
>in use there.  This is easy in C, one could call the function via a
>pointer, like (*orig_name)(). >

Process is as follows:
1. Load your program.
2. Get the old vector (Do via DOS function calls or 
     via LES dx,[Vector] or some other combination)
3. Save the old vector either in some other interupt location
     or preferably some data area in your code segment.
4. Turn off interupts
5. Replace the old vector with your new vector. (i.e. cseg:new_offset)
6. Turn on interupts
7. Use DOS Terminate and Stay Resident function
8. When you want to get the old vector either do the interupt where
     you saved it or do a far call to the data area where you saved it.

Doing this with a far call method saves an interupt and avoids problems
with multiple TSRs.

I do have code that does it both ways, but I'm too lazy to look it up.
I think you get the idea though.
Dan Floyd
8<D=