www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/06/28/16:39:14

Xref: news2.mv.net comp.os.msdos.djgpp:5507
From: Ed Kaulakis <edk AT mcig DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Hookingi nterrupts in C++
Date: Fri, 28 Jun 1996 12:41:20 +0000
Organization: Medi-Comp Innovations Group
Lines: 25
Message-ID: <31D3D2F0.64E1@mcig.com>
References: <4qku2p$447 AT pegasus DOT odyssee DOT net>
NNTP-Posting-Host: pm177.smartlink.net
Mime-Version: 1.0
To: neligan AT odyssee DOT net
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Mitran Marcel wrote:
> 
> Hi,
> 
>         I'm trying to write a simple program that hooks the timer interrupt in
> C++. 

You shoulda thunk of that. What you need is a piece of code that 
associates a 'this' pointer for the interrupt handler object with the 
interrupt vector. Ofer Laor's ISC, (on Simtel mirrors everywhere) shows
one way to do this in real mode. Basically, he builds in memory a short 
code sequence (called for historical reasons a thunk) which loads the 
this pointer and calls the void serve_interrupt(void) method. 

The key point is that the interrupt vector table entry is the _only_ 
context available at the time of the interrupt, and the only way to 
figure out which one got entered is to have each one point to different 
code, which loads a constant (e.g. the this pointer) which you want to 
associate with this interrupt.

In DJGPP, things will be more complex; the memory in which the thunk is 
built must be writable at build time and executable at run time; it must 
be locked in memory; etc. etc. etc.

Good luck!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019