[comp.windows.ms.programmer] Interrupts in Windows

iam@waikato.ac.nz (Ian McDonald) (01/11/91)

In an earlier (now cancelled) message I posted code for setting interrupts in
Windows code.  Unforunately I missed an h off a int 21 call so here is the
correct (and a bit tidier) call.  It doesn't seem to work with real mode at the
moment but I suspect that is lack of memory.  (By real mode I mean windows real
mode not program code running in real mode - this will only work for code
running in real mode not protected mode - can someone point me in the direction
of DPMI specs). When using this code segments have to be preloaded and fixed.

/* winvect.c */

/* A replacement for Microsoft's routines which are not in Windows libraries

   History

   iam 08 Jan 91 Created
*/

#ifdef _WINDOWS
#include <windows.h>
#include "winvect.h"

void(_interrupt _far *_dos_getvect(unsigned intnum))() {
  void _far *vect;

  /* Dos function 35 is Get vector function.  Specify the interrupt in al
     and the vector will be returned in es:bx */

  _asm {
    mov ax,intnum
    mov ah,35h
    int 21h
    mov vect+2,es
    mov vect,bx
  }
  return(vect);

}

void _dos_setvect(unsigned intnum,void(_interrupt _far *handler)()) {

  /* Dos function 25 is set vector.  Put interrupt number in al,
     vector in ds:dx */
  _asm {
    push ds
    mov ax,intnum
    mov ah,25h
    lds dx,handler
    int 21h
    pop ds
  }
}

#endif
-- 
-------------------------------------------------------------------------
Ian McDonald  |                                           
52 Cook Street|                                             /  /\  /\
Hamilton      |   This space free for advertising !!       /  /  \/  \
New Zealand   |                                           /  /        \
+64-71-563438 |   I can receive mail but can't reply to it.