public bool DeviceIOControl<T>(Kernel32.IOControlCode ioControlCode, object inBuffer, ref T outBuffer) { if (_device == null) return false; object boxedOutBuffer = outBuffer; bool b = Kernel32.DeviceIoControl(_device, ioControlCode, inBuffer, inBuffer == null ? 0 : (uint)Marshal.SizeOf(inBuffer), boxedOutBuffer, (uint)Marshal.SizeOf(boxedOutBuffer), out uint _, IntPtr.Zero); if (!b) { int error = Marshal.GetLastWin32Error(); lastError = error; } outBuffer = (T)boxedOutBuffer; return b; }
public bool DeviceIOControl(Kernel32.IOControlCode ioControlCode, object inBuffer) { if (_device == null) return false; bool b = Kernel32.DeviceIoControl(_device, ioControlCode, inBuffer, inBuffer == null ? 0 : (uint)Marshal.SizeOf(inBuffer), null, 0, out uint _, IntPtr.Zero); return b; }