🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: alt.msdos.programmer
2 messages
2 total messages Started by Charlie Hutchins Mon, 17 Aug 1992 17:43
Why can't I hook INT 21h???
#388
Author: Charlie Hutchins
Date: Mon, 17 Aug 1992 17:43
34 lines
1489 bytes
Okay, maybe someone could help me here.  I am trying to write a TSR
that hooks interrupt 21h but whenever I try and hook that vector I
get an invalid command.com error and my system crashes.  I am using
TC++ 3.0 and I have tryed both using their set vect routine as
well as manually changing the interrupt vector table but in both
cases the same thing happens...crash!  Even if I write an ISR for
INT 21h that simply returns control to the original ISR the system
crahes.  For example, even this crashes my system:

#include <dos.h>
#include <stdio.h>

void interrupt new21handler(void);
void interrupt (*old21handler)();

void main(void)
{
        disable();
        old21handler=getvect(0x21);
        setvect(0x21, new21handler);
        enable();
        keep(0, 4000);
}

void interrupt new21handler(void)
{
        (old21handler)();
}

Anyone know what's wrong here??? As far as I can see this program should
basically do nothing but take up memory but instead, it crahes the system when
run.  Any info would be greatly appreciated.

...Charlie Hutchins
Re: Why can't I hook INT 21h???
#391
Author: Bob Mathews
Date: Tue, 18 Aug 1992 03:40
17 lines
1287 bytes
Charlie_Hutchins@mindlink.bc.ca (Charlie Hutchins) writes:
>Okay, maybe someone could help me here.  I am trying to write a TSR
>that hooks interrupt 21h but whenever I try and hook that vector I
>get an invalid command.com error and my system crashes.  I am using
>TC++ 3.0 and I have tryed both using their set vect routine as
>well as manually changing the interrupt vector table but in both
>cases the same thing happens...crash!  Even if I write an ISR for
>INT 21h that simply returns control to the original ISR the system
>crahes.  For example, even this crashes my system:
[code deleted]

The turbo c interrupt function automatically saves all cpu registers.
The return values from DOS are getting clobbered.  Code like this
absolutely needs to be written in assembly.  You need to have complete
control of what's happening to the machine.

swehtam bob
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads