TechSpot

Writing direct to hard disk in windows XP

By nobby_trussin
Apr 22, 2005
Topic Status:
Not open for further replies.
  1. Hi,

    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

    thanks

    Dan
     
  2. patio

    patio TS Maniac Posts: 700

    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:
     
  3. RealBlackStuff

    RealBlackStuff TS Rookie Posts: 8,165

    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.
     
  4. Nodsu

    Nodsu TS Rookie Posts: 9,431

    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.
     
  5. RealBlackStuff

    RealBlackStuff TS Rookie Posts: 8,165

    See if this helps:
    http://www.osronline.com/lists_archive/ntfsd/thread2157.html

    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.
     
  6. nobby_trussin

    nobby_trussin TS Rookie Topic Starter

    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

    Dan
     
Topic Status:
Not open for further replies.


Add New Comment

TechSpot Members
Login or sign up for free,
it takes about 30 seconds.
You may also...


Get complete access to the TechSpot community. Join thousands of technology enthusiasts that contribute and share knowledge in our forum. Get a private inbox, upload your own photo gallery and more.