tags:

views:

42

answers:

2
+1  A: 

You are trying to clear logical device E: and not physical device. Try doing the following:

call CreateFile() WinAPI function to open "\\.\PhysicalDriveX" where X is the number of the device (see Remarks in description of CreateFile function for information about how to open the physical device properly). Then use WriteFile API function to write 512 bytes at offset 0 of the opened device.

If you get permission denied error when opening the device for writing, you can take our RawDisk product (trial version will work fine for you) which lets one bypass this security measure of Windows.

upd: As for calling CreateFile from C#, see PInvoke.net.

Eugene Mayevski 'EldoS Corp
+1  A: 

There are two ways to format a USB drive, from Windows standpoint:

  • As a floppy disk. In this case entire USB drive contains a single file system, and its boot record is located in sector 0.

  • As a hard drive. In this case, sector 0 contains MBR with partition table. Actual file system(s) with their individual boot records are located further on the drive.

I think you are observing the second case. Using \.\E: to identify the device, you end up accessing file system's boot record instead of MBR.

Here is how you can access sector 0 of the USB drive.

  1. Load WinObj from here.
  2. In WinObj, under GLOBAL??, find E:. It will be a SymbolicLink pointing to something like \Device\Harddisk2\DP(1)0-0+30.
  3. Under GLOBAL??, find a PhysicalDrive# symlink referring to the same Harddisk# that you found on step 2. Most probably it will have the same numeric suffix as Harddisk#. E.g.: SymbolicLink PhysicalDrive2 refers to \Device\Harddisk2\DR47.
  4. Use the PhysicalDrive# you've found in DD command:

    dd bs=512 count=1 if=\\.\PhysicalDrive2 of=mbr.dat

atzz