absread
Reads absolute disk sectors.
Defined in header <dos.h>
Syntax
#include <dos.h>
int absread(int drive, int nsects, long Ised, void *buffer);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
absread reads specific disk sectors. It ignores the logical structure of a disk and pays no attention to files, FATs, or directories.
absread uses DOS interrupt 0x25 to read specific disk sectors.
drive = drive number to read (0 = A, 1 = B, etc.) nsects = number of sectors to read Isect = beginning logical sector number buffer = memory address where the data is to be read
The number of sectors to read is limited to 64K or the size of the buffer, whichever is smaller.
Return value
If it is successful, absread returns 0.
On error, the routine returns -1 and sets the global variable errno to the value returned by the system call in the AX register.
See also
Example
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
iinclude <dos.h>
#include <ctype.h>
#define SECSIZE 512
int main (void)
{
unsigned char buf [SECSIZE];
int i, ], sector, drive;
char str[10];
printf ("Enter drive letter: ");
gets(str);
drive = toupper (str[0]) - 'A';
printf ("Enter sector number to read: ");
gets(str);
sector = atoi (str);
if (absread (drive, 1, sector, &buf) != 0) {
perror("Disk error");
exit(l);
}
printf ("\nDrive: %c Sector: %d\n", 'A' + drive, sector)
for (i = 0; i < SECSIZE; i += 16) {
if ((i / 16) == 20) {
printf ("Press any key tO' continue...");
getchO ;
printf ("\n");
}
printf ("%03d: ", i);
for (] = 0; j < 16; ]++)
printf ("%02X ", buf[i+j]);
printf ("\t");
for (j = 0; j < 16; j++)
if (isprint(buf[i+j]))
printf ("%c", buf[i+j]);
else printf (".");
printf ("\n");
}
return 0;
}
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/dos.h/absread/
· short form /3.1/absread/