MBR

MBR stands for Master Boot Record of disk.
To facilitate the understanding, MBR is divided into generalization and narrow sense. The generalized includes the whole sector (boot loader, partition table and separation mark). That is Master Boot Record. And the narrow sense of MBR only means boot program.
In a hard disk, Cylinder 0, Head 0 and Sector 1 are called Master Boot Sector (also called MBR) that contains Boot Loader, DPT (Disk Partition Table) and valid sign of hard disk (55AA). In the Master Boot Sector of 512 bytes, Boot Loader take up 446 bytes and the second part Disk Partition Table (DPT) takes up 64 bytes. And the number of partitions and the size of every partition are all recorded in this part.the third part is magicnumber, taking up 2 bytes and fixed to 55AA.

Note:
MBR does not belong to any operating system and it can not be read through disk commands provided by operating system. But it can be modified and re-written through the command. For example, in minix3, the small routine masterboot can be written into MBR through the command installboot -m /dev/c0d0 /usr/mdec/masterboot. Assembly language is often applied to write masterboot. The NO.2 function of INT13H provided by ROM-BIOS can be applied to read the content of the sector. And DISKEDIT.EXE in Norton8.0 can also be used. However, if MRB fails, and users can not enter the operating system, the MRB recovery function of MiniTool Partition Wizard can be applied to solve the problem.



MiniTool Partition Wizard is free for individual and family users. The newest edition can be downloaded in MiniTool Partition Wizard Download Center

Calling Parameter
The calling parameters for disk sectors read of INT13H are following:
Entry: AH=2(appointing function code)
AL=number of sectors need to read
DL= disk number (0, 1-floppy; 80, 81- hard disk)
DH= head number
CL 2 bytes high +CH=Cylinder number
CL6 bytes low=sector number
CS:BX= memory buffer address for storage of data read
Outlet parameters: CS:BX= read data storage address  
Error massage: if error occurs, CF=1 AH=error code.
The operations of DEBUG to read data located in Cylinder0, Head 0 and Sector 1 are following:
  A>DEBUG
  -A 100
XXXX:XXXX MOV AX,0201 (applying function code 2 to read one sector)
XXXX:XXXX MOV BX,1000 (the address for storing the read-data in buffer area is CS:1000)
  XXXX:XXXX MOV CX,0001 (read Cylinder 0,Sector 1)
  XXXX:XXXX MOV DX,0080 (Head 0 appointing the first physicaldisk)
  XXXX:XXXX INT 13
  XXXX:XXXX INT 3
  XXXX:XXXX (press 'Enter")
  -G=100 (execute the program segment above)
  -D 1000 11FF (display the MBR content of 512bytes)
In windows operating system such as XP, 2003, Vista, Windows7, there is an interface provided by Microsoft to directly read MBR:
  FILE * fd=fopen("\\\\.\\PHYSICALDRIVE0","rb+");
  char buffer[512];
  fread(buffer,512,1,fd);
  //then you can edit buffer[512] as your wish......
  fseek(fd,0,SEEK_SET); // (very important)
fwrite(buffer,512,1,fd); //( write the modified MBR into computer)
  fclose(fd); //(finished)

Components of MBR
The Master Boot Record (MBR)of a disk is composed of 4 parts shown in picture 6-15.
1. Master Boot program (offset address 000H-0088H): It is responsible for installation and operation of system boot program.
2. Error massage data area: Offset address 0089H-00E1H is error massage and 00E2H-01FDH are all 0 byte.
3. DPT (Disk Partition Table) contains 4 partition entries, (offset address 01BEH-01FDH), and every partition entry is 16 bytes. And 64 bytes are divided into Partition Entry 1, Partition Entry 2, Partition Entry3, and Partition Entry 4.
4. End mark: Its offset address is 01FE-01FF and it is 55AA of 2 bytes. If the mark is wrong, the system can not be started.
Publisher, webmasters and all viewers are allowed to reprint all useful articles on our site freely.
But note that you must add the following credit information to anywhere that you put our website resources:
"Article reprint is permitted by www.data-recovery-app.com" and a hyperlinke back to http://www.data-recovery-app.com is required.