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++ Language Reference - dos_abs_disk_read http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
                            dos_abs_disk_read

   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.

   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>

   char buffer[512];
   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 error %x   bios error %x\n",i%256,
                       i/256);
             exit(1);
        }

        printf("logical sector 1, drive A\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 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

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