home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / msdos / programm / 8577 < prev    next >
Encoding:
Text File  |  1992-08-17  |  1.4 KB  |  44 lines

  1. Path: sparky!uunet!dtix!darwin.sura.net!mips!swrinde!elroy.jpl.nasa.gov!ames!agate!rsoft!mindlink!a3133
  2. From: Charlie_Hutchins@mindlink.bc.ca (Charlie Hutchins)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Why can't I hook INT 21h???
  5. Message-ID: <14339@mindlink.bc.ca>
  6. Date: 17 Aug 92 17:41:03 GMT
  7. Organization: MIND LINK! - British Columbia, Canada
  8. Lines: 34
  9.  
  10. Okay, maybe someone could help me here.  I am trying to write a TSR
  11. that hooks interrupt 21h but whenever I try and hook that vector I
  12. get an invalid command.com error and my system crashes.  I am using
  13. TC++ 3.0 and I have tryed both using their set vect routine as
  14. well as manually changing the interrupt vector table but in both
  15. cases the same thing happens...crash!  Even if I write an ISR for
  16. INT 21h that simply returns control to the original ISR the system
  17. crahes.  For example, even this crashes my system:
  18.  
  19. #include <dos.h>
  20. #include <stdio.h>
  21.  
  22. void interrupt new21handler(void);
  23. void interrupt (*old21handler)();
  24.  
  25. void main(void)
  26. {
  27.         disable();
  28.         old21handler=getvect(0x21);
  29.         setvect(0x21, new21handler);
  30.         enable();
  31.         keep(0, 4000);
  32. }
  33.  
  34. void interrupt new21handler(void)
  35. {
  36.         (old21handler)();
  37. }
  38.  
  39. Anyone know what's wrong here??? As far as I can see this program should
  40. basically do nothing but take up memory but instead, it crahes the system when
  41. run.  Any info would be greatly appreciated.
  42.  
  43. ...Charlie Hutchins
  44.