tags:

views:

56

answers:

3

how do you read mbr and partition table from the hard disk and edit it? I want to know exactly how do the partition recovery softwares work?

+1  A: 

Get the sources of fdisk.

Pascal Cuoq
+1  A: 

Start by reading up on BIOS interrupt calls, e.g. here: http://en.wikipedia.org/wiki/INT_13

BIOS is probably the closest access you can normally get to hardware - it lives even below the OS and provides, amongst other things, raw disk access.

Piskvor
+2  A: 

Please see here on what MSDN has to say about 'CreateFile', somewhere down on the page titled 'Physical Disks and Volumes', and see on the KB about this. You would have to make calls to 'DeviceIoControl'.

The partition and MBR is part of the boot sector found at the first sector of the disk, i.e. sector 0.

Be careful! Messing with the partitions will end up losing the data. Don't say you were warned!

If you want to access the disk physically prior to Windows starting up, look at Ralph Brown's interrupt list for Int 0x13 (hexadecimal) to do direct Disk I/O. There are some excellent open source software such as 'fdisk', 'cfdisk', 'gnuparted' that will explain how it works. - Use the source luke...

Hope this helps, Best regards, Tom.

tommieb75
"Don't say you were warned!" -> You probably mean to say "Don't say you were not warned!"
PhiS
@PhiS: lol. Actually...you just confused me there with the idiosyncrasis of the English language....lol...yeah I guess you're write right? :)
tommieb75