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. Access harddisk

Access harddisk

Scheduled Pinned Locked Moved C / C++ / MFC
c++questionlearning
8 Posts 4 Posters 1 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.
  • S Offline
    S Offline
    Scozturk
    wrote on last edited by
    #1

    Hi! Is there anyway to access the harddisk in byte mode? I mean I want to get the bytes and modify them or delete them for real... I found some examples for the assembly language... well is it possible with c++ without mfc? Thank you very much for your answers in advance! Well... I am a beginner ...

    A D 2 Replies Last reply
    0
    • S Scozturk

      Hi! Is there anyway to access the harddisk in byte mode? I mean I want to get the bytes and modify them or delete them for real... I found some examples for the assembly language... well is it possible with c++ without mfc? Thank you very much for your answers in advance! Well... I am a beginner ...

      A Offline
      A Offline
      Anthony_Yio
      wrote on last edited by
      #2

      You can mix your assembly codes into your C++ codes like

      ULONG ulReturn = 0x00000000;
      __asm
      {
      mov eax, ulReturn
      ................

        mov ulReturn, eax
      

      }

      Don't you like C++ for this. :) Sonork 100.41263:Anthony_Yio

      S 1 Reply Last reply
      0
      • A Anthony_Yio

        You can mix your assembly codes into your C++ codes like

        ULONG ulReturn = 0x00000000;
        __asm
        {
        mov eax, ulReturn
        ................

          mov ulReturn, eax
        

        }

        Don't you like C++ for this. :) Sonork 100.41263:Anthony_Yio

        S Offline
        S Offline
        Scozturk
        wrote on last edited by
        #3

        Wow... I didn't know that! Thanks a lot! Well... I am a beginner ...

        1 Reply Last reply
        0
        • S Scozturk

          Hi! Is there anyway to access the harddisk in byte mode? I mean I want to get the bytes and modify them or delete them for real... I found some examples for the assembly language... well is it possible with c++ without mfc? Thank you very much for your answers in advance! Well... I am a beginner ...

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Accessing the disk directly is not possible on NT-based machines. Goggle for HAL to see why/how it keeps non ring-0 applications from accessing the hardware. You can create a driver to do this, however, but that is not a trivial task.


          "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

          B 1 Reply Last reply
          0
          • D David Crow

            Accessing the disk directly is not possible on NT-based machines. Goggle for HAL to see why/how it keeps non ring-0 applications from accessing the hardware. You can create a driver to do this, however, but that is not a trivial task.


            "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

            B Offline
            B Offline
            bikram singh
            wrote on last edited by
            #5

            "directly" is ambigious, i think. Under NT, it is much easier to access a hard disk than it is in Win 9x. All you need to do is call the CreateFile() function with a "filename" of \\.\PHYSICALDRIVE0 for the first physical hdd and so on, or for logical drives: \\.\C: You can read (not write), data using the ReadFile() function. Writing would need a device driver. Under 9x, you cannot use this method. You have to revrt to using the INT13 or INT13 Extended functions for the purpose. And that means writing a 16-bit VxD in VC++ 2.x or Borland C++. Bikram Singh

            D 1 Reply Last reply
            0
            • B bikram singh

              "directly" is ambigious, i think. Under NT, it is much easier to access a hard disk than it is in Win 9x. All you need to do is call the CreateFile() function with a "filename" of \\.\PHYSICALDRIVE0 for the first physical hdd and so on, or for logical drives: \\.\C: You can read (not write), data using the ReadFile() function. Writing would need a device driver. Under 9x, you cannot use this method. You have to revrt to using the INT13 or INT13 Extended functions for the purpose. And that means writing a 16-bit VxD in VC++ 2.x or Borland C++. Bikram Singh

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              hDriver = CreateFile("\\\\.\\physicaldrive0", ...) uses a generic symbolic link to get access to the driver that represents the first physical drive. bikram singh wrote: You can read ... data using the ReadFile() function. Certainly you can. ReadFile(hDriver, &data, 512, &dwRead, NULL) will work just fine for reading the MBR of the first physical drive. Access to PhysicalDrivexx devices is restricted to administrator-level accounts. To bypass HAL (e.g., virus scanner) would require a device driver.


              "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

              B 1 Reply Last reply
              0
              • D David Crow

                hDriver = CreateFile("\\\\.\\physicaldrive0", ...) uses a generic symbolic link to get access to the driver that represents the first physical drive. bikram singh wrote: You can read ... data using the ReadFile() function. Certainly you can. ReadFile(hDriver, &data, 512, &dwRead, NULL) will work just fine for reading the MBR of the first physical drive. Access to PhysicalDrivexx devices is restricted to administrator-level accounts. To bypass HAL (e.g., virus scanner) would require a device driver.


                "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

                B Offline
                B Offline
                bikram singh
                wrote on last edited by
                #7

                DavidCrow wrote: Certainly you can. ReadFile(hDriver, &data, 512, &dwRead, NULL) will work just fine for reading the MBR of the first physical drive. It works for for any sector on the hard disk. Except the ones the hdd controller has marked as "bad" in it's cmos memory. DavidCrow wrote: Access to PhysicalDrivexx devices is restricted to administrator-level accounts. To bypass HAL (e.g., virus scanner) would require a device driver. Thats true. Win some, lose some! ps. have you worked on a FSFD? When I made mine, I was just so totally confused! The IFS DDK I dont have access to, so it was a really jittery experience! Bikram Singh

                D 1 Reply Last reply
                0
                • B bikram singh

                  DavidCrow wrote: Certainly you can. ReadFile(hDriver, &data, 512, &dwRead, NULL) will work just fine for reading the MBR of the first physical drive. It works for for any sector on the hard disk. Except the ones the hdd controller has marked as "bad" in it's cmos memory. DavidCrow wrote: Access to PhysicalDrivexx devices is restricted to administrator-level accounts. To bypass HAL (e.g., virus scanner) would require a device driver. Thats true. Win some, lose some! ps. have you worked on a FSFD? When I made mine, I was just so totally confused! The IFS DDK I dont have access to, so it was a really jittery experience! Bikram Singh

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  bikram singh wrote: It works for for any sector on the hard disk. Except the ones the hdd controller has marked as "bad" in it's cmos memory. My bad. I read your earlier post as "You can not read..." which is why I was providing an example that showed otherwise. I'll need to not be so quick with my trigger finger! :-O


                  "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

                  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