title: Using CreateFile To Access a Drive Partition
body: <p>I have admin rights and have no problem getting a valid handle and ultimately reading an entire hard drive via:</p>
  
  <pre><code>IntPtr handle = CreateFile(@"\\.\PHYSICALDRIVE1", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
  </code></pre>
  
  <p>I can also get a valid handle when I try to open a directory of that drive:</p>
  
  <pre><code>IntPtr handle = CreateFile(@"\\.\Z:\\", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
  </code></pre>
  
  <p>But I cannot get a valid handle when I try to simply open a partition of that drive:</p>
  
  <pre><code>IntPtr handle = CreateFile(@"\\.\Z:", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
  </code></pre>
  
  <p><code>GetLastWin32Error</code> returns access denied (5).</p>
  
  <p>Of course if I offline the drive, then I get "<code>The system cannot find the file specified</code>."
  I've tried everything I could think of with different partitions, different options etc. to no available.</p>