Date: Wed, 8 Jul 1998 12:16:31 +0300 (IDT) From: Eli Zaretskii To: Endlisnis cc: djgpp AT delorie DOT com Subject: Re: Mouse Handling In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Sun, 5 Jul 1998, Endlisnis wrote: > I tried to set up one of the examples shown in the FAQ to have a > function of mine called every time a mouse event occurs. My function > doesn't contain any code, it is just blank. Yet anytime the mouse moves, > the system crashes. The FAQ has inadvertently omitted a crucial part of setting up the mouse handler: you must assign callback_info.rm_segment and callback_info.rm_offset to r.x.es and r.x.dx, respectively. Otherwise, you pass a bogus address to the mouse driver, which will surely crash your system when the driver calls that address. The FAQ text explains that, but the example omits these lines, sorry. I really suggest that you browse the documentation of the specific function you are invoking (in this case, function 0Ch of Int 33h) when writing such code. I would imagine that you would have found this bug in the FAQ example much faster if you did that. Some additional comments about your test program, while we are at that: > _go32_dpmi_lock_data(func,Size); You need to use _go32_dpmi_lock_code here, since you are locking the code, not the data. Btw, I don't think you even need to lock anything when you install a mouse handler, since the handler isn't called in a context of a hardware interrupt. > while(Mouse.x!=80) > cout << Mouse.x << "," << Mouse.y << "," << Mouse.b << "\r"; > } In a real production program, you need to disable your handler (by calling function 00h of Int 33h, or by calling the same function 0Ch with a zero mask in CX register), and then deallocate it (by calling _go32_dpmi_free_real_mode_callback). If you fail to do that, your program might crash when it exits.