Date: Thu, 1 May 1997 13:18:30 +0300 (IDT) From: Eli Zaretskii To: Jimmy OBERTAN cc: djgpp AT delorie DOT com Subject: Re: My mouse driver and CLI/STI question In-Reply-To: <9704301159.AA39701@ibm1.cicrp.jussieu.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Wed, 30 Apr 1997, Jimmy OBERTAN wrote: > Win95, DOS with cwsdpmi and win3.1. Result : under win95 and DOS every > thing works well but under win3.1 the kbhit() function dosn't work after > calling the Show function. I've perform some tests and find out that the > "cli" was the problem. Should i use the dpmi function to enable or > disable the virtual interrupt state for all to run properly ? You don't need either, it is all done for you automatically. So please remove all those asm() statements and see if the program works then. (Why do you at all push and pop flags *inside* your function? That's what the wrapper is for.) > void MouseOFF() > { __dpmi_regs r; > if (!SlimeSouris) return; > delete ATCALL; > delete f; > _go32_dpmi_free_real_mode_callback(f); > > r.x.ax = 0x14; > r.x.cx = LastMouseMask; > r.x.es = LastMouseHandler_seg; > r.x.dx = LastMouseHandler_ofs; > __dpmi_int(0x33, &r); > > if (etat==Shown) Hide(); > etat=Hidden; > SetHide(NULL); > SetShow(NULL); > > SlimeSouris=0; > } This is exactly in the wrong order! You are deallocating the callback while the interrupt table is still pointing to it. If somebody moves the mouse or presses a button during that moment, they will crash! This is what you need to do: - hide the mouse pointer; - restore the previous interrupt function; - free the callback; - call destructors for f and ATCALL; - return