Program to modify the values of partition table entry of MBR

Files Recovery Software
Home Contact Details Customer Support Download Demo Products  

 
 

Modify MBR by Programming

The sample program to show, how we can modify the values of MBR partition table entry has been given below. The program modifies the values second partition entry of MBR partition table.

The coding of the program has been given below:

/* Program to modify the values of partition table entry of MBR */

# include <bios.h>

/* structure to read the partition entry from partition table */

struct partition
{
unsigned char bootable ; /* Active Partition Byte */
unsigned char start_side ; /* Starting Head */
unsigned int start_sec_cyl ; /* combination of Starting sector and cylinder number */
unsigned char parttype ; /* File system Indicator Byte */
unsigned char end_side ; /* Ending Head */
unsigned int end_sec_cyl ; /* combination of Starting sector and cylinder number */
unsigned long part_beg ; /* Relative Sector Number */
unsigned long plen ; /* Partition length in sectors */
} ;

/* Structure to read MBR */

struct part
{
unsigned char master_boot[446] ; /* IPL (Initial Program Loader)*/
struct partition pt[4] ; /* Partition table*/
int lasttwo ; /* Magic Number */
} ;

struct part p ;

void main()
{
unsigned int t1,t2;
clrscr();

biosdisk ( 2, 0x80, 0, 0, 1, 1, &p ) ;
display(); /* display the partition Table information */

getch();

/* Let us assume that we want to modify the partition information of second partition entry from partition table of MBR, with these values */

p.pt[1].bootable = 0x80; /* Active Boot Partition */

p.pt[1].parttype = 0x7; /* NTFS Partition */

p.pt[1].start_side = 0; /* Starting Head =0 */

p.pt[1].end_side = 31; /* Ending Head == 31 */

p.pt[1].part_beg = 808416;/* Relative Sector = 808416 */

p.pt[1].plen = 405216; /* Total Sectors in Partition = 405216 */

Previous page

page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13

Next page

 

 
 
Data Recovery Book
 
Chapter 1 An Overview of Data Recovery
Chapter 2 Introduction of Hard Disks
Chapter 3 Logical Approach to Disks and OS
Chapter 4 Number Systems
Chapter 5 Introduction of C Programming
Chapter 6 Introduction to Computer Basics
Chapter 7 Necessary DOS Commands
Chapter 8 Disk-BIOS Functions and Interrupts Handling With C
Chapter 9 Handling Large Hard Disks
Chapter 10 Data Recovery From Corrupted Floppy
Chapter 11 Making Backups
Chapter 12 Reading and Modifying MBR with Programming
Chapter 13 Reading and Modifying DBR with Programming
Chapter 14 Programming for “Raw File” Recovery
Chapter 15 Programming for Data Wipers
Chapter 16 Developing more Utilities for Disks
Appendix Glossary of Data Recovery Terms
 
 
Pro Data Doctor

Home

Products

Contact Details

Customer Support

Download Demo

Terms and Conditions

 
Pro Data Doctor