Documente Academic
Documente Profesional
Documente Cultură
Cs609@vu.edu.pk
Lecture # 29
3F 1388AFC 0390620A
3F 1388AFC
Logical Logical Extended Partition
Drive Drive
1388B3B
2711676H
3A9A1B1H
Above slides shows the information collected as yet which indicates the logical drive
there starting LBA blocks, the number of block , the hidden blocks etc. The following
slide shows the contents of the data part of partition table of the last extended partition.
skipped
It has just one data entry for the logical drive indicating that this is the partition table in
the chain. The detail of the contents this partition table are shown below.
First Partition
System ID = 07 = Windows FAT32 partition
first block = 3F
First block physical address = 3F + 01388b3b +1388b3b +
1388b3b (Blocks in previous partions)
No. of blocks = 011f4b55
end cylinder# = 1023
end sec # = 63 indicating a LBA disk
Second Partition
System ID = 0 = Unused
The following slide shows the summary of all the data collected as yet depicting 4 logical
drives and the number of blocks within.
3F 3F 3F 3F
Null
#include <dos.h>
#include <bios.h>
struct DA P
{ unsigned char size;
unsigned char reserved1;
unsigned char blocks;
unsigned char reserved2;
unsigned char far *buffer;
unsigned long int lbalod;
unsigned long int lbahid;
} dap ;
struct PartEntry
{ unsigned char BootableFlag;
unsigned char StartHead;
unsigned char StartSector;
unsigned char StartCylinder;
unsigned char SystemID;
unsigned char End Head ;
unsigned char End Sector;
unsigned char EndC ylinder;
unsigned long AbsBegin;
unsigned long SectCount;
};
struct PartTable
{
unsigned char code [446];
struct PartEntry e[4];
unsigned int signature;
};
struct DA P dap ;
void ReadLBA (unsigned int drive,
unsigned long int lbalo, unsigned long int lbahi,
unsigned char far * buffer, int nsects)
{
dap.lbalod = lbalo ;
dap.lbahid=lbahi;
dap.size=16;
dap.reserved1=0;
dap.blocks=nsects;
dap.reserved2=0;
dap.buffer =buffer;// (unsigned char far *)MK_FP(_DS,buf);
_AH=0x42;
_DL=drive;
_SI=(unsigned int)&dap;
geninterrupt(0x13);
}
void m ain ()
{
GetPart(0x80,0,0) ;
}
Above is a listing of a simple program that reads the partition table using the extended
13H services. It then displays the contents of the data part of the partition table read. For
this purpose it uses various data structures designed in reflection of the partition table and
16 bytes data entries within. The program uses recursion and calls the getpart() function
recursively whenever it finds an extended partition to read the data within the extended
partition table.
The partition table data entry also stores the CHS address of the starting block. But this
address is left insignificant if a LBA enable disk is in question. However LBA address
can be used in place of the CHS address, and in case CHS address is required it can be
calculated if the total number of tracks, sectors and heads are known. To get the total
number of tracks, sectors and head the above described service can be used.