Thread: read raw from the hd

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

    read raw from the hd

    Is there a way to read the bytes directly from the harddrive? I mean the FS, dirt, "deleted" stuff and everything.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    This looks promising:
    http://support.microsoft.com/kb/100027

    gg

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Cool, thanks; I didn't think it'd be that easy.

  4. #4
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    GetLastError after a failed call to DeviceIoControl returns 5 (access denied).

    How do I get permission to access the harddrive?

    I am running the program under an admin account.
    Last edited by Yarin; 03-27-2008 at 12:33 PM.

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Yarin View Post
    GetLastError after a failed call to DeviceIoControl returns 5 (access denied).

    How do I get permission to access the harddrive?

    I am running the program under an admin account.
    Are you on Vista, where "administrator" isn't really "administrator" anymore?

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You must also not have mounted the drive. So if you are trying to access a drive that you can "see" in Windows, it's not going to allow you access.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    And what IOCTL are you attempting?

    gg

  8. #8
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by matsp View Post
    You must also not have mounted the drive. So if you are trying to access a drive that you can "see" in Windows, it's not going to allow you access.
    Windows always mounts all drives it recognizes, so that's probably the case...
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  9. #9
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    >> Are you on Vista, where "administrator" isn't really "administrator" anymore?
    No, XP. But tell more about this.

    >> You must also not have mounted the drive. So if you are trying to access a drive that you can "see" in Windows, it's not going to allow you access.
    Okay, that's probably it, I'll try doing that first.

    >> And what IOCTL are you attempting?
    DISK_GET_DRIVE_LAYOUT

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Yarin View Post
    >> Are you on Vista, where "administrator" isn't really "administrator" anymore?
    No, XP. But tell more about this.
    You know about UAC, right?
    It means then unless the application asks for admin privileges, you don't have them. This is true for administrator accounts, too.
    So running your app with UAC enabled on Vista would guarantee failure because you would be running it as a limited user unless you specified in the manifest to run it as admin or disabled UAC.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Access it through a system service, they run in session 0 if installed form the admin acount. Don't use vista, they broke a lot of the security stuff in an effort to make it harder to write applications that perform useful work.

  12. #12
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    I found another way to enumerate the partitions, but now when I use CreateFile on "\\.\C:", ReadFile failed. It seems I can't do it like that. When I said read raw from the hd, I literally meant read EVERYTHING, like a disk defragmentor.

  13. #13
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by Yarin View Post
    I found another way to enumerate the partitions, but now when I use CreateFile on "\\.\C:", ReadFile failed. It seems I can't do it like that. When I said read raw from the hd, I literally meant read EVERYTHING, like a disk defragmentor.
    That's usually done by drivers...
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Yarin View Post
    I found another way to enumerate the partitions, but now when I use CreateFile on "\\.\C:", ReadFile failed. It seems I can't do it like that. When I said read raw from the hd, I literally meant read EVERYTHING, like a disk defragmentor.
    I'm pretty sure that a disk defragmentor uses another interface than "read raw disk data".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #15
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Quote Originally Posted by Yarin View Post
    I found another way to enumerate the partitions, but now when I use CreateFile on "\\.\C:", ReadFile failed. It seems I can't do it like that. When I said read raw from the hd, I literally meant read EVERYTHING, like a disk defragmentor.
    Defragmentor with source code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can I know the actual bytes read in a file read
    By pliang in forum C++ Programming
    Replies: 1
    Last Post: 06-08-2005, 04:23 PM
  2. What Would You Use To Read User Input?
    By djwicks in forum C Programming
    Replies: 11
    Last Post: 04-05-2005, 03:32 PM
  3. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  4. Read Array pro!!Plz help!!
    By Supra in forum C Programming
    Replies: 2
    Last Post: 03-04-2002, 03:49 PM
  5. Help! Can't read decimal number
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 09-07-2001, 02:09 AM