Пример #1
0
        /// <summary>
        /// Read Audio Sectors
        /// </summary>
        /// <param name="sector">The sector where to start to read</param>
        /// <param name="Buffer">The length must be at least CB_CDDASECTOR*Sectors bytes</param>
        /// <param name="NumSectors">Number of sectors to read</param>
        /// <returns>True on success</returns>
        protected bool ReadSector(int sector, byte[] Buffer, int NumSectors)
        {
            if (TocValid && ((sector + NumSectors) <= GetEndSector(toc.LastTrack)) && (Buffer.Length >= CB_AUDIO * NumSectors))
            {
                RawReadInfo rri = new RawReadInfo();                //NativeMethods.RAW_READ_INFO();
                rri.TrackMode   = TrackModeType.CDDA;               //NativeMethods.TRACK_MODE_TYPE.CDDA;
                rri.SectorCount = (uint)NumSectors;
                rri.DiskOffset  = sector * CB_CDROMSECTOR;

                uint BytesRead = 0;
                if (NativeMethods.DeviceIoControl(cdHandle, NativeMethods.IOCTL_CDROM_RAW_READ, rri, (uint)Marshal.SizeOf(rri), Buffer, (uint)NumSectors * CB_AUDIO, ref BytesRead, IntPtr.Zero) != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 public extern static int DeviceIoControl(IntPtr hDevice, uint IoControlCode, [In] RawReadInfo rri, uint InBufferSize, [In, Out] byte[] OutBuffer, uint OutBufferSize, ref uint BytesReturned, IntPtr Overlapped);
Пример #3
0
		/// <summary>
		/// Read Audio Sectors
		/// </summary>
		/// <param name="sector">The sector where to start to read</param>
		/// <param name="Buffer">The length must be at least CB_CDDASECTOR*Sectors bytes</param>
		/// <param name="NumSectors">Number of sectors to read</param>
		/// <returns>True on success</returns>
		protected bool ReadSector(int sector, byte[] Buffer, int NumSectors)
		{
			if (TocValid && ((sector + NumSectors) <= GetEndSector(toc.LastTrack)) && (Buffer.Length >= CB_AUDIO * NumSectors))
			{
				RawReadInfo rri = new RawReadInfo(); //NativeMethods.RAW_READ_INFO();
				rri.TrackMode = TrackModeType.CDDA; //NativeMethods.TRACK_MODE_TYPE.CDDA;
				rri.SectorCount = (uint)NumSectors;
				rri.DiskOffset = sector * CB_CDROMSECTOR;

				uint BytesRead = 0;
				if (NativeMethods.DeviceIoControl(cdHandle, NativeMethods.IOCTL_CDROM_RAW_READ, rri, (uint)Marshal.SizeOf(rri), Buffer, (uint)NumSectors * CB_AUDIO, ref BytesRead, IntPtr.Zero) != 0)
				{
					return true;
				}
				else
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}