title: DeviceIoControl with IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS - C#
body: <p>I've C++ code that calls DeviceIoControl with IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS that I need to convert to C#.<br>
  I've found many DeviceIoControl p\invoke samples, but none for this specific flag.
  I've tried using the following extern:</p>
  
  <pre><code>[DllImport("kernel32", SetLastError = true)]
  [return: MarshalAs(UnmanagedType.Bool)]
  public static extern bool DeviceIoControl(SafeFileHandle hVol, int controlCode, IntPtr inBuffer, int inBufferSize, ref DiskExtents outBuffer, int outBufferSize, ref int bytesReturned, IntPtr overlapped);
  </code></pre>
  
  <p>structures:</p>
  
  <pre><code>[StructLayout(LayoutKind.Sequential)]
  public struct DiskExtent
  {
      public uint DiskNumber;
      public long StartingOffset;
      public long ExtentLength;
  }
  
  [StructLayout(LayoutKind.Sequential)]
  public struct DiskExtents
  {
      public int numberOfExtents;
      public DiskExtent[] first;
  }
  </code></pre>
  
  <p>And the following calling code:</p>
  
  <pre><code>int bytesReturned = 0;
  DiskExtents diskExtents = new DiskExtents();
  bool res = DeviceIoControl(hVol, 5636096, IntPtr.Zero, 0, ref diskExtents, Marshal.SizeOf(diskExtents), ref bytesReturned, IntPtr.Zero);
  </code></pre>
  
  <p>But the call return false and the data structure is always empty.
  Any help would be great!</p>