public DeviceIOCTL(string devicePath, bool async) { this.async = async; FileOptions fileOps = FileOptions.None; if (async) { overlapped = new DeviceIoOverlapped(); hEvent = new ManualResetEvent(false); fileOps = FileOptions.Asynchronous; } hDevice = new SafeFileHandle( CreateFile( devicePath, FileAccess.ReadWrite, FileShare.ReadWrite, 0, FileMode.Open, fileOps, IntPtr.Zero), true); }