www.delorie.com/djgpp/v2faq/faq151.html | search |
| Previous | Next | Up | Top |
_go32_dpmi_allocate_real_mode_callback_retf
or the _go32_dpmi_allocate_real_mode_callback_iret
library function, as required by the real-mode service you want to hook, and
pass the `segment' and `offset' members it returns to the service you want (in the above example, Int 33h function 0Ch) by calling __dpmi_int.
Here's a code fragment that shows how to do
this(Note: If you are using this example in your program, don't forget to disable the handler at program's exit by calling the same function 0Ch of Int 33h with a zero mask in the CX
register, and then deallocate the callback by calling the _go32_dpmi_free_real_mode_callback
library function. Also, remember that all code and data touched by the handler must be
locked, otherwise it will crash under some DPMI servers, such as CWSDPMI.):
#include <dpmi.h> #include <go32.h> static __dpmi_regs callback_regs; static _go32_dpmi_seginfo callback_info; int install_mouse_handler (unsigned mask, void (*func)(__dpmi_regs *)) { __dpmi_regs r; callback_info.pm_offset = (long)func; if (_go32_dpmi_allocate_real_mode_callback_retf(&callback_info, &callback_regs)) return -1; /* failure */ r.x.ax = 0xc; r.x.cx = mask; r.x.es = callback_info.rm_segment; r.x.dx = callback_info.rm_offset; __dpmi_int (0x33, &r); return (r.x.flags & 1) ? -1 : 0; }The handler (
func
in the above example) will be called with a pointer to a __dpmi_regs
structure which is filled by values found in the CPU registers when the mouse driver
calls the handler. See the docs in the library reference Info file for further details about allocating wrapper functions.
webmaster donations bookstore | delorie software privacy |
Copyright ⌐ 1998 by Eli Zaretskii | Updated Sep 1998 |
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)