[an error occurred while processing this directive]
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 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
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
getmntent from the library source distribution, or
from the zip picker.