Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>dos_abs_disk_read</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
dos_abs_disk_read
   Note-This function is not available under the DOSX extender.

Usage

   #include <dos.h>
   int dos_abs_disk_read (int drive, int num_sec,
                          int start_sec, char *buffer):

Description

   Transfer control directly to BIOS to perform the disk read. The drive is
   a 0 for A:, 1 for B: and so on up to 25. The number of sectors to read is
   specified in num_sec. start_sec defines the first sector for operation.
   The final argument, buffer, is the destination memory address for the
   operation, it must be large enough to hold the requested sectors. This
   function will work correctly under MS-DOS 4.x.


Example 

   /* Reads in logical sector 1 from drive a: and    */
   /* does a hex and ascii dump of it to the display */
   #include <stdio.h>
   #include <dos.h>
   #include <ctype.h>
   #include <stdlib.h>

   char buffer[512];
   int main()
   {
       unsigned i, j;
       unsigned char *p = (unsigned char *) buffer;

       i = dos_abs_disk_read(0,1,1,buffer);
       if (i)
           {
           printf("Disk error: dos code %x bios code %x\n",i%256,i/256);

           exit(EXIT_FAILURE);
           }
       printf("logical sector 1, drive A\n\n\n");

       for (j = 0; j < 512; j += 8, p += 16)
           {
           for (i = 0; i < 16; i++)
               printf("%02x ",p[i]);
           printf("    ");
           for (i = 0; i < 16; i++)
               if (isprint(p[i]))
                   printf("%c",p[i]);
               else
                   printf(".");
           if (j && (j%128 == 0))
               {
               printf("\n:Press any key:\n%c",0x07);
               getchar();
               }
           else

               printf("\n");
           }
       return EXIT_SUCCESS;
   }

Return Value

   Returns a 0 on success. A non-zero return value indicates an error. The
   lower byte will contain the DOS error code. The higher byte will contain
   the specific BIOS error. These BIOS errors are detailed below:

       0x01    bad command
       0x02    bad address mark
       0x03    write protect error
       0x04    sector not found
       0x08    DMA (direct memory access) failure
       0x10    data error (bad CRC)
       0x20    controller failure
       0x40    seek operation failed
       0x80    device failed to respond


See Also

   DOS package, dos_abs_disk_write



See Also: dos_abs_disk_write

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