2

How do open a partition in Windows a la Linux style /dev/sdXY? Currently I'm opening \\\\.\\PhysicalDrive%d then calling DeviceIoControl(IOCTL_DISK_GET_DRIVE_LAYOUT, ...) to get the partition layouts, and storing the offset and size of the region containing the filesystem. In my code I offset IO operations on the device by the offset to the partition.

Furthermore, how do I remove the apparently synchronous behaviour? Operations are very slow on the physical drive raw device on Windows, and I'd prefer the OS did caching where possible.

Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
  • Have you tried `\\.\C:` (no trailing slash)? – J-16 SDiZ Dec 08 '10 at 06:08
  • @J-16 SDiZ: Partitions !== mounted filesystems. – Matt Joiner Dec 08 '10 at 06:43
  • drive letter != mounted filesystem. you can have drive letter not mounted (chkdsk umount disk), and you can have drive letter without real "partition" (dynamic disk). Not an exact mapping, but it is the best mapping you can get in windows. – J-16 SDiZ Dec 08 '10 at 13:30

1 Answers1

2

You can use paths like \\?\GLOBALROOT\Device\Harddisk0\Partition0 to access partitions. See here for general information about namespaces. Also might want to give WinObj a try; it lets you browse the object manager namespace.

Luke
  • 11,211
  • 2
  • 27
  • 38
  • Wasted ton of time to discover, that you need to prefix \Device\Harddisk0\Partition0 with \\?\GLOBALROOT\ . Thank you, Luke! – LOST Jul 08 '16 at 05:43