Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Writing directly on a harddisk without using File

Writing directly on a harddisk without using File

Scheduled Pinned Locked Moved C / C++ / MFC
securityhelpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    Hi all, How can we write at a given sector in my hard disk? I have tried it using this code but nothing happens

    HANDLE hFile ;
    DWORD dwResult;

    hFile  = CreateFile (L"\\\\\\\\.\\\\PhysicalDrive3",
    				   GENERIC\_WRITE,
    				   0,                      // do not share
                       NULL,                   // default security
                       CREATE\_ALWAYS,          // overwrite existing
                       FILE\_ATTRIBUTE\_NORMAL,  // normal file
                       NULL);  
    WriteFile (hFile, TEST\_STR, strlen(TEST\_STR), &dwResult, NULL);
    

    Can anybody help me in this? Thanks in advance

    To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

    M R 2 Replies Last reply
    0
    • L Le rner

      Hi all, How can we write at a given sector in my hard disk? I have tried it using this code but nothing happens

      HANDLE hFile ;
      DWORD dwResult;

      hFile  = CreateFile (L"\\\\\\\\.\\\\PhysicalDrive3",
      				   GENERIC\_WRITE,
      				   0,                      // do not share
                         NULL,                   // default security
                         CREATE\_ALWAYS,          // overwrite existing
                         FILE\_ATTRIBUTE\_NORMAL,  // normal file
                         NULL);  
      WriteFile (hFile, TEST\_STR, strlen(TEST\_STR), &dwResult, NULL);
      

      Can anybody help me in this? Thanks in advance

      To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

      M Offline
      M Offline
      Maxwell Chen
      wrote on last edited by
      #2

      I wrote some small tool to read and write HDD sectors 6 years ago under WinXP. If I recall correctly, the buffer has to fit the size of a sector (or n folds, aka: N * 512 bytes). Otherwise it rejects and nothing will happen.

      Maxwell Chen

      1 Reply Last reply
      0
      • L Le rner

        Hi all, How can we write at a given sector in my hard disk? I have tried it using this code but nothing happens

        HANDLE hFile ;
        DWORD dwResult;

        hFile  = CreateFile (L"\\\\\\\\.\\\\PhysicalDrive3",
        				   GENERIC\_WRITE,
        				   0,                      // do not share
                           NULL,                   // default security
                           CREATE\_ALWAYS,          // overwrite existing
                           FILE\_ATTRIBUTE\_NORMAL,  // normal file
                           NULL);  
        WriteFile (hFile, TEST\_STR, strlen(TEST\_STR), &dwResult, NULL);
        

        Can anybody help me in this? Thanks in advance

        To accomplish great things, we must not only act, but also dream; not only plan, but also believe.

        R Offline
        R Offline
        raja jamwal
        wrote on last edited by
        #3

        Well unfortunately Windows OS after 2000 or may be NT wouldn't allow you this, check out my post here http://cyberlifeday.blogspot.com/2009/12/booting-windowslinux-os-any.html in brief to do same, you'll need to change drive letter to A: or B:, read the post for reason and behind the scenes. :)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups