Пример #1
0
        /// <summary>
        /// Sets the recording device to use in this session
        /// </summary>
        public static void setRecordingDrive()
        {
            Program.drive_selector.Logger = Program.logger;
            Program.drive_selector.InitializeDeviceList(false);

            if (Program.drive != null)
            {
                Program.drive.Dispose();
                Program.drive = null;
            }

            if (Program.device != null)
            {
                Program.device.Dispose();
                Program.device = null;
            }

            string dname = (string)Program.drive_selector.SelectedItem;
            Program.device = new Device(Program.logger);
            
            if (!Program.device.Open(dname[0]))
            {
                Program.device = null;
                return;
            }

            Program.drive = new Drive(Program.device);
            DiskOperationError status = Program.drive.Initialize();
            if (status != null)
            {
                Program.drive.Dispose();
                Program.device.Dispose();
                Program.device = null;
                Program.drive = null;
                return;
            }

            SpeedInfo[] speeds;
            if (Program.drive.GetWriteSpeeds(out speeds) == null && speeds.GetLength(0) != 0)
                Program.burn_speed = speeds[0];
            else
                Program.burn_speed = null;
        }
Пример #2
0
        /// <summary>
        /// Extract the information we want to keep around after we close the device.
        /// </summary>
        /// <param name="dev">the open device we are going to query</param>
        /// <returns>true if we got the info, false otherwise</returns>
        public bool ExtractInfo(Device dev)
        {
            if (dev.Inquiry(out m_inqury_result) != Device.CommandStatus.Success)
                return false;

            if (!m_inqury_result.Valid)
                return false;

            if (m_inqury_result.PeripheralQualifier != 0)
                return false;

            if (m_inqury_result.PeripheralDeviceType != Device.MMCDeviceType)
                return false;

            return true;
        }
Пример #3
0
        /// <summary>
        /// This method scans the current machine for all CDROM devices found in the system.
        /// </summary>
        public void ScanForDevices()
        {
            if (BeforeScan != null)
            {
                DeviceManagerRescanArgs args = new DeviceManagerRescanArgs();
                BeforeScan(this, args);
            }

            m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 0, "Scanning for devices ... ")) ;

            OperatingSystem os = Environment.OSVersion;
            m_logger.LogMessage(new UserMessage(UserMessage.Category.Info, 0, "Operating System: " + os.ToString()));
            m_logger.LogMessage(new UserMessage(UserMessage.Category.Info, 0, "Platform: " + os.Platform.ToString()));

            int ossize = 32 ;
            if (IntPtr.Size == 8)
                ossize = 64 ;

            m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 0, "OS Word Size: " + ossize.ToString())) ;

            m_devices_found.Clear();
            for (int i = 0; i < 100; i++)
            {
                uint dlev = (uint)((i > 5) ? 9 : 8);
                string name = "\\\\.\\CDROM" + i.ToString();

                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, dlev, "Checking device " + name + " ... "));

                Device dev = new Device(m_logger) ;
                if (!dev.Open(name))
                {
                    m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, dlev, "  ... device open failed"));
                    continue ;
                }

                string letter = GetLetterFromDeviceName(name);

                DeviceInfo info = DeviceInfo.CreateDevice(name, letter);
                if (!info.ExtractInfo(dev))
                {
                    m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, dlev, "  ... cannot extract inquiry information from the drive"));

                    string str = "The drive '" + letter + "' (" + name + ") is a CD/DVD driver, but is not a valid MMC device.";
                    m_logger.LogMessage(new UserMessage(UserMessage.Category.Error, 0, str));
                    str = "This drive is not supported by BwgBurn and is probably an older device.";
                    m_logger.LogMessage(new UserMessage(UserMessage.Category.Error, 0, str));
                    continue;
                }

                m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, dlev, "  ... device added to device list"));
                m_devices_found.Add(info) ;
                dev.Close() ;
            }

            if (AfterScan != null)
            {
                DeviceManagerRescanArgs args = new DeviceManagerRescanArgs();
                AfterScan(this, args);
            }

            string devlist = string.Empty;
            foreach (DeviceInfo info in m_devices_found)
            {
                if (devlist.Length > 0)
                    devlist += ", ";
                devlist += info.ShortDesc;
            }
            m_logger.LogMessage(new UserMessage(UserMessage.Category.Debug, 0, "Found devices ... " + devlist));

            foreach (DeviceInfo info in m_devices_found)
            {
                UserMessage m = new UserMessage(UserMessage.Category.Debug, 6, "Found Device: " + info.DeviceLetter) ;
                m_logger.LogMessage(m);

                m = new UserMessage(UserMessage.Category.Debug, 6, "    NT Name = " + info.DeviceName);
                m_logger.LogMessage(m);

                m = new UserMessage(UserMessage.Category.Debug, 6, "    Vendor = " + info.InquiryData.VendorIdentification.Trim());
                m_logger.LogMessage(m);

                m = new UserMessage(UserMessage.Category.Debug, 6, "    Product = " + info.InquiryData.ProductIdentification.Trim());
                m_logger.LogMessage(m);

                m = new UserMessage(UserMessage.Category.Debug, 6, "    Revision = " + info.InquiryData.ProductRevision.Trim());
                m_logger.LogMessage(m);
            }
        }
Пример #4
0
		public void Close()
		{
			UserData = null;
			C2Count = null;
			if (m_device != null)
				m_device.Close();
			m_device = null;
			_toc = null;
			_toc2 = null;
			gapsDetected = false;
			readCommandFound = false;
			_currentStart = -1;
			_currentEnd = -1;
		}
Пример #5
0
		public bool Open(char Drive)
		{
			Device.CommandStatus st;

			m_inqury_result = null;

			// Open the base device
			m_device_letter = Drive;
			if (m_device != null)
				Close();

			m_device = new Device(m_logger);
			if (!m_device.Open(m_device_letter))
				throw new ReadCDException(Resource1.DeviceOpenError, Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()));
			//throw new ReadCDException(Resource1.DeviceOpenError + ": " + WinDev.Win32ErrorToString(m_device.LastError));

			// Get device info
			st = m_device.Inquiry(out m_inqury_result);
			if (st != Device.CommandStatus.Success)
				throw new SCSIException(Resource1.DeviceInquiryError, m_device, st);
			if (!m_inqury_result.Valid || m_inqury_result.PeripheralQualifier != 0 || m_inqury_result.PeripheralDeviceType != Device.MMCDeviceType)
				throw new ReadCDException(Resource1.DeviceNotMMC);

			m_max_sectors = Math.Min(NSECTORS, m_device.MaximumTransferLength / CB_AUDIO - 1);
			//// Open/Initialize the driver
			//Drive m_drive = new Drive(dev);
			//DiskOperationError status = m_drive.Initialize();
			//if (status != null)
			//    throw new Exception("SCSI error");

			// {
			//Drive.FeatureState readfeature = m_drive.GetFeatureState(Feature.FeatureType.CDRead);
			//if (readfeature == Drive.FeatureState.Error || readfeature == Drive.FeatureState.NotPresent)
			//    throw new Exception("SCSI error");
			// }{
			//st = m_device.GetConfiguration(Device.GetConfigType.OneFeature, 0, out flist);
			//if (st != Device.CommandStatus.Success)
			//    return CreateErrorObject(st, m_device);

			//Feature f = flist.Features[0];
			//ParseProfileList(f.Data);
			// }

			//SpeedDescriptorList speed_list;
			//st = m_device.GetSpeed(out speed_list);
			//if (st != Device.CommandStatus.Success)
			//    throw new Exception("GetSpeed failed: SCSI error");

			//m_device.SetCdSpeed(Device.RotationalControl.CLVandNonPureCav, (ushort)(0x7fff), (ushort)(0x7fff));
			//int bytesPerSec = 4 * 588 * 75 * (pass > 8 ? 4 : pass > 4 ? 8 : pass > 0 ? 16 : 32);
			//Device.CommandStatus st = m_device.SetStreaming(Device.RotationalControl.CLVandNonPureCav, start, end, bytesPerSec, 1, bytesPerSec, 1);
			//if (st != Device.CommandStatus.Success)
			//    System.Console.WriteLine("SetStreaming: ", (st == Device.CommandStatus.DeviceFailed ? Device.LookupSenseError(m_device.GetSenseAsc(), m_device.GetSenseAscq()) : st.ToString()));
			//st = m_device.SetCdSpeed(Device.RotationalControl.CLVandNonPureCav, (ushort)(bytesPerSec / 1024), (ushort)(bytesPerSec / 1024));
			//if (st != Device.CommandStatus.Success)
			//    System.Console.WriteLine("SetCdSpeed: ", (st == Device.CommandStatus.DeviceFailed ? Device.LookupSenseError(m_device.GetSenseAsc(), m_device.GetSenseAscq()) : st.ToString()));


			//st = m_device.SetCdSpeed(Device.RotationalControl.CLVandNonPureCav, 32767/*Device.OptimumSpeed*/, Device.OptimumSpeed);
			//if (st != Device.CommandStatus.Success)
			//    throw new Exception("SetCdSpeed failed: SCSI error");

			IList<TocEntry> toc;
			st = m_device.ReadToc((byte)0, false, out toc);
			if (st != Device.CommandStatus.Success)
				throw new SCSIException(Resource1.ReadTOCError, m_device, st);
				//throw new Exception("ReadTOC: " + (st == Device.CommandStatus.DeviceFailed ? Device.LookupSenseError(m_device.GetSenseAsc(), m_device.GetSenseAscq()) : st.ToString()));

			//byte[] qdata = null;
			//st = m_device.ReadPMA(out qdata);
			//if (st != Device.CommandStatus.Success)
			//    throw new SCSIException("ReadPMA", m_device, st);

			//st = m_device.ReadCDText(out cdtext, _timeout);
			// new CDTextEncoderDecoder

			_toc2 = null;
			_toc = new CDImageLayout();
			for (int iTrack = 0; iTrack < toc.Count - 1; iTrack++)
				_toc.AddTrack(new CDTrack((uint)iTrack + 1, 
					toc[iTrack].StartSector,
					toc[iTrack + 1].StartSector - toc[iTrack].StartSector - 
					    ((toc[iTrack + 1].Control < 4 || iTrack + 1 == toc.Count - 1) ? 0U : 152U * 75U), 
					toc[iTrack].Control < 4,
					(toc[iTrack].Control & 1) == 1));			
			if (_toc.AudioLength > 0)
			{
				if (_toc[1].IsAudio)
					_toc[1][0].Start = 0;
				Position = 0;
			} else
				throw new ReadCDException(Resource1.NoAudio);

            UserData = new long[MSECTORS, 2, 4 * 588];
            C2Count = new byte[MSECTORS, 294];

			return true;
		}
Пример #6
0
		public SCSIException(string args, Device device, Device.CommandStatus st)
			: base(args + ": " + (st == Device.CommandStatus.DeviceFailed ? device.GetErrorString() : st.ToString()))
		{
		}