Chapter – 11
Making Backups
Why Backups?
“The prevention is always better than the cure”. Making backups is also an important part of prevention of data disaster, which may help us to overcome the disk crash or any other type of data loss. In this chapter, we shall discuss how we can recover the data even after some serious disk crashes, just only with the help of previously made backups.
The recovery done by the previously stored backups is, almost always up to 100 percent, however the several type of disk crash may cause the variation in the recovery results in some particular cases.
Recovering data with the help of backups is quite easy, fast and reliable and can give the best results whereas the data recovery without backups is a difficult, complicated may be a lot of time taking process and even then we are in fear of not getting the 100 percent data in several cases.
When and what to Back up
There are several different areas on the disk which should be backed up once or at different intervals of time. The following table gives the idea of complete back up measures and helps to find out that when and what to back up:
What to Backup |
When to be Backed up |
Backup of MBR |
Once after FDISK. The MBR is Created By the FDISK command of DOS. You can take backup of MBR After FDISK, however even after the FORMAT of partitions created by FDISK, The MBR remains Unchanged. |
Backup of DBR |
Back up the DBRs for each logical drive once, after FORMAT. |
Backup of FAT and Directory entries. |
FAT and Directory Entries are changed every time when you create of delete files or directories. Therefore it is recommended that you should take backup daily. |
Backup of User Data |
Should be taken regularly. This type of backup causes the disk imaging to take place. However it is time taking yet most of the companies which have very sensitive data in their disks like to spend their time on disk imaging because by doing this they can backup all of the information described above. |
Besides this you should make an Emergency Boot Floppy for the system. If there is any type of disaster with the data in you hard disk, you can boot your system with the help of this floppy and analyze the disk for errors.
Backup of MBR (Master Boot Record) and its use
The Master Boot Record (MBR) or sometimes referred as The master partition table (MPT), contains a small program to load and start the active (or bootable) partition from the hard disk drive. The Master boot Record contains information about all four primary partitions.
For a Detailed study about MBR, refer the chapter, “Logical Approach to Disks and OS”, Discussed earlier in this book.
The MBR is located at Absolute Sector 0 or we can say at cylinder 0, head 0, and sector1. It is created on the hard disk drive by executing FDISK.EXE command of DOS.
Why Backup MBR:
MBR allows the boot sector of the active partition to receive the control when the system is started.
After the Power-On Self Test (POST), the BIOS loads the MBR (Master Boot Record) from the Hard Disk into memory and then executes it. First the MBR checks the Hard disk for an Active Partition, then it loads the DOS Boot Record (DBR) into memory and turns control over to the Operating System Boot code and then the Operating System Boot Record code loads the rest of the Operating System into Memory.
There for we can say that if the MBR of the Disk is corrupted, the hard disk is almost dead and the system is completely unable to boot or Run the Operating system. In such condition, all the data stored in the hard disk, becomes inaccessible. Generally The Error Messages are displayed as follows:
“Invalid partition table” “Error loading operating system” “Missing operating system"
What Can Be Recovered with the Backup of MBR?
The back up of MBR may help you to get rid of the above Error messages. With the backup, the Following problems can be rectified:
- Error Loading Operating system, due to Corrupted IPL (Initial Program Loader)
- Lost Primary Partition(s)
- Corrupted Partition information
- Invalid Magic Number
Writing the Program to make Backup of MBR:
/* Program to make Backup of MBR */
#include <bios.h>
#include <stdio.h>
int main(void)
{
struct diskinfo_t dinfo; /* Structure to Hold the
information of disk Parameters */
int result;
int count=0;
char filename[80]; /* Stores the File name given by
User */
static char dbuf[512]; /* Data Buffer of 512 Bytes */
FILE *fp;
dinfo.drive = 0x80; /* drive number for First Hard
Disk */
dinfo.head = 0; /* disk head number */
dinfo.track = 0; /* track number */
dinfo.sector = 1; /* sector number */
dinfo.nsectors = 1; /* sector count */
dinfo.buffer = dbuf; /* data buffer */
printf("\n Enter The Filename and path to store the
Backup of MBR \n ");
gets(filename);
// Open The File to Store the MBR Backup \\
if((fp=fopen(filename,"wb"))==NULL)
{
printf("Could not Create File, Press any key to
Exit...");
getch();
exit(0);
}
printf("Attempting to read from Hard disk drive :\n");
//// Read the Specified Disk Sector \\\\
result = _bios_disk(_DISK_READ, &dinfo);
if ((result & 0xff00) == 0)
{
printf("Disk read from hard disk drive :
successful.\n");
/// Write 512 Bytes Of MBR to the File \\\\
while(count<512)
{
fprintf(fp,"%c",dbuf[count] & 0xff );
count++;
}
fclose(fp);
}
else
printf("Cannot read Hard Disk drive, status = 0x%02x\n", result);
return 0;
}
Comments on Program coding:
In the program coding given earlier, basically we are proceeding to perform the following tasks step by step:
- dinfo points to the diskinfo_t structure that contains the information of parameters required by the operation performed by the _bios_disk function.
- Since we want to read first sector of the disk therefore the location of the sector will be as follows:
Parameter |
What it means |
dinfo.drive = 0x80 |
It indicates the Physical drive 80H that is the first Hard disk drive. |
dinfo.head = 0 |
It points to head number 0 |
dinfo.track = 0 |
It points to track 0 |
dinfo.sector = 1 |
First sector of the floppy that is sector 1 |
dinfo.sector = 1 |
>Number of sectors to consider for read operation = 1 |
dinfo.buffer = dbuf |
Data buffer for the operation |
- Open a file stream of user given file name and path to store the backup of MBR of exact 512 bytes. The file name and path is stored in the character array filename.
- _bios_disk(_DISK_READ, &dinfo) reads the first sector of the hard disk (80H), specified by dinfo.
- The status returned, is stored in result that is used to display the message for successful operation or to display an error message on the screen if any error occurs.
Program to Restore the MBR from Backup:
If the MBR is corrupted any how, the program given next helps to restore the MBR Back.
It should always be kept in mind that the illegal use or use in lack of knowledge may of this program, may destroy your data information in the hard disk and may make the entire data inaccessible. You should be sure of what you are going to do. Otherwise you may more complicate the problem.
Program to Restore the MBR from Backup:
The Coding of the program is as follows:
/* Program to Restore the Backup of MBR From the Backup File */
#include <bios.h>
#include <stdio.h>
int main(void)
{
struct diskinfo_t dinfo;
int result;
int count=0;
char filename[80]; /* Stores the File name given
by User */
static char dbuf[512]; /* Data Buffer of 512 Bytes
*/
FILE *fp;
/* Get the user Input for MBR Backup file Path */
printf("\n Enter The Filename and path of Backup File of
MBR \n ");
gets(filename);
if((fp=fopen(filename,"rb"))==NULL)
{
printf("Could not open Backup File, Press any key
to Exit...");
getch();
exit(1);
}
/* MBR data should be of Exact 512 Bytes */
while(count<512)
{
fscanf(fp,"%c",&dbuf[count]);
count++;
}
fclose(fp);
printf("Attempting to Write to Hard disk drive :\n");
dinfo.drive = 0x80; /* drive number for First
Hard Disk */
dinfo.head = 0; /* disk head number */
dinfo.track = 0; /* track number */
dinfo.sector = 1; /* sector number */
dinfo.nsectors = 1; /* sector count */
dinfo.buffer = dbuf; /* data buffer */
result = _bios_disk(_DISK_WRITE, &dinfo);
if ((result & 0xff00) == 0)
{
printf("Restoring the Backup of MBR to The Disk
Sector: successful.\n");
}
else
printf("Cannot Write on Hard Disk drive, status =
0x%02x\n", result);
return 0;
}
Comments on Program coding:
In the program coding given above, basically we are proceeding to perform the following tasks step by step:
- dinfo points to the diskinfo_t structure that contains the information of parameters required by the operation performed by the _bios_disk function.
- Since we want to write on first sector of the disk therefore the location of the sector will be as follows:
Parameter |
What it means |
dinfo.drive = 0x80 |
It indicates the Physical drive 80H that is the first Hard disk drive. |
dinfo.head = 0 |
It points to head number 0 |
dinfo.track = 0 |
It points to track 0 |
dinfo.sector = 1 |
First sector of the floppy that is sector 1 |
dinfo.sector = 1 |
Number of sectors to consider for read operation = 1 |
dinfo.buffer = dbuf |
Data buffer for the operation |
- The file name and path of Backup of MBR, given by the user, is stored in the character array filename. It should be kept in mind that the MBR information should of Exact 512 bytes.
- _bios_disk(_DISK_WRITE, &dinfo) writes the data on the first sector of the hard disk (80H), specified by dinfo.
- The status returned, is stored in result that is used to display the message for successful operation or to display an error message on the screen if any error occurs.
Backup of DBR (DOS Boot Record) and its use
After the partition table, the DOS Boot Record (DBR) or sometimes called DOS Boot Sector is the second most important information on your hard drive.
For a Detailed study about DBR, refer the chapter, “Logical Approach to Disks and OS”, Discussed earlier in this book.
First logical sector of each DOS partition will contain a DOS Boot Record (DBR) or DOS Boot Sector. The job of the DBR is to load the operating system from the hard disk drive into the main memory of computer and give the system’s control to the loaded program.
The DOS Boot Record (DBR) for the first partition on a hard disk is usually found at Absolute Sector 63 (the 64th sector on the disk drive) or in CHS form we can say C–H–S = 0–1–1 for most drives.
However this location may vary depending upon the SPT (Sectors per Track) of the Drive. For example, on an old 245MB drive having only 31 SPT, the Boot Record was located on the 32nd sector (Absolute Sector 31).
The DBR is created by the FORMAT command of DOS, after partitioning is done using the FDISK command. The sector on which DBR resides becomes logical sector 1 of that particular partition for the DOS. The sector number used by DOS starts from the physical sector on which DBR is located.
The DBR contains a small program which is executed by the Master Boot Record (MBR) Executable program. All DOS partitions contain the program code to boot the machine i.e. load the operating system, but only that partition is given control by the Master Boot Record which as specified as active partition, in the partition table entry.
Why Backup DBR:
The DBR contains some important information about the disk geometry. This information is located in the first sector of every partition, such as:
- Jump Code + NOP
- OEM Name and Version
- Bytes Per Sector
- Sectors Per Cluster
- Reserved Sectors
- Number of Copies of FAT
- Maximum Root Directory Entries (but Not Available for FAT32)
- Number of Sectors in Partition Smaller than 32MB (Therefore Not Available for FAT32)
- Media Descriptor (F8H for Hard Disks)
- Sectors Per FAT (In Older FAT Systems and Not Available for FAT32)
- Sectors Per Track
- Number of Heads
- Number of Hidden Sectors in Partition
- Number of Sectors in Partition
- Number of Sectors Per FAT
- FAT Information Descriptor Flags
- Version of FAT32 Drive
- Cluster Number of the Start of the Root Directory
- Sector Number of the File System Information Sector
- Sector Number of the Backup Boot Sector
- Reserved
- Logical Drive Number of Partition
- Extended Signature (29H)
- Serial Number of Partition
- Volume Name of Partition
- FAT Name
- Executable Code
- Executable Marker or Magic Number (AAH 55H)
Generally, the following error messages are displayed on the screen:
“Disk boot failure”
“Non system disk or disk error”
“Invalid system disk or Disk I/O error”
“Replace the disk, and then press any key…”
What can be recovered with the Backup of DBR?
The back up of DBR may help you to get rid of the above Error messages. These Error Messages On the screen wait for the user to put a bootable disk with the above mentioned programs in the floppy drive and press a key.
The drive should be accessible if you boot the system from the bootable floppy or CD. Although the hard disk is not bootable, yet generally that should not affect access to the data of the disk drive. After booting the system with the bootable disk you can access the data.
By restoring the backup of DBR You can overcome the problems generated, as mentioned above.
Programs for Making and Restoring Backups of DBR:
The programs for making the Backups of DBR’s and restoring them are almost similar to the programs of MBR backup and to restore.
For example, if you are going to write the programs for making backup of DBR of First logical drive of the disk and to restore it back, the parameters specified by dinfo structure will be changed as follows:
Parameter |
What it means |
dinfo.drive = 0x80 |
It indicates the Physical drive 80H that is the first Hard disk drive> |
dinfo.head = 1 |
It points to head number 1 |
dinfo.track = 0 |
It points to track 0 |
dinfo.sector = 1 |
First sector of the floppy that is sector 1 |
dinfo.sector = 1 |
Number of sectors to consider for read operation = 1 |
dinfo.buffer = dbuf |
Data buffer for the operation |
Here we see that only the location of the sector to read/write is changed. Here the C-H-S is given as 0-1-1 as the DBR of first logical drive is stored here.
Complete Disk Imaging
This type of backup is getting more and more popular now days and most preferred by such organizations which have very sensitive data in their systems. They people can not take any chance of even a single percent of data loss.
Such organizations take their backups as entire disk image regularly. Though it is some time taking but gives you surety that you will miss nothing. Due to its increasing popularity, programmers have tried their best to make the disk imaging software more and more faster to minimize the time period taken by the imaging process.
Disk imaging is a good Idea because just by spending some tens of minutes you can get the ease of mind that you have backup of everything in your pocket. All of the factors like MBR, BDR, FATs, Root Directories are copied to the destination disk as it is.
What we need for disk imaging is an Identical (or almost Identical) destination hard disk, to our source hard disk in which we have our valuable data. One thing is always kept in mind that the destination disk should not be smaller then the source disk.
After taking the complete image, if you boot the system with the destination disk, in which you have taken the disk image, generally you will get all the data as it is.
Writing the program for complete disk imaging
The program for disk imaging has been given next. The Program uses the INT 13H extensions therefore it can support large disks too.
The program makes the image of first physical hard disk drive (0x80) to the second physical hard disk drive (0x81) therefore before making the backup image you should keep it in mind that all the data in destination disk (0x81) will be overwritten by the data of source disk (0x80) in sector by sector pattern.
The coding of the program has been given next:
/* Program to make the Image of First Hard Disk (0x80) to the second Hard Disk (0x81) */
#include<stdio.h>
#include<dos.h>
#include<conio.h>
/* Structure to be used by getdrivegeometry function using INT 13H Extension, Function Number 0x48. */
struct geometry
{
unsigned int size ; /* (call) size of Buffer */
unsigned int flags ; /* Information Flags */
unsigned long cyl ; /* Number of Physical
Cylinders on Drive */
unsigned long heads ;/* Number of Physical
Heads on Drive */
unsigned long spt ; /* Number of Physical
Sectors Per Track */
unsigned long sectors[2] ; /* Total Number of
Sectors on Drive */
unsigned int bps ; /* Bytes Per Sector */
} ;
/* Structure of Disk Address packet format, To be used by the Functions, readabsolutesectors and writeabsolutesectors */
struct diskaddrpacket
{
char packetsize ; /* Size of Packet, generally 10H */
char reserved ; /* Reserved (0) */
int blockcount ; /* Number of Blocks to Transfer */
char far *bufferaddress ; /* address to Transfer
Buffer */
unsigned long blocknumber[2] ; /* Starting Absolute
Block Number */
} ;
///// Function to get Drive Parameters \\\\\
unsigned long getdrivegeometry (int drive)
{
union REGS i, o ;
struct SREGS s ;
struct geometry g = { 26, 0, 0, 0, 0, 0, 0, 0 } ;
i.h.ah = 0x48 ; /* Function Number 0x48 of INT 13H
Extensions See the Comments
Below */
i.h.dl = drive; /* Drive Number */
i.x.si = FP_OFF ( (void far*)&g ) ;
s.ds = FP_SEG ( (void far*)&g ) ;
/* Invoke the specified function number of INT 13H extension with Segment Register Values */
int86x ( 0x13, &i, &o, &s ) ;
printf("\n Head = %lu, Sectors Per Track = %lu, Cylinder =
%lu\n", g.heads, g.spt, g.cyl);
/* If get drive Geometry function Fails, Display Error Message and Exit */
if(g.spt==0)
{
printf("\n Get Drive Geometry Function Fails....");
printf("\n Extensions Not Supported, Press any Key to
Exit...");
getch();
exit(1);
}
return *g.sectors; /* Return The Number of Sectors
on Drive */
}
////// Start Of Main \\\\\\
void main()
{
unsigned long loop=0, Sectors_in_HDD1=0, Sectors_in_HDD2=0;
unsigned char buffer[61440]; /* Data buffer of 61440
Bytes to Read/Write 120 Sectors of 512 Bytes at a time to save time. */
char choice;
clrscr();
/* If total no. of hard disks attached is less than two Display Error Message and Exit. */
if(((char)peekb(0x0040, 0x0075))<2)
{
printf("\n\n You Must Have At least Two Hard Disks
Attached to your Computer To Run This");
printf("\n Program. Press any Key to Exit... ");
getch();
exit(1);
}
/// Get parameters of First Hard Disk (0x80) \\\
Sectors_in_HDD1 = getdrivegeometry (0x80);
printf(" Total Sectors in First Hard Disk = %lu\n\n",
Sectors_in_HDD1);
/// Get Parameters of Second Hsrd Disk (0x81) \\\
Sectors_in_HDD2 = getdrivegeometry (0x81);
printf(" Total Sectors in Second Hard Disk = %lu\n\n",
Sectors_in_HDD2);
/// First Confirm, Then Proceed \\\
printf("\n All The Data in Second Hard Disk will be
lost !!!");
printf("\n Press \'Y\' to Continue, Else any key to
Exit... ");
choice = getche();
switch(choice)
{
case 'y':
case 'Y':
break;
default:
exit(0);
}
/* Destination should not be smaller than the Source */
if(Sectors_in_HDD2<Sectors_in_HDD1)
{
printf("\n\n Destination Disk should not be Smaller
than Source Disk");
printf("\n Press any Key to Exit...");
getch();
exit(0);
}
/* If Everything is okay, copy All the Sectors of the Source Disk to Destination Hard Disk */
gotoxy(10,15);printf("Copying Absolute Sector: ");
for(loop=0;loop< =Sectors_in_HDD1;loop=loop+120)
{
readabsolutesectors ( 0x80, loop, 120, buffer );
writeabsolutesectors ( 0x81, loop, 120, buffer );
gotoxy(36,15); printf("%ld",loop);
if(kbhit())
{
exit(0);
}
}
//// Show the Message of Completion \\\
printf("\n\n Disk Imaging is Now Completed, Press any Key
To Exit...");
getch();
}
//// End of main
Comments on Coding:
In the coding of the program given earlier, for disk Imaging We are proceeding by performing the Following tasks:
- The Structure, geometry is used by getdrivegeometry function using INT 13H Extension, Function Number 0x48. For a Detailed description on INT 13H Extensions, refer the chapter “Handling large hard disks”, Discussed earlier in this book.
The Data Types representing several parameters of the disk have the following meanings:
Data Type |
Size in Bytes |
Description |
unsigned int size |
2 Bytes |
Size of Buffer |
unsigned int flags |
2 Bytes |
Information Flags |
unsigned long cyl |
4 Bytes |
Number of Physical Cylinders on Drive |
unsigned long heads |
4 Bytes |
Number of Physical Heads on Drive |
unsigned long spt |
4 Bytes |
Number of Physical Sectors Per Track |
unsigned long sectors[2] |
8 Bytes |
Total Number of Sectors on Drive |
unsigned int bps |
2 Bytes |
Bytes Per Sector |
- The structure diskaddrpacket is used by the functions readabsolutesectors and writeabsolutesectors. The format of disk address packet has been given in the following table:
Data Type |
Size in Bytes |
Description |
char packetsize |
1 Byte |
Size of Packet, generally 10H |
char reserved |
1 Byte |
Reserved (0) |
int blockcount |
2 Bytes |
Number of Blocks to Transfer |
char far *bufferaddress |
4 Bytes |
address to Transfer Buffer |
unsigned long blocknumber[2] |
4 Bytes |
Starting Absolute Block Number |
- The getdrivegeometry function is used to get the parameters of specified Drive. The Function getdrivegeometry uses function number 0x48 of INT 13H Extensions.
The meaning of parameters has been described in the table given next:
Parameter |
What it means |
i.h.ah = 0x48 |
Function Number 0x48 of INT 13H Extensions |
i.h.dl = drive |
Drive Number |
i.x.si = FP_OFF ( (void far*)&g ) |
ds:si address to buffer for drive parameters as discussed earlier |
s.ds = FP_SEG ( (void far*)&g ) |
ds:si address to buffer for drive parameters as discussed earlier |
The int86x(0x13, &i, &o, &s) function invokes the interrupt 13H with segment register Values. The getdrivegeometry function returns the total number on drive.
- In the main() function, (char)peekb(0x0040, 0x0075); (the function peekb is Defined in DOS.H) returns the number of hard disks attached to the system.
The number of hard disks connected to the system is represented by the byte stored at memory location 0040H:0075H (Segment 0040H: Offset 0075H). If the number of hard disks connected to the system is less then two program shows the error message and exits.
Sectors_in_HDD1 = getdrivegeometry (0x80); gets the parameters of first hard disk (0x80) and returns the total number of sectors on first hard disk.
Similarly Sectors_in_HDD2 = getdrivegeometry (0x81); gets the parameters of second hard disk (0x81) and returns the total number of sectors on second hard disk.
After confirmation by the user to continue with imaging, first check the condition that the size of source hard disk should not be greater then the size of the destination hard disk. If the destination is smaller, Display the error message and exit.
If everything is going right, copy the sectors of the source disk to the destination disk. Here we are reading and writing 61440 Bytes (120 sectors with each of 512 Bytes) at a time to make the imaging process faster.
If you want to use more sectors at a time, even beyond the limit of 64K, you can do it by using “huge Pointer” in large memory model. The Example of Specification is as follows:
char huge array[100000L];
- The Function, readabsolutesectors ( 0x80, loop, 120, buffer ); reads the 120 sectors of first hard disk (0x80), starting from the sector number specified by unsigned long integer loop and store the data in data buffer.
- The Function, writeabsolutesectors ( 0x81, loop, 120, buffer ); writes the data of data buffer to 120 sectors of second hard disk (0x81), starting from the sector number specified by unsigned long integer loop.
The coding of the functions readabsolutesectors ( ) and writeabsolutesectors ( ) have been given next:
//// Function to read absolute sector(s) \\\\
int readabsolutesectors ( int drive,
unsigned long sectornumber,
int numofsectors,
void *buffer )
{
union REGS i, o ;
struct SREGS s ;
struct diskaddrpacket pp ;
pp.packetsize = 16 ; /* packet size = 10H */
pp.reserved = 0 ; /* Reserved = 0 */
pp.blockcount = numofsectors ; /* Number of sectors
to read */
/* for Data buffer */
pp.bufferaddress = (char far*) MK_FP ( FP_SEG((void
far*)buffer), FP_OFF((void far*)buffer));
pp.blocknumber[0] = sectornumber ; /* Sector number
to read */
pp.blocknumber[1] = 0 ; /* Block number */
i.h.ah = 0x42 ; /* Function Number*/
i.h.dl = drive ; /* Physical Drive Number */
i.x.si = FP_OFF ( (void far*)&pp ) ; /* ds:si for
buffer Parameters */
s.ds = FP_SEG ( (void far*)&pp ) ; /* ds:si for
buffer Parameters */
/* Invoke the specified Function of INT 13H with segment register values */
int86x ( 0x13, &i, &o, &s ) ;
if ( o.x.cflag==1)
return 0 ; /*failure */
else
return 1 ; /* success */
}
//// Function to Write Absolute Sector(s) \\\\
int writeabsolutesectors ( int drive,
unsigned long sectornumber,
int numofsectors,
void *buffer )
{
union REGS i, o ;
struct SREGS s ;
struct diskaddrpacket pp ;
pp.packetsize = 16 ; /* Packet Size = 10H */
pp.reserved = 0 ; /* Reserved = 0 */
pp.blockcount = numofsectors ; /* Number of Sectors
to be written */
/* for Data buffer */
pp.bufferaddress = (char far*) MK_FP ( FP_SEG((void
far*)buffer), FP_OFF((void far*)buffer));
pp.blocknumber[0] = sectornumber ;/* Sector number
to be written */
pp.blocknumber[1] = 0 ; /* Block number = 0 */
i.h.ah = 0x43 ; /* Function Number */
i.h.al = 0x00 ; /* Write Flags, see
comments */
i.h.dl = drive ; /* Physical Drive number*/
/* ds:si for buffer Parameters */
i.x.si = FP_OFF ( (void far*)&pp ) ;
/* ds:si for buffer Parameters */
s.ds = FP_SEG ( (void far*)&pp ) ;
/* Invoke the specified Function of INT 13H with segment register values */
int86x ( 0x13, &i, &o, &s ) ;
if ( o.x.cflag==1)
return 0 ; /* failure */
else
return 1 ; /* success */
}
Comments on Coding:
The parameters used by both the function have the following meanings:
Parameter |
Size in Bytes |
Description |
pp.packetsize = 16 ; |
1 Byte |
Size of packet = 10H |
pp.reserved = 0 ; |
1 Byte |
Reserved = 0 |
pp.blockcount = numofsectors ; |
2 Bytes |
Number of sectors to read |
pp.bufferaddress = (char far*) MK_FP ( FP_SEG((void far*)buffer), FP_OFF((void far*)buffer)); |
----- |
for Data buffer or Transfer Buffer |
pp.blocknumber[0] = sectornumber ; |
4 Bytes |
Sector number to read/write (generally, we need only this). Only alone This can support up to 2.1 Terabytes. |
pp.blocknumber[1] = 0 ; |
4 Bytes |
Block number. Use this, If accessing the disk of greater then 2.1 Terabytes in size. |
i.h.ah = 0x42 ; or i.h.ah = 0x43 ; |
2 Bytes |
Function Number of INT 13H Extensions |
i.h.al = 0x00 ; |
1 Byte |
Write Flags used in write function only,00H, 01H are used for Write Without Verify and 02H is used for write with verify |
i.h.dl = drive ; |
2 Bytes |
Physical Drive Number |
i.x.si = FP_OFF ( (void far*)&pp ) ; |
------ |
ds:si for buffer Parameters |
s.ds = FP_SEG ( (void far*)&pp ) ; |
------ |
ds:si for buffer Parameters |
int86x ( 0x13, &i, &o, &s ) ; |
------ |
Invoke the specified Function of INT 13H with segment register values |
Page Modified on: 15/01/2022