www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/02/06:23:28

Message-Id: <199605021015.AA28083@moo.dsi.unive.it>
Reply-To: adettino AT dsi DOT unive DOT it
Organization: CDL Informatica - Universita' Venezia
From: Dettino Alberto <adettino AT dsi DOT unive DOT it>
Subject: Handling INT 0x24
To: djgpp AT delorie DOT com
Date: Thu, 02 May 96 12:15:11 +0200
Sender: maildisp AT moo DOT dsi DOT unive DOT it

When an error related to the disks accour (such as no disk in drive, disk ful,
ecc.) dos calls the critical error handler (int 0x24).
I have seen that programs compiled with DJGPP automatically handle this
interrupt and make the routine fails the system call so the calling (for
example fopen, fread, ecc.) function returns an error.
Now I want to trap this interrupt so I have written a little program:

file test.c:

#include <stdio.h>
#include <dpmi.h>
#include <conio.h>

/* variable needed to capture an interrupt */
_go32_dpmi_registers _regs;
_go32_dpmi_seginfo _info,old_int24;

/* function prototypes */
void get_int24(void);
void free_int24(void);
void my_int24(_go32_dpmi_registers *r);


void main(void) {
 /* capture the interrupt. */
 get_int24();

 /* try to open a file (there's no disk in drive a so we are sure */
 /* that dos calls the error handler routine                      */
 fopen("a:\\a_file","r");

 /* this peace of code is never reached */
 free_int24();

 return;
}



void get_int24(void) {
 /* save old interrupt vector */
 _go32_dpmi_get_real_mode_interrupt_vector(0x24,&old_int24);
 _info.pm_offset=(int)my_int24;

 /* now interrupt points to our routine */
 _go32_dpmi_allocate_real_mode_callback_iret(&_info,&_regs);
 _go32_dpmi_set_real_mode_interrupt_vector(0x24,&_info);

 return;
}

void free_int24(void) {
 /* release the interrupt vector */
 _go32_dpmi_set_real_mode_interrupt_vector(0x24,&old_int24);
 _go32_dpmi_free_real_mode_callback(&_info);

 return;
}


/* the function that handles the int 24h */
void my_int24(_go32_dpmi_registers *r) {
 /* show a message so we are sure that our routine is really called */
 /* we have to use cprintf instead of printf because when we are    */
 /* into an int 24h we can't make dos call                          */
 cprintf("Error handler called!!");

 /* set back old vector */
 free_int24();

 /* simply make dos terminate our application */
 r->h.al=2;

 return;
}


end of file test.c

I run this program and it works: it shows me the error string and terminate
the application returning to the dos prompt. Now everithing seems to be good
(the original int 0x24 is restored and works well) but if I run another
program that want to handle directly the interrupt my system reboots.

Why this? There's a bug in my code or this behaviour is due to the DPMI
interface used by DJGPP programs?

Any help will be appreciate. 


Alberto Dettino 
University of Venice, Department of Computer Science.
E-Mail: adettino AT dsi DOT unive DOT it

If you need, here there's my PGP public key:

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: 2.6.3i
Comment: Requires PGP version 2.6 or later.

mQCNAzDtKhAAAAEEAM8C/2iDVx2t7jCcnfQdB7HwTt1A0ZqQe8AGNcl6A48cp5de
geHjx2qTND5tEHPcMWKpn/bP+qabhZy8w7AQ1uf2j/soFktdEpZfyd98qw0XJWQ2
cTXWEt5raqs5y8GIhYNBbnXlghFt8dW05gh9m4CJ3w1brZqlDMnYTfAj3G7NAAUT
tCdBbGJlcnRvIERldHRpbm8gPGFkZXR0aW5vQGRzaS51bml2ZS5pdD6JAJUDBRAx
fhIcbAyChODiNIEBAUQCA/4yD09NmGtKO2dmcmrfLV7L0s8po4GRX3VSzKIF/Jt2
pmcJfefQQfGRtxWeVuj6zpY2squOKwayDGwaafD8Ak9bwD73QUYA8rJqWgiSdQ7r
bWJprYzc/m7aMtK3MZVSmEAHisDqjdTOGjv2TKwEusyEaKYXSpO/lXgdkLc117DG
DIkAlQMFEDFYsDVgjVNlNdijEQEBOjEEALJDofgqLdJlwdzlRD4WOrz/mKXwf3Bz
CuA9y9Ht/dLPh1rTTJy99+Z5wrwfZpCgNsg1CCjcDAQxoClr1dsx2BpPVjrUEphC
sLuLKKlcNB0lM2UDr9shnwN12q7uoXtLpMfZ9zoMLVt7dEW3tq6F3FX7pS71BNIw
qwCQhx0ef1rBiQCVAwUQMT+IdzBFxihfhXQVAQG1ZAQA2HbxLNO+GjaqGxSKC40X
gM/Ztmpz/djA7R3JN1Ly/yimAwfgmXFIGLR58Bt5E/ElAsRIk5QgfDp0FzGrN9KA
ZYvraCzNkfzGgpnfjOu8/PGrXzRR5Yg9Wq6zuczwie3lNC/tEGS0RKQXQN8XqAJh
KctZBmE3k4eli2M12jqqUzqJAJUDBRAxJxX0gQh/1LfYv70BAVjnA/45PlXmeci7
oq03PMgCxtkOvecTTftLlq27xATdW5IKBoT9mWwgLLpO/4B+VlNVFTZiv425+ckF
C4pCx7kdHBs+B0e4U0gn+kIZzJrzbSIlUGjGw1zxLPH5EAtDj9/qHpknOIfyrK4O
34ff2BimjJTWEYgUrcHUoIK6TxuZFQZehokAlQMFEDDtKknJ2E3wI9xuzQEBsDcE
AMtzDI/ZwFdmsiLzr8+MSgthi4CR7JwlbDmLNk6wWH8piOzWEJUUdyC2nQkymLQA
sclALjl9j8zHl7uql2l/18XmCdeUc/+NLHeAWCaVu4c7Jo5vxWuq0frRrPTcMAsn
eFWT67zWCbYx4N3QyG1LIHdL8yVKQazUm0lTULapHpIa
=Z4bq
-----END PGP PUBLIC KEY BLOCK-----

- Raw text -


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