Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_harderr() install new hardware error handler</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _harderr()              Install new hardware error handler

 #include   <dos.h>

  void _harderr(void(fptr)());
  far *fptr;        Location of new INT 24h handler

    _harderr() replaces the MS-DOS critical error handler with a
    programmer-defined replacement. The default handler displays the
    familiar "Abort, retry, or ignore?" message, among others. Using
    _harderr(), it is possible to perform more extensive critical error
    handling, although only MS-DOS function calls below 0Ch or 59h can be
    used. This means that many standard C functions (such as stream and
    low-level I/O) cannot be used in hardware error handlers.

    _harderr() does not directly install 'fptr', but instead installs an
    intermediate handler that calls 'fptr'. The intermediate handler
    calls the fptr replacement with the following parameters:

 handler(unsigned deverror, unsigned errcode, unsigned far *devhdr);

 --------------------------------------------------------------------------
       deverror     The device error code containing the AX register
                    value that MS-DOS passes to the INT 24h handler.

                    If the error occurred on a disk device, bit 15 of
                    deverror will be 0, and the deverror argument will
                    contain one or more of the following:

                    Bits       Meaning
                    -------    -----------------------------------
                     15        Disk error if 0
                     14        Not used
                     13        "Ignore" response not allowed if 0
                     12        "Retry" response not allowed if 0
                     11        "Abort" response not allowed if 0

                     9-10      Code    Location
                               ----    ---------------------------
                                00     MS-DOS
                                01     File allocation table (FAT)
                                10     Directory
                                11     Data area

                     8         Read error if 0; write error if 1

                     0-7       Drive where error occurred. Values less
                               than 80h specify floppy
                               disks; values greater than 80h specify
                               fixed disks. For example, 0
                               means the first floppy diskette, while 80h
                               means the first fixed disk.

                If the error did not occur on a disk device, bit 15 of
                deverror will be 1. The attribute word located at offset
                04 in the device-header block will indicate the type of
                device which had the error. If bit 15 of the attribute
                word is 0, the error is a bad memory image of the File
                Allocation Table. If bit 15 of the attribute word is 1,
                the error occurred on a character device and bits 0-3 of
                the attribute word indicate the type of device:

                    Bits       Meaning
                    -------    -----------------------------------
                      3        Current clock device
                      2        Current null device
                      1        Current standard output
                      0        Current standard input

 ---------------------------------------------------------------------------
        errcode     The DI register value that MS-DOS passes to the INT
                    24h handler.

                    The low-order byte of errcode can be one of the
                    following values:

                    00h      Write-protect error
                    01h      Invalid drive number
                    02h      Drive not ready
                    03h      Invalid command
                    04h      CRC error
                    05h      Bad request structure length
                    06h      Seek error
                    07h      Unknown medium; disk format not recognized
                    08h      Sector not found
                    09h      Printer out of paper
                    0Ah      Write error
                    0Bh      Read error
                    0Ch      General, nonspecific error

 ---------------------------------------------------------------------------
         devhdr     A far pointer to a device header that contains
                    descriptive information about the device on which the
                    error occurred. The user-defined handler must not
                    alter this header.

      Notes:    If the replacement handler returns, it can use one of
                these three methods:

                       1) Using the return statement
                       2) Using the _hardresume function
                       3) Using the _hardretn() function

                Control is given to MS-DOS if the handler returns using
                return or the _hardresume() function; control is given to
                the application if the handler returns using the
                _hardretn() function.

   Portability:     MS-DOS only, version 1.0 or higher


See Also: _hardresume() _hardretn() _chain_intr()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson