EvilZone

Programming and Scripting => .NET Framework => : xor September 17, 2015, 10:13:34 AM

: [C#] Raw Disk Access
: xor 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