www.delorie.com/djgpp/v2faq/faq22_13.html   search  
Node:Int 24h, Next:, Previous:Struct packing, Up:Miscellany

22.13 How to avoid "Abort, Retry, Fail" messages

Q: How do I write a program that accesses floppy and CD-ROM drives, but avoids popping that "Abort, Retry, Fail?" message from DOS?

Q: Other DOS compilers supply a function named harderr or _harderr to hook the critical-error interrupt 24h, but DJGPP doesn't seem to have these...

A: Under DPMI, Int 24h is always hooked by the DPMI server, since Int 24h is issued by the real-mode DOS code, and it is not possible to terminate a DPMI client (like DJGPP programs) from real mode, if you press A in response to that prompt. The default handler under most DPMI servers will just set AL register to 3 and do an IRET, thus silently failing the DOS call that triggered Int 24h. The DJGPP startup code also hooks the protected-mode Int 24h with a handler that fails the DOS call as described above. So in most circumstances you won't see that DOS prompt at all; your program will just see a failed DOS call.

However, some DPMI hosts (notably, QDPMI), will sometimes crash your program if it generates Int 24h, for instance when you access an empty floppy drive. In such cases, or when the default action of failing the DOS call is not good enough, you will have to hook Int 24h with your handler. This should be done in exactly the same manner as hooking hardware interrupts (see how to set an interrupt handler), because Int 24h is one of the few software interrupts that, like all hardware interrupts, are always reflected to protected-mode. Note that CWSDPMI currently doesn't support hooking Int 24h; if you set an interrupt handler, it won't be called.

There are ways to avoid program crashes due to Int 24h (under those DPMI hosts that exhibit this buggy behavior) other than to install a handler for it. For instance, you can test if the floppy drive is empty with a BIOS call before accessing it with DOS functions; there are also similar ways to check if a CD-ROM drive is empty. The library function getmntent (see getmntent.) can be used to detect all the drives that can be safely accessed by DOS; or you can borrow some of the internal functions used by getmntent from the library source distribution, or from the zip picker.



  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2001   by Eli Zaretskii     Updated Apr 2001