Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I read a disk directly with .Net?

Tags:

.net

winapi

disk

Is is possible to read a disk directly with .Net? By directly I mean via the device bypassing the file system. I think I would go about this by opening the device some way "\Device\Ide\IdeDeviceP2T0L0-1" for example.

If I can't open the device with a .NET api knowing which Win32 API to use would be helpful.

like image 492
Darryl Braaten Avatar asked Sep 01 '08 17:09

Darryl Braaten


1 Answers

CreateFile has support for direct disk access. Read the notes under "Physical Disks and Volumes". You should be able to P/Invoke the call.

Note that Vista and Server 2008 have severely restricted this.

like image 120
Mark Brackett Avatar answered Oct 09 '22 11:10

Mark Brackett