Writing direct to hard disk in windows XP

Not open for further replies.

i have written a boot loader and a seperate installer to write it to the first sector of the hard disk. this is dos based and works fine when run in native dos. however, seeing as times have changed and windows xp is the latest and greatest (allegedly) i have decided it's time to re-write the installer for windows. all i need to do is write my 512 byte binary bootloader file directly to the first sector of the disk. simple

the problem is, windows xp doesn't like direct writes to the disk. does anyone know how to get around this? according to the microsoft site direct writes are allowed (as long as you are a system admin), you simply create a handle using createfile () and then read/write with readfile () and writefile () but i have had no success just yet. i take it this is a security problem as the same code works fine on floppy disks.

if i could find a decent windows reference, i'm sure i could figure it out in a few minutes, but microsoft seem to like hiding information which tells you how their software works.

any help is appreciated




Posts: 480   +0
What is it that you want to do that you are using your bootloader ? ?
Are you planning on running 2 or more OS's ?
More info.

patio. :cool:


Posts: 6,452   +3
You probably overlooked that XP partitions are mostly in NTFS format.
DOS has no access to NTFS, so get a util that can write on NTFS.


Posts: 5,452   +7
Nobby does not want to write to any partitions.
He wants to get access to the bootsector of a HD from Windows from his own program.


Posts: 6,452   +3
See if this helps:

Also saw this, if it is of any help:
Under Windows NT/2K/XP, you cannot access hard disks using I/O ports NOR using the BIOS int 13h. The only way to access hard disk is using the CreateFile() function to create a handle to the physical disk you wish to open, and then use ReadFile() and Writefile() to read and write, respectively. Pass "\\.\PHYSICALDISKx" as the filename argument to CreateFile, where x is the physical disk number.
  • Thread Starter Thread Starter
  • #6
Hi thanks for the replies

it was mainly curiousity to write the bootloader but i might now make it into a nice little multi OS booter - I had this old dos assembler book which told you how the computer booted - what address the bootloader must jump to and exactly how BIOS boots the OS etc and i thought i'd write one. i used the old int 13h functions to write the program to the boot sector originally and it worked a treat back in the DOS days :)

that's the info that's on the microsoft site that i read too. about using createfile () and writefile () but it returns some error to do with networking when you call writefile ()! (i can't remember the error exactly) so i just presumed it was windows security stopping me writing it. and with good reason i suppose, i mean you don't want things writing direct to the disk really especially with all the malicious code that's about nowadays.

thanks for the link too i shall have a read

Not open for further replies.