Xref: news2.mv.net comp.os.msdos.djgpp:5552 comp.os.msdos.programmer:26024 From: Shaune Beattie Newsgroups: comp.os.msdos.programmer,comp.os.msdos.djgpp Subject: Help please! protected mode "TSR"'s Date: Sun, 30 Jun 1996 19:58:43 +0100 Lines: 59 Message-ID: <31D6CE63.353587C0@beattie.demon.co.uk> NNTP-Posting-Host: beattie.demon.co.uk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hi, Basically I want to write a program that traps a HW interrupt while a DPMI32 program is running. Obviously writting a normal "real" mode TSR is no good as interrupts are passed to the protected mode first (and the program in question will also be hooking the same interrupt I want to). If I could write a protected mode TSR as described in the DPMI 1.0 spec, then what I would do is in my initialisation function, hook both the hardware interupt i want, and also int 31H.. this way when the program also tried to hook the same interrupt i can make sure i reinsert my interupt handler so that it gets called first, optionally chaining on to the handler that the program has installed. however the program will be running under a dpmi v0.9 host.. and hence I can't use the 1.0 spec functions.. so somehow I need to kludge it... my thought is that if I install a normal real mode tsr on an real mode interrupt that I know the target program will also call.. then I can then make calls to the dpmi host that has been loaded to run the target program, hopefully then what I can do is call the int 31H routines to obtain the real mode to protected mode switch routine.. call it.. then allocate some protected mode memory, allocate a descriptor and point it at that memory, setting it to be executable, 32bit etc. then copy the rest of the real mode tsr routine (which is actually the 32bit protected mode program) into that memory, finally calling into it.. that program will then hook the protected mode interupts as normal etc. first of all, this is pretty horendous.. any easier ways of doing it? secondly what are the chances of it working? can I call the real to protected mode switch routine whilst in a interrupt service routine? is this at all valid? what about the rest of the int 31H functions.. are these valid to call whilst in a real mode interupt service routine? do i actually need to bother with the copy.. or can i simply create a descriptor pointing at the rest of my code whereever it happens to be in dos memory? if some of this is completely off track it is because i only started writting ms-dos programms 2 weeks ago :-) before then I spent all my time in the isolated worlds of full 32bit programs and didnt have to worry about all this stuff. so one really stupid question.. what signifies the difference between 32 and 16 bit code? once my code calls the real to protected mode switch.. so it is running in protected mode.. is there anything stopping me simply executing 32bit code straight away? and hence ignore all the allocating memory and copying parts? or do I need to create a descriptor that marks the memory as being 32bit code to make the 16->32bit switch? I hope i explained at least some of this well enough for someone to give me any hints thanks for any help Shaune