[comp.os.msdos.programmer] Hooking Int 2F

theall@rm105serve.sas.upenn.edu (George A. Theall) (04/21/91)

   Are there any tricks to hooking into INT 2F under DOS 3.30?  I'm
writing a TSR who's sole purpose is to occupy conventional memory. I
thought I'd hook INT 2F so as to be able to communicate with my ISR,
but something's not working right.

   Here's the code, written for TASM's IDEAL model, for my ISR. For now
it merely services installation checks, passing requests for other ISRs
along to whoever owned the interrupt before. It's been compiled using
TASM 2.0 with the TINY model.

			--- snip, snip, snip ---
	PROC handle_Int2F   FAR
	          cmp       ah, 0C0h
	          jz        SHORT @@aSubfunction
	          jmp       [cs:OldInt2F]
	@@aSubfunction:
	          or        al, al
	          jnz       SHORT @@Fin
	          dec       al
	@@Fin:
	          iret
			------------------------

Simple, no? I can install it fine, detect its presence  correctly, and
remove it without trouble. It seems to work.

   The trouble though is when I limit memory to 64K and try to run a
program FOO which has not given me trouble before. (Of  course, I've
never run FOO with only 64K of memory. :-) Program  execution jumps
immediately to FFFF:FFFF. (The first instruction in FOO is MOV DX, CS,
and trying to Trace execution with DEBUG produces an immediate
exception 13 with QEMM installed.) Funny thing is that with 65K the
program appears to work fine.

   I suspect a stack is getting clobbered somewhere. Is DOS doing
something behind my ISR's back which a local stack would cure? Btw: 
FOO is an EXE compiled by TC++ v1.01 using the TINY model.

   Thanks in advance for any help,

George
--- 
theall@rm105serve.sas.upenn.edu			Dept. of Economics
theall@ssctemp.sas.upenn.edu			Univ. of Pennsylvania
gtheall@penndrls.upenn.edu			Philadelphia, PA 19104