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

  1. Path: sparky!uunet!olivea!decwrl!decwrl!netcomsv!cruzio!aki
  2. From: aki@cruzio.santa-cruz.ca.us
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Re: Why can't I hook INT 21h???
  5. Message-ID: <4064@cruzio.santa-cruz.ca.us>
  6. Date: 18 Aug 92 17:18:35 GMT
  7. References: <14339@mindlink.bc.ca> <eoq.25.0@vthnw.cvm.msu.edu> <dmurdoch.46.714083466@mast.queensu.ca>
  8. Sender: aki@cruzio.santa-cruz.ca.us
  9. Reply-To: aki@cruzio.santa-cruz.ca.us
  10. Lines: 44
  11.  
  12.  
  13. struct REGPACK rp;  /* for the intr() call */
  14. void interrupt myinthandler(ax,bx,cx,dx,bp,ds,es,flags)
  15. {
  16.   rp.r_ax=ax;
  17.   rp.r_bx=bx;
  18.   rp.r_cx=cx;
  19.   rp.r_dx=dx;
  20.   rp.r_bp=bp;
  21.   /* plus other pointers and indexes as required */
  22.   rp.r_ds=ds;
  23.   rp.r_es=es;
  24.   intr(old_ints_new_int_num, &rp);
  25.   ax=rp.r_ax;
  26.   bx=rp.r_bx;
  27.   cx=rp.r_cx;
  28.   dx=rp.r_dx;
  29.   bp=rp.r_bp;
  30.   ds=rp.r_ds;
  31.   es=rp.r_es;
  32.   flags=rp.r_flags;
  33. }
  34.  
  35. The above is for Turbo-C.  Don't ask me how to convert it to other
  36. C implementations.   The idea is simple.  You transfer the original
  37. INT to a different location (just like the HD BIOS transfers the
  38. FD INT 13H).  Then you use the REGPACK structure to move the information
  39. that a particular ISR needs to the function and back.  Turbo-C
  40. handles interrupt-functions very cleanly by pushing all registers
  41. onto the stack;  thus it's easy to adjust the return values.  When
  42. looking for a new place for the old ISR,  I routinely scan for an
  43. empty location (0000:0000) in the area of INT 80H-FDH.  If DOS is
  44. less than 3,  the vectors are not initialized and thus I just pick
  45. F0H.
  46.  
  47. Some problems of the above code:  HUGE overhead as far as time,
  48. HUGE stack requirement (if you count stack size in bytes).
  49.  
  50. Aki.
  51. .
  52.  
  53. -- 
  54. /  Phone: 408-662 9664   Fax: 662 9676  |  "Aki" pronounced: Ah-Key. I know  \ 
  55. \  125 Searidge Ct #D, Aptos, CA 95003  |  what I'm doing most of the time.  /
  56.