Mail Archives: djgpp/2001/04/06/13:45:36
Hi friends...
I'm trying to hook a &^@&^#&^ IRQ with my DJGPP program.
I hate to post code on the newsgroup, but i don't have more options.
The program is running over plain DOS (IO.SYS, MSDOS.SYS and COMMAND.COM
ONLY).
I'm trying to hook IRQ 0 - System Timer Interrupt (0x08) with no sucess.
I can hook INT 0x1C, but i need the real IRQ ISR INT 0x08
8((
Please, if you have time, take a look to this (minimum) code and tell me
what
is wrong. It works for INTERRUPT = 0x1C, but don't for 0x08.
Do i need to hook the real mode 0x08 interrupt ? Or both the protected and
real mode ones ?
---8<--- cut here ---8<----
#include <stdio.h>
#include <go32.h>
#include <dpmi.h>
#include <pc.h>
#include <unistd.h>
#define INTERRUPT 0x08 //works for INTERRUPT 0x1C
unsigned int ct;
_go32_dpmi_seginfo oldvect;
_go32_dpmi_seginfo newvect;
void hookint(void);
void unhookint(void);
int *newtimer(void)
{
ct++;
}
int *endtimer(void)
{
}
int main(void)
{
sound(500);usleep(50000);nosound();
printf("Hooking INT %X...\n",INTERRUPT);
ct=0;
hookint();
while(ct<=100); //just to wait a few seconds...
unhookint();
printf("The End\n");
sound(900);usleep(50000);nosound();
return(1);
}
void hookint(void)
{
_go32_dpmi_lock_code (newtimer, (long)endtimer - (long)newtimer);
_go32_dpmi_lock_data (&ct,sizeof(ct));
_go32_dpmi_get_protected_mode_interrupt_vector (INTERRUPT, &oldvect);
newvect.pm_offset = (long)newtimer;
newvect.pm_selector= _go32_my_cs();
_go32_dpmi_allocate_iret_wrapper (&newvect);
_go32_dpmi_set_protected_mode_interrupt_vector (INTERRUPT, &newvect);
}
void unhookint(void)
{
_go32_dpmi_set_protected_mode_interrupt_vector (INTERRUPT, &oldvect);
_go32_dpmi_free_iret_wrapper(&newvect);
}
---8<--- cut here ---8<---
Thanks in advance for your help and attention !!
Eduardo TUDA DocHell Lorenzetti Pellin
PEA - Electrical Energy and Automation Department
USP - Politechnical School of Sao Paulo University - BRAZIL
http://www.pea.usp.br/~epellini
---------------------------------
And if you have a time to loose,
an open mind, and right to choose,
would you care to take a look,
or can you read me like a book...
time's is allways on my side...
--------------------------------- (Up the Irons !!!)
- Raw text -