public static bool ScsiMiniportIdentify(this IoControl IoControl, byte TargetId, out IdentifyDevice IdentifyDevice) { const byte ID_CMD = 0xEC; var SrbIoControl = new SrbIoControl( Signagure: "SCSIDISK", ControlCode: IOControlCode.ScsiMiniportIdentify, Timeout: 2 ); var inparams = new Disk.Sendcmdinparams( DriveRegs: new Disk.Ideregs( CommandReg: ID_CMD ), DriveNumber: TargetId ); bool Result = IoControl.ScsiMiniport <Disk.Sendcmdinparams, IdentifyDeviceOutData>(ref SrbIoControl, inparams, out var outparams, out var ReturnBytes); var buffer = new byte[IDENTIFY_BUFFER_SIZE]; using (PtrUtils.CreatePtr(outparams, out var IntPtr, out var Size)) { IdentifyDevice = (IdentifyDevice)Marshal.PtrToStructure(IntPtr.Add(IntPtr, (int)Marshal.OffsetOf <Disk.Sendcmdoutparams>(nameof(Disk.Sendcmdoutparams._Buffer))), typeof(IdentifyDevice)); return(Result); } }
/// <summary> /// IOCTL_SCSI_MINIPORT IOCTL ( https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntddscsi/ni-ntddscsi-ioctl_scsi_miniport ) /// </summary> /// <typeparam name="IN"></typeparam> /// <typeparam name="OUT"></typeparam> /// <param name="IoControl"></param> /// <param name="SrbIoControl"></param> /// <param name="InOutStruct"></param> /// <param name="OutStruct"></param> /// <param name="ReturnBytes"></param> /// <returns></returns> public static bool ScsiMiniport <IN, OUT>(this IoControl IoControl, ref SrbIoControl SrbIoControl, in IN InOutStruct, out OUT OutStruct, out uint ReturnBytes)