Page 1 of 1

Writing bootsectors etc. in Windows x64

Posted: Tue Dec 27, 2005 9:02 pm
by Cjmovie
If you remember a while back, I asked for help regarding writing to floppys in Windows XP x64 edition...Ported versions of dd did not work, partcopy did not work, and debug was 16-bit (as in, not useable). I ended up with a very limited program that could only write 1.44mb image files.

So, I have started work on a 100% partcopy compatable program that will work in Windows XP Pro x64 Edition. So far it has worked fine. I have written directly to drives (both hard drives and floppys) without trouble.
I didn't test the hard drive one on purpose..apparently //./PHYSICALDRIVE0 maps to hard drive 1 if you forgot to plug your floppy drive back in ;). So I had to boot into dos prompt and (lucky I had it!) restore my bootsector for windows XP (also note, for some reason, fixboot doesn't work....helps none)

Anyways, if you'd be interested in me finishing it (in its current state it works as much as _I_ need it to) I'd be willing to.....

And also, although this is not directly related to OS development, it plays a large role in it, which is why I decided to put it in this forum. If admins decide to move it, that's fine :).

Re:Writing bootsectors etc. in Windows x64

Posted: Wed Dec 28, 2005 6:28 am
by kataklinger
I wrote hdd bootsector installer, but when I run it and write new bootsector Windows restores old one it after a while. >:(
Does anybody knows how to fix this?

Re:Writing bootsectors etc. in Windows x64

Posted: Wed Dec 28, 2005 7:49 am
by Kemp
Windows probably sees it as corrupted (which it has been from Windows' viewpoint) and restores it from the backup boot sector (sector 6 or somesuch IIRC, though I may be wrong).

Re:Writing bootsectors etc. in Windows x64

Posted: Wed Dec 28, 2005 2:08 pm
by Cjmovie
Sector 6? I don't think that's right....
FAT partitions have no pre-defined backup of the bootsector. Instead it's only stored somewhere deep inside your windows installation CD...:)

However, on NTFS partitions, a copy of the first sector _is_ stored. In older versions of ntfs it is at the exact center of the logical drive. In newer versions of ntfs (NTFS5, for example, IIRC) it is stored at the end of the logical volume.

Re:Writing bootsectors etc. in Windows x64

Posted: Wed Dec 28, 2005 4:38 pm
by Kemp
Offset 50, 2 bytes, what MS call the BPB_BkBootSec field:
This field is only defined for FAT32 media and does not exist on FAT12 and FAT16 media. If non-zero, indicates the sector number in the reserved area of the volume of a copy of the boot record. Usually 6. No value other than 6 is recommended.
Another feature on FAT32 volumes that is not present on FAT16/FAT12 is the BPB_BkBootSec field. FAT16/FAT12 volumes can be totally lost if the contents of sector 0 of the volume are overwritten or sector 0 goes bad and cannot be read. This is a ?single point of failure? for FAT16 and FAT12 volumes. The BPB_BkBootSec field reduces the severity of this problem for FAT32 volumes, because starting at that sector number on the volume?6?there is a backup copy of the boot sector information including the volume?s BPB.

[...]

This second case?sector 0 goes bad?is the reason why no value other than 6 should ever be placed in the BPB_BkBootSec field. If sector 0 is unreadable, various operating systems are ?hard wired? to check for backup boot sector(s) starting at sector 6 of the FAT32 volume.

Re:Writing bootsectors etc. in Windows x64

Posted: Wed Dec 28, 2005 5:49 pm
by kataklinger
Thanks, I'll try to rewrite backup boot sector too.

Re:Writing bootsectors etc. in Windows x64

Posted: Wed Dec 28, 2005 5:56 pm
by Kemp
You should probably read the full information in the specs before you do that, the information I gave was quite abbreviated and missing out a few important notes and stuff. Hope this helps.

Re:Writing bootsectors etc. in Windows x64

Posted: Wed Dec 28, 2005 6:11 pm
by kataklinger
Yes, I remeber I read about location of bootsector backup in BPB. I'll try, it cannot hurt anyway but I'm going to ret FAT32 spec once more. :P