Author Topic: [C#] Raw Disk Access  (Read 803 times)

0 Members and 1 Guest are viewing this topic.

Offline xor

  • Peasant
  • *
  • Posts: 59
  • Cookies: 32
    • View Profile
[C#] Raw Disk Access
« on: September 17, 2015, 10:13:34 am »
If attempting to access the raw data on your drive using File or FileStream, you will quickly encounter a message that you are not allowed to access drives starting with \\.\

By using the Kernel32.dll CreateFile import and C# SafeFileHandle, we are able to bypass this limitation.
The code below accesses the first 512 bytes of Physical Drive 0 as Read Only.
You can adapt this for your own needs, if you need to write to the drive, or see more data.

Note: You may need to run this with administrator access.

http://pastebin.com/j7Jhrzsr

-- xor

« Last Edit: September 17, 2015, 10:14:45 am by xor »