🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #973

Re: Why can't I hook INT 21h???

#973
From: aki
Date: Tue, 18 Aug 1992 17:18
44 lines
1868 bytes
struct REGPACK rp;  /* for the intr() call */
void interrupt myinthandler(ax,bx,cx,dx,bp,ds,es,flags)
{
  rp.r_ax=ax;
  rp.r_bx=bx;
  rp.r_cx=cx;
  rp.r_dx=dx;
  rp.r_bp=bp;
  /* plus other pointers and indexes as required */
  rp.r_ds=ds;
  rp.r_es=es;
  intr(old_ints_new_int_num, &rp);
  ax=rp.r_ax;
  bx=rp.r_bx;
  cx=rp.r_cx;
  dx=rp.r_dx;
  bp=rp.r_bp;
  ds=rp.r_ds;
  es=rp.r_es;
  flags=rp.r_flags;
}

The above is for Turbo-C.  Don't ask me how to convert it to other
C implementations.   The idea is simple.  You transfer the original
INT to a different location (just like the HD BIOS transfers the
FD INT 13H).  Then you use the REGPACK structure to move the information
that a particular ISR needs to the function and back.  Turbo-C
handles interrupt-functions very cleanly by pushing all registers
onto the stack;  thus it's easy to adjust the return values.  When
looking for a new place for the old ISR,  I routinely scan for an
empty location (0000:0000) in the area of INT 80H-FDH.  If DOS is
less than 3,  the vectors are not initialized and thus I just pick
F0H.

Some problems of the above code:  HUGE overhead as far as time,
HUGE stack requirement (if you count stack size in bytes).

Aki.
.

-- 
/  Phone: 408-662 9664   Fax: 662 9676  |  "Aki" pronounced: Ah-Key. I know  \ 
\  125 Searidge Ct #D, Aptos, CA 95003  |  what I'm doing most of the time.  /
Technical Details
Message-ID: <4064@cruzio.santa-cruz.ca.us>
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!decwrl!decwrl!netcomsv!cruzio!aki
References: <14339@mindlink.bc.ca> <eoq.25.0@vthnw.cvm.msu.edu> <dmurdoch.46.714083466@mast.queensu.ca>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!olivea!decwrl!decwrl!netcomsv!cruzio!aki
From: aki@cruzio.santa-cruz.ca.us
Newsgroups: comp.os.msdos.programmer
Subject: Re: Why can't I hook INT 21h???
Message-ID: <4064@cruzio.santa-cruz.ca.us>
Date: 18 Aug 92 17:18:35 GMT
References: <14339@mindlink.bc.ca> <eoq.25.0@vthnw.cvm.msu.edu> <dmurdoch.46.714083466@mast.queensu.ca>
Sender: aki@cruzio.santa-cruz.ca.us
Reply-To: aki@cruzio.santa-cruz.ca.us
Lines: 44