Example #1
0
 public static unsafe Task <int> DeviceIoControlAsync(
     SafeObjectHandle hDevice,
     uint dwIoControlCode,
     IntPtr inBuffer,
     int nInBufferSize,
     IntPtr outBuffer,
     int nOutBufferSize,
     CancellationToken cancellationToken = default(CancellationToken))
 {
     return(OverlappedAsync(hDevice, lpOverlapped =>
     {
         int pBytesReturned;
         return Kernell32DllNativeMethods.DeviceIoControl(hDevice, dwIoControlCode, inBuffer, nInBufferSize, outBuffer,
                                                          nOutBufferSize, out pBytesReturned, lpOverlapped);
     }, cancellationToken));
 }
Example #2
0
 static unsafe bool DeviceIoControlCore(
     SafeObjectHandle hDevice,
     uint dwIoControlCode,
     IntPtr inBuffer,
     int nInBufferSize,
     IntPtr outBuffer,
     int nOutBufferSize,
     out int pBytesReturned,
     OVERLAPPED?lpOverlapped)
 {
     using (var overlapped = lpOverlapped.Pin())
     {
         return(Kernell32DllNativeMethods.DeviceIoControl(hDevice, dwIoControlCode, inBuffer, nInBufferSize,
                                                          outBuffer, nOutBufferSize, out pBytesReturned, (OVERLAPPED *)overlapped.Pointer));
     }
 }