Date: Sun, 17 Oct 1999 14:44:19 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Alex Mendes da Costa cc: djgpp AT delorie DOT com Subject: Re: Hooking Interrupts In-Reply-To: <3808656A.F523EB85@virtualis.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Sat, 16 Oct 1999, Alex Mendes da Costa wrote: > This code compiles just fine, and it runs fine until I press a key, > which I am guessing calls my interrupt, then it stuffs up my computer > completely. On what OS? DOS? Windows? > I am guessing the problem is in the regions I am trying to lock with > __dpmi_lock_linear_region, and I have read through loads of docs and FAQ > but for the life of me I can't figure out why it wont work! I already replied once to a similar message of yours, with the advice to try the _go32_xxx helper functions first, and write your handler in C, not in NASM. Did you try that? The _go32_xxx helper functions make it a lot easier by taking care of many gory details for you. > region.handle = 0; Don't do this! And zero out the `region' variable before assigning values to its members (with a call to memset). > /* Lock the stack */ > __dpmi_get_segment_base_address(_my_ss(), &baseaddr); > region.handle = 0; > region.size = 10; > region.address = baseaddr; > __dpmi_lock_linear_region(®ion); Don't do this. You cannot lock the stack like that, the above code is very dangerous. If you want the entire stack locked, it is simpler to lock everything with the _CRT0_FLAG_LOCK_MEMORY bit. The usual way to solve problems with stack is not to use the normal C stack inside the interrupt handler. The handler is called on a locked stack provided by the DPMI server, so for small amount of push/pop instructions it should me more than adequate. Simply don't switch to the C stack, and you will not need to lock the stack at all. > i = 0; > do { > /* Endless loop? */ > } while (i == 0); How do you expect to exit this loop?