Пример #1
0
        //trial
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            IDiscRecorder2 recorder = new MsftDiscRecorder2();

            recorder.InitializeDiscRecorder(selectedDrive);
            IDiscRecorder2Ex dr2 = recorder as IDiscRecorder2Ex;

            //recorder.QueryInterface();
            byte[] resp = new byte[32];
            byte[] recv = new byte[18];
            uint   sb   = 1024;
            IntPtr respPtr;

            resp[0]  = 0; resp[1] = 0; resp[2] = 0; resp[3] = 0; resp[4] = 0;
            resp[5]  = 0; resp[6] = 0; resp[7] = 0; resp[8] = 0; resp[9] = 0;
            resp[10] = 0; resp[11] = 0; resp[12] = 0;

            try
            {
                dr2.SendCommandNoData(resp, 6, recv, 60);

                dr2.GetDiscInformation(out respPtr, ref sb);
                if (sb > 1024)
                {
                    sb = 1024;
                }
                Marshal.Copy(respPtr, resp, 0, (int)sb);
            }
            catch (System.Runtime.InteropServices.COMException)
            {
            }
        }
Пример #2
0
        /// <summary>
        /// Sends a MMC command to the recording device. Use this function when no data buffer
        /// is sent to nor received from the device.
        /// </summary>
        /// <remarks>For details of the contents of the command packet and sense data, see the latest revision of the
        /// MMC specification at ftp://ftp.t10.org/t10/drafts/mmc5/.
        /// <para>Client-defined commands (CDBs) used with this method must be between 6 and 16 bytes in length.
        /// In addition, the size of each command must match the size defined by the operation code as defined in the
        /// following table.</para>
        /// <para><list type="table">
        ///    <listheader>
        ///        <term>CDB group</term>
        ///        <term>CDB operation code range</term>
        ///        <term>Required CDB size</term>
        ///    </listheader>
        ///    <item>
        ///        <description>0</description>
        ///        <description>0x00 — 0x1F</description>
        ///        <description>6 bytes</description>
        ///    </item>
        ///    <item>
        ///        <description>1</description>
        ///        <description>0x20 — 0x3F</description>
        ///        <description>10 bytes</description>
        ///    </item>
        ///    <item>
        ///        <description>2</description>
        ///        <description>0x40 — 0x5F</description>
        ///        <description>10 bytes</description>
        ///    </item>
        ///    <item>
        ///        <description>3</description>
        ///        <description>0x60 — 0x7F</description>
        ///        <description>TBD - will enforce standard-specified size requirements for this opcode range in the future.</description>
        ///    </item>
        ///    <item>
        ///        <description>4</description>
        ///        <description>0x80 — 0x9F</description>
        ///        <description>16 bytes</description>
        ///    </item>
        ///    <item>
        ///        <description>5</description>
        ///        <description>0xA0 — 0xBF</description>
        ///        <description>12 bytes</description>
        ///    </item>
        ///    <item>
        ///        <description>6</description>
        ///        <description>0xC0 — 0xDF</description>
        ///        <description>Vendor Unique - Any size allowed</description>
        ///    </item>
        ///    <item>
        ///        <description>7</description>
        ///        <description>0xE0 — 0xFF</description>
        ///        <description>Vendor Unique - Any size allowed</description>
        ///    </item>
        /// </list></para>
        /// <para>Some very early devices used vendor-unique opcodes and therefore some opcodes cannot be validated
        /// in this manner. The following opcodes are still valid and only verify that the size is between 6 and 16
        /// bytes:</para><para>0x02, 0x05, 0x06, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x13, 0x14, 0x19, 0x20, 0x21, 0x22,
        /// 0x23, 0x24, 0x26, 0x27, 0x29, 0x2C, 0x2D</para></remarks>
        /// <param name="cdb">
        /// Command packet to send to the device.
        /// Must be between 6 and 16 bytes.
        /// </param>
        /// <param name="Timeout">
        /// Time limit, in seconds, allowed for the send command to receive a result.
        /// </param>
        /// <returns>Sense data returned by the recording device.</returns>
        Byte[] IDiscRecorder2X.SendCommandNoData(Byte[] cdb, uint timeout)
        {
            if (cdb.Length < 6 || cdb.Length > 16)
            {
                // TODO: log error
                throw new ArgumentException("The command packet to send to the device must be between 6 and 16 bytes.");
            }

            Byte[]           senseBuffer = new Byte[18];
            IDiscRecorder2Ex recorderEx  = (IDiscRecorder2Ex)this;

            recorderEx.SendCommandNoData(cdb, (uint)cdb.Length, senseBuffer, timeout);

            return(senseBuffer);
        }