Exemplo n.º 1
0
        public frmMediaScan(string devicePath, DeviceInfo deviceInfo, ScsiInfo scsiInfo = null)
        {
            XamlReader.Load(this);

            this.devicePath = devicePath;
            btnStop.Visible = false;

            lineChart.AbsoluteMargins = true;
            lineChart.MarginX         = 5;
            lineChart.MarginY         = 5;
            lineChart.DrawAxes        = true;
            lineChart.AxesColor       = Colors.Black;
            lineChart.ColorX          = Colors.Gray;
            lineChart.ColorY          = Colors.Gray;
            lineChart.BackgroundColor = Color.FromRgb(0x2974c1);
            lineChart.LineColor       = Colors.Yellow;
        }
Exemplo n.º 2
0
 public MediaScanViewModel(string devicePath, DeviceInfo deviceInfo, Window view, ScsiInfo scsiInfo = null)
 {
     _devicePath  = devicePath;
     _view        = view;
     StopVisible  = false;
     StartCommand = ReactiveCommand.Create(ExecuteStartCommand);
     CloseCommand = ReactiveCommand.Create(ExecuteCloseCommand);
     StopCommand  = ReactiveCommand.Create(ExecuteStopCommand);
     StartVisible = true;
     CloseVisible = true;
     BlockMapList = new ObservableCollection <(ulong block, double duration)>();
     ChartPoints  = new ObservableCollection <DataPoint>();
     StepsX       = double.NaN;
     StepsY       = double.NaN;
     AxesColor    = Colors.Black;
     LineColor    = Colors.Yellow;
 }
Exemplo n.º 3
0
        public DeviceInfoViewModel(DeviceInfo devInfo, Window view)
        {
            SaveUsbDescriptorsCommand = ReactiveCommand.Create(ExecuteSaveUsbDescriptorsCommand);
            _view    = view;
            _devInfo = devInfo;

            DeviceType   = devInfo.Type.ToString();
            Manufacturer = devInfo.Manufacturer;
            Model        = devInfo.Model;
            Revision     = devInfo.FirmwareRevision;
            Serial       = devInfo.Serial;
            ScsiType     = devInfo.ScsiType.ToString();
            Removable    = devInfo.IsRemovable;
            UsbVisible   = devInfo.IsUsb;

            if (devInfo.IsUsb)
            {
                UsbVisible = true;
                SaveUsbDescriptorsEnabled = devInfo.UsbDescriptors != null;
                UsbVendorId     = $"{devInfo.UsbVendorId:X4}";
                UsbProductId    = $"{devInfo.UsbProductId:X4}";
                UsbManufacturer = devInfo.UsbManufacturerString;
                UsbProduct      = devInfo.UsbProductString;
                UsbSerial       = devInfo.UsbSerialString;
            }

            if (devInfo.IsFireWire)
            {
                FirewireVisible      = true;
                FirewireVendorId     = $"{devInfo.FireWireVendor:X4}";
                FirewireModelId      = $"{devInfo.FireWireModel:X4}";
                FirewireManufacturer = devInfo.FireWireVendorName;
                FirewireModel        = devInfo.FireWireModelName;
                FirewireGuid         = $"{devInfo.FireWireGuid:X16}";
            }

            if (devInfo.IsPcmcia)
            {
                PcmciaInfo = new PcmciaInfo
                {
                    DataContext = new PcmciaInfoViewModel(devInfo.Cis, _view)
                };
            }

            if (devInfo.AtaIdentify != null ||
                devInfo.AtapiIdentify != null)
            {
                AtaInfo = new AtaInfo
                {
                    DataContext =
                        new AtaInfoViewModel(devInfo.AtaIdentify, devInfo.AtapiIdentify, devInfo.AtaMcptError, _view)
                };
            }

            if (devInfo.ScsiInquiryData != null)
            {
                ScsiInfo = new ScsiInfo
                {
                    DataContext = new ScsiInfoViewModel(devInfo.ScsiInquiryData, devInfo.ScsiInquiry,
                                                        devInfo.ScsiEvpdPages, devInfo.ScsiMode, devInfo.ScsiType,
                                                        devInfo.ScsiModeSense6, devInfo.ScsiModeSense10,
                                                        devInfo.MmcConfiguration, _view)
                };

                if (devInfo.PlextorFeatures != null)
                {
                    PlextorVisible = true;

                    if (devInfo.PlextorFeatures.Eeprom != null)
                    {
                        PlextorEepromVisible = true;
                        PlextorDiscs         = $"{devInfo.PlextorFeatures.Discs}";
                        PlextorCdReadTime    = TimeSpan.FromSeconds(devInfo.PlextorFeatures.CdReadTime).ToString();

                        PlextorCdWriteTime = TimeSpan.FromSeconds(devInfo.PlextorFeatures.CdWriteTime).ToString();

                        if (devInfo.PlextorFeatures.IsDvd)
                        {
                            PlextorDvdTimesVisible = true;

                            PlextorDvdReadTime = TimeSpan.FromSeconds(devInfo.PlextorFeatures.DvdReadTime).ToString();

                            PlextorDvdWriteTime = TimeSpan.FromSeconds(devInfo.PlextorFeatures.DvdWriteTime).ToString();
                        }
                    }

                    PlextorPoweRec = devInfo.PlextorFeatures.PoweRec;

                    if (devInfo.PlextorFeatures.PoweRec)
                    {
                        PlextorPoweRecEnabled = devInfo.PlextorFeatures.PoweRecEnabled;

                        if (devInfo.PlextorFeatures.PoweRecEnabled)
                        {
                            PlextorPoweRecEnabled = true;

                            if (devInfo.PlextorFeatures.PoweRecRecommendedSpeed > 0)
                            {
                                PlextorPoweRecRecommendedVisible = true;

                                PlextorPoweRecRecommended =
                                    $"{devInfo.PlextorFeatures.PoweRecRecommendedSpeed} Kb/sec.";
                            }

                            if (devInfo.PlextorFeatures.PoweRecSelected > 0)
                            {
                                PlextorPoweRecSelectedVisible = true;

                                PlextorPoweRecSelected = $"{devInfo.PlextorFeatures.PoweRecSelected} Kb/sec.";
                            }

                            if (devInfo.PlextorFeatures.PoweRecMax > 0)
                            {
                                PlextorPoweRecMaxVisible = true;
                                PlextorPoweRecMax        = $"{devInfo.PlextorFeatures.PoweRecMax} Kb/sec.";
                            }

                            if (devInfo.PlextorFeatures.PoweRecLast > 0)
                            {
                                PlextorPoweRecLastVisible = true;
                                PlextorPoweRecLast        = $"{devInfo.PlextorFeatures.PoweRecLast} Kb/sec.";
                            }
                        }
                    }

                    PlextorSilentMode = devInfo.PlextorFeatures.SilentMode;

                    if (devInfo.PlextorFeatures.SilentMode)
                    {
                        PlextorSilentModeEnabled = devInfo.PlextorFeatures.SilentModeEnabled;

                        if (devInfo.PlextorFeatures.SilentModeEnabled)
                        {
                            PlextorSilentModeAccessTime = devInfo.PlextorFeatures.AccessTimeLimit == 2
                                                              ? "\tAccess time is slow" : "\tAccess time is fast";

                            PlextorSilentModeCdReadSpeedLimit =
                                devInfo.PlextorFeatures.CdReadSpeedLimit > 0
                                    ? $"{devInfo.PlextorFeatures.CdReadSpeedLimit}x" : "unlimited";

                            PlextorSilentModeCdWriteSpeedLimit =
                                devInfo.PlextorFeatures.CdWriteSpeedLimit > 0
                                    ? $"{devInfo.PlextorFeatures.CdReadSpeedLimit}x" : "unlimited";

                            if (devInfo.PlextorFeatures.IsDvd)
                            {
                                PlextorSilentModeDvdReadSpeedLimitVisible = true;

                                PlextorSilentModeDvdReadSpeedLimit =
                                    devInfo.PlextorFeatures.DvdReadSpeedLimit > 0
                                        ? $"{devInfo.PlextorFeatures.DvdReadSpeedLimit}x" : "unlimited";
                            }
                        }
                    }

                    PlextorGigaRec   = devInfo.PlextorFeatures.GigaRec;
                    PlextorSecuRec   = devInfo.PlextorFeatures.SecuRec;
                    PlextorSpeedRead = devInfo.PlextorFeatures.SpeedRead;

                    if (devInfo.PlextorFeatures.SpeedRead)
                    {
                        PlextorSpeedEnabled = devInfo.PlextorFeatures.SpeedReadEnabled;
                    }

                    PlextorHiding = devInfo.PlextorFeatures.Hiding;

                    if (devInfo.PlextorFeatures.Hiding)
                    {
                        PlextorHidesRecordables = devInfo.PlextorFeatures.HidesRecordables;
                        PlextorHidesSessions    = devInfo.PlextorFeatures.HidesSessions;
                    }

                    PlextorVariRec = devInfo.PlextorFeatures.VariRec;

                    if (devInfo.PlextorFeatures.IsDvd)
                    {
                        PlextorVariRecDvd       = devInfo.PlextorFeatures.VariRecDvd;
                        PlextorBitSetting       = devInfo.PlextorFeatures.BitSetting;
                        PlextorBitSettingDl     = devInfo.PlextorFeatures.BitSettingDl;
                        PlextorDvdPlusWriteTest = devInfo.PlextorFeatures.DvdPlusWriteTest;
                    }
                }

                if (devInfo.ScsiInquiry?.KreonPresent == true)
                {
                    Kreon = true;
                    KreonChallengeResponse = devInfo.KreonFeatures.HasFlag(KreonFeatures.ChallengeResponse);
                    KreonDecryptSs         = devInfo.KreonFeatures.HasFlag(KreonFeatures.DecryptSs);
                    KreonXtremeUnlock      = devInfo.KreonFeatures.HasFlag(KreonFeatures.XtremeUnlock);
                    KreonWxripperUnlock    = devInfo.KreonFeatures.HasFlag(KreonFeatures.WxripperUnlock);

                    KreonChallengeResponse360 = devInfo.KreonFeatures.HasFlag(KreonFeatures.ChallengeResponse360);

                    KreonDecryptSs360      = devInfo.KreonFeatures.HasFlag(KreonFeatures.DecryptSs360);
                    KreonXtremeUnlock360   = devInfo.KreonFeatures.HasFlag(KreonFeatures.XtremeUnlock360);
                    KreonWxripperUnlock360 = devInfo.KreonFeatures.HasFlag(KreonFeatures.WxripperUnlock360);
                    KreonLock          = devInfo.KreonFeatures.HasFlag(KreonFeatures.Lock);
                    KreonErrorSkipping = devInfo.KreonFeatures.HasFlag(KreonFeatures.ErrorSkipping);
                }

                if (devInfo.BlockLimits != null)
                {
                    BlockLimits.BlockLimitsData?
                        blockLimits = Decoders.SCSI.SSC.BlockLimits.Decode(devInfo.BlockLimits);

                    if (blockLimits.HasValue)
                    {
                        Ssc = true;

                        if (blockLimits.Value.minBlockLen == blockLimits.Value.maxBlockLen)
                        {
                            MinBlockSize = $"Device's block size is fixed at {blockLimits.Value.minBlockLen} bytes";
                        }
                        else
                        {
                            MaxBlockSize = blockLimits.Value.maxBlockLen > 0
                                               ? $"Device's maximum block size is {blockLimits.Value.maxBlockLen} bytes"
                                               : "Device does not specify a maximum block size";

                            MinBlockSize = $"Device's minimum block size is {blockLimits.Value.minBlockLen} bytes";

                            if (blockLimits.Value.granularity > 0)
                            {
                                BlockSizeGranularity =
                                    $"Device's needs a block size granularity of 2^{blockLimits.Value.granularity} ({Math.Pow(2, blockLimits.Value.granularity)}) bytes";
                            }
                        }
                    }
                }

                if (devInfo.DensitySupport != null)
                {
                    if (devInfo.DensitySupportHeader.HasValue)
                    {
                        Densities = DensitySupport.PrettifyDensity(devInfo.DensitySupportHeader);
                    }
                }

                if (devInfo.MediumDensitySupport != null)
                {
                    if (devInfo.MediaTypeSupportHeader.HasValue)
                    {
                        MediumTypes = DensitySupport.PrettifyMediumType(devInfo.MediaTypeSupportHeader);
                    }

                    MediumDensity = DensitySupport.PrettifyMediumType(devInfo.MediumDensitySupport);
                }
            }

            SdMmcInfo = new SdMmcInfo
            {
                DataContext = new SdMmcInfoViewModel(devInfo.Type, devInfo.CID, devInfo.CSD, devInfo.OCR,
                                                     devInfo.ExtendedCSD, devInfo.SCR)
            };
        }
Exemplo n.º 4
0
        public frmDump(string devicePath, DeviceInfo deviceInfo, ScsiInfo scsiInfo = null)
        {
            MediaType mediaType;

            XamlReader.Load(this);

            // Defaults
            chkStopOnError.Checked      = false;
            chkForce.Checked            = false;
            chkPersistent.Checked       = true;
            chkResume.Checked           = true;
            chkTrack1Pregap.Checked     = false;
            chkSidecar.Checked          = true;
            chkTrim.Checked             = true;
            chkExistingMetadata.Checked = false;
            stpRetries.Value            = 5;
            stpSkipped.Value            = 512;

            if (scsiInfo != null)
            {
                mediaType = scsiInfo.MediaType;
            }
            else
            {
                switch (deviceInfo.Type)
                {
                case DeviceType.SecureDigital:
                    mediaType = MediaType.SecureDigital;

                    break;

                case DeviceType.MMC:
                    mediaType = MediaType.MMC;

                    break;

                default:
                    if (deviceInfo.IsPcmcia)
                    {
                        mediaType = MediaType.PCCardTypeII;
                    }
                    else if (deviceInfo.IsCompactFlash)
                    {
                        mediaType = MediaType.CompactFlash;
                    }
                    else
                    {
                        mediaType = MediaType.GENERIC_HDD;
                    }

                    break;
                }
            }

            ObservableCollection <IWritableImage> lstPlugins = new ObservableCollection <IWritableImage>();
            PluginBase plugins = GetPluginBase.Instance;

            foreach (IWritableImage plugin in
                     plugins.WritableImages.Values.Where(p => p.SupportedMediaTypes.Contains(mediaType)))
            {
                lstPlugins.Add(plugin);
            }

            cmbFormat.ItemTextBinding = Binding.Property((IWritableImage p) => p.Name);
            cmbFormat.ItemKeyBinding  = Binding.Property((IWritableImage p) => p.Id.ToString());
            cmbFormat.DataStore       = lstPlugins;

            List <CommonEncodingInfo> encodings = Encoding.GetEncodings().Select(info => new CommonEncodingInfo
            {
                Name = info.Name, DisplayName = info.GetEncoding().EncodingName
            }).ToList();

            encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings().Select(info => new CommonEncodingInfo
            {
                Name = info.Name, DisplayName = info.DisplayName
            }));

            ObservableCollection <CommonEncodingInfo> lstEncodings = new ObservableCollection <CommonEncodingInfo>();

            foreach (CommonEncodingInfo info in encodings.OrderBy(t => t.DisplayName))
            {
                lstEncodings.Add(info);
            }

            cmbEncoding.ItemTextBinding = Binding.Property((CommonEncodingInfo p) => p.DisplayName);
            cmbEncoding.ItemKeyBinding  = Binding.Property((CommonEncodingInfo p) => p.Name);
            cmbEncoding.DataStore       = lstEncodings;

            switch (mediaType)
            {
            case MediaType.CD:
            case MediaType.CDDA:
            case MediaType.CDG:
            case MediaType.CDEG:
            case MediaType.CDI:
            case MediaType.CDROM:
            case MediaType.CDROMXA:
            case MediaType.CDPLUS:
            case MediaType.CDMO:
            case MediaType.CDR:
            case MediaType.CDRW:
            case MediaType.CDMRW:
            case MediaType.VCD:
            case MediaType.SVCD:
            case MediaType.PCD:
            case MediaType.DDCD:
            case MediaType.DDCDR:
            case MediaType.DDCDRW:
            case MediaType.DTSCD:
            case MediaType.CDMIDI:
            case MediaType.CDV:
            case MediaType.CDIREADY:
            case MediaType.FMTOWNS:
            case MediaType.PS1CD:
            case MediaType.PS2CD:
            case MediaType.MEGACD:
            case MediaType.SATURNCD:
            case MediaType.GDROM:
            case MediaType.GDR:
            case MediaType.MilCD:
            case MediaType.SuperCDROM2:
            case MediaType.JaguarCD:
            case MediaType.ThreeDO:
            case MediaType.PCFX:
            case MediaType.NeoGeoCD:
            case MediaType.CDTV:
            case MediaType.CD32:
            case MediaType.Playdia:
            case MediaType.Pippin:
            case MediaType.VideoNow:
            case MediaType.VideoNowColor:
            case MediaType.VideoNowXp:
                chkTrack1Pregap.Visible = true;

                break;

            default:
                chkTrack1Pregap.Visible = false;

                break;
            }

            _devicePath = devicePath;
        }
Exemplo n.º 5
0
        public MediaDumpViewModel(string devicePath, DeviceInfo deviceInfo, Window view,
                                  [CanBeNull] ScsiInfo scsiInfo = null)
        {
            _view = view;
            DestinationEnabled = true;
            StartVisible       = true;
            CloseVisible       = true;
            OptionsVisible     = true;
            StartCommand       = ReactiveCommand.Create(ExecuteStartCommand);
            CloseCommand       = ReactiveCommand.Create(ExecuteCloseCommand);
            StopCommand        = ReactiveCommand.Create(ExecuteStopCommand);
            DestinationCommand = ReactiveCommand.Create(ExecuteDestinationCommand);
            PluginsList        = new ObservableCollection <ImagePluginModel>();
            Encodings          = new ObservableCollection <EncodingModel>();

            // Defaults
            StopOnError      = false;
            Force            = false;
            Persistent       = true;
            Resume           = true;
            Track1Pregap     = false;
            Sidecar          = true;
            Trim             = true;
            ExistingMetadata = false;
            Retries          = 5;
            Skipped          = 512;

            MediaType mediaType;

            if (scsiInfo != null)
            {
                mediaType = scsiInfo.MediaType;
            }
            else
            {
                switch (deviceInfo.Type)
                {
                case DeviceType.SecureDigital:
                    mediaType = MediaType.SecureDigital;

                    break;

                case DeviceType.MMC:
                    mediaType = MediaType.MMC;

                    break;

                default:
                    if (deviceInfo.IsPcmcia)
                    {
                        mediaType = MediaType.PCCardTypeII;
                    }
                    else if (deviceInfo.IsCompactFlash)
                    {
                        mediaType = MediaType.CompactFlash;
                    }
                    else
                    {
                        mediaType = MediaType.GENERIC_HDD;
                    }

                    break;
                }
            }

            PluginBase plugins = GetPluginBase.Instance;

            foreach (IWritableImage plugin in
                     plugins.WritableImages.Values.Where(p => p.SupportedMediaTypes.Contains(mediaType)))
            {
                PluginsList.Add(new ImagePluginModel
                {
                    Plugin = plugin
                });
            }

            Encodings.AddRange(Encoding.GetEncodings().Select(info => new EncodingModel
            {
                Name        = info.Name,
                DisplayName = info.GetEncoding().EncodingName
            }));

            Encodings.AddRange(Claunia.Encoding.Encoding.GetEncodings().Select(info => new EncodingModel
            {
                Name        = info.Name,
                DisplayName = info.DisplayName
            }));

            switch (mediaType)
            {
            case MediaType.CD:
            case MediaType.CDDA:
            case MediaType.CDG:
            case MediaType.CDEG:
            case MediaType.CDI:
            case MediaType.CDROM:
            case MediaType.CDROMXA:
            case MediaType.CDPLUS:
            case MediaType.CDMO:
            case MediaType.CDR:
            case MediaType.CDRW:
            case MediaType.CDMRW:
            case MediaType.VCD:
            case MediaType.SVCD:
            case MediaType.PCD:
            case MediaType.DDCD:
            case MediaType.DDCDR:
            case MediaType.DDCDRW:
            case MediaType.DTSCD:
            case MediaType.CDMIDI:
            case MediaType.CDV:
            case MediaType.CDIREADY:
            case MediaType.FMTOWNS:
            case MediaType.PS1CD:
            case MediaType.PS2CD:
            case MediaType.MEGACD:
            case MediaType.SATURNCD:
            case MediaType.GDROM:
            case MediaType.GDR:
            case MediaType.MilCD:
            case MediaType.SuperCDROM2:
            case MediaType.JaguarCD:
            case MediaType.ThreeDO:
            case MediaType.PCFX:
            case MediaType.NeoGeoCD:
            case MediaType.CDTV:
            case MediaType.CD32:
            case MediaType.Playdia:
            case MediaType.Pippin:
            case MediaType.VideoNow:
            case MediaType.VideoNowColor:
            case MediaType.VideoNowXp:
            case MediaType.CVD:
                Track1PregapVisible = true;

                break;

            default:
                Track1PregapVisible = false;

                break;
            }

            _devicePath = devicePath;
        }
Exemplo n.º 6
0
        public pnlDeviceInfo(DeviceInfo devInfo)
        {
            XamlReader.Load(this);

            this.devInfo = devInfo;

            txtType.Text         = devInfo.Type.ToString();
            txtManufacturer.Text = devInfo.Manufacturer;
            txtModel.Text        = devInfo.Model;
            txtRevision.Text     = devInfo.FirmwareRevision;
            txtSerial.Text       = devInfo.Serial;
            txtScsiType.Text     = devInfo.ScsiType.ToString();
            chkRemovable.Checked = devInfo.IsRemovable;
            chkUsb.Checked       = devInfo.IsUsb;

            if (devInfo.IsUsb)
            {
                tabUsb.Visible = true;
                btnSaveUsbDescriptors.Enabled = devInfo.UsbDescriptors != null;
                txtUsbVendorId.Text           = $"{devInfo.UsbVendorId:X4}";
                txtUsbProductId.Text          = $"{devInfo.UsbProductId:X4}";
                txtUsbManufacturer.Text       = devInfo.UsbManufacturerString;
                txtUsbProduct.Text            = devInfo.UsbProductString;
                txtUsbSerial.Text             = devInfo.UsbSerialString;
            }

            if (devInfo.IsFireWire)
            {
                tabFirewire.Visible          = true;
                txtFirewireVendorId.Text     = $"{devInfo.FireWireVendor:X4}";
                txtFirewireModelId.Text      = $"{devInfo.FireWireModel:X4}";
                txtFirewireManufacturer.Text = devInfo.FireWireVendorName;
                txtFirewireModel.Text        = devInfo.FireWireModelName;
                txtFirewireGuid.Text         = $"{devInfo.FireWireGuid:X16}";
            }

            if (devInfo.IsPcmcia)
            {
                var tabPcmciaInfo = new tabPcmciaInfo();
                tabPcmciaInfo.LoadData(devInfo.Cis);
                tabInfos.Pages.Add(tabPcmciaInfo);
            }

            if (devInfo.AtaIdentify != null ||
                devInfo.AtapiIdentify != null)
            {
                var tabAtaInfo = new tabAtaInfo();
                tabAtaInfo.LoadData(devInfo.AtaIdentify, devInfo.AtapiIdentify, devInfo.AtaMcptError);

                tabInfos.Pages.Add(tabAtaInfo);
            }

            if (devInfo.ScsiInquiryData != null)
            {
                var tabScsiInfo = new tabScsiInfo();

                tabScsiInfo.LoadData(devInfo.ScsiInquiryData, devInfo.ScsiInquiry, devInfo.ScsiEvpdPages,
                                     devInfo.ScsiMode, devInfo.ScsiType, devInfo.ScsiModeSense6,
                                     devInfo.ScsiModeSense10, devInfo.MmcConfiguration);

                tabInfos.Pages.Add(tabScsiInfo);

                if (devInfo.PlextorFeatures != null)
                {
                    tabPlextor.Visible = true;

                    if (devInfo.PlextorFeatures.Eeprom != null)
                    {
                        stkPlextorEeprom.Visible  = true;
                        txtPlextorDiscs.Text      = $"{devInfo.PlextorFeatures.Discs}";
                        txtPlextorCdReadTime.Text = TimeSpan.FromSeconds(devInfo.PlextorFeatures.CdReadTime).ToString();

                        txtPlextorCdWriteTime.Text =
                            TimeSpan.FromSeconds(devInfo.PlextorFeatures.CdWriteTime).ToString();

                        if (devInfo.PlextorFeatures.IsDvd)
                        {
                            stkPlextorDvdTimes.Visible = true;

                            txtPlextorDvdReadTime.Text =
                                TimeSpan.FromSeconds(devInfo.PlextorFeatures.DvdReadTime).ToString();

                            txtPlextorDvdWriteTime.Text =
                                TimeSpan.FromSeconds(devInfo.PlextorFeatures.DvdWriteTime).ToString();
                        }
                    }

                    chkPlextorPoweRec.Checked = devInfo.PlextorFeatures.PoweRec;

                    if (devInfo.PlextorFeatures.PoweRec)
                    {
                        chkPlextorPoweRecEnabled.Visible = true;
                        chkPlextorPoweRecEnabled.Checked = devInfo.PlextorFeatures.PoweRecEnabled;

                        if (devInfo.PlextorFeatures.PoweRecEnabled)
                        {
                            stkPlextorPoweRecEnabled.Visible = true;

                            if (devInfo.PlextorFeatures.PoweRecRecommendedSpeed > 0)
                            {
                                stkPlextorPoweRecRecommended.Visible = true;

                                txtPlextorPoweRecRecommended.Text =
                                    $"{devInfo.PlextorFeatures.PoweRecRecommendedSpeed} Kb/sec.";
                            }

                            if (devInfo.PlextorFeatures.PoweRecSelected > 0)
                            {
                                stkPlextorPoweRecSelected.Visible = true;

                                txtPlextorPoweRecSelected.Text = $"{devInfo.PlextorFeatures.PoweRecSelected} Kb/sec.";
                            }

                            if (devInfo.PlextorFeatures.PoweRecMax > 0)
                            {
                                stkPlextorPoweRecMax.Visible = true;
                                txtPlextorPoweRecMax.Text    = $"{devInfo.PlextorFeatures.PoweRecMax} Kb/sec.";
                            }

                            if (devInfo.PlextorFeatures.PoweRecLast > 0)
                            {
                                stkPlextorPoweRecLast.Visible = true;
                                txtPlextorPoweRecLast.Text    = $"{devInfo.PlextorFeatures.PoweRecLast} Kb/sec.";
                            }
                        }
                    }

                    chkPlextorSilentMode.Checked = devInfo.PlextorFeatures.SilentMode;

                    if (devInfo.PlextorFeatures.SilentMode)
                    {
                        chkPlextorSilentModeEnabled.Visible = true;
                        chkPlextorSilentModeEnabled.Checked = devInfo.PlextorFeatures.SilentModeEnabled;

                        if (devInfo.PlextorFeatures.SilentModeEnabled)
                        {
                            lblPlextorSilentModeAccessTime.Text = devInfo.PlextorFeatures.AccessTimeLimit == 2
                                                                      ? "\tAccess time is slow"
                                                                      : "\tAccess time is fast";

                            txtPlextorSilentModeCdReadSpeedLimit.Text =
                                devInfo.PlextorFeatures.CdReadSpeedLimit > 0
                                    ? $"{devInfo.PlextorFeatures.CdReadSpeedLimit}x" : "unlimited";

                            txtPlextorSilentModeCdWriteSpeedLimit.Text =
                                devInfo.PlextorFeatures.CdWriteSpeedLimit > 0
                                    ? $"{devInfo.PlextorFeatures.CdReadSpeedLimit}x" : "unlimited";

                            if (devInfo.PlextorFeatures.IsDvd)
                            {
                                stkPlextorSilentModeDvdReadSpeedLimit.Visible = true;

                                txtPlextorSilentModeDvdReadSpeedLimit.Text =
                                    devInfo.PlextorFeatures.DvdReadSpeedLimit > 0
                                        ? $"{devInfo.PlextorFeatures.DvdReadSpeedLimit}x" : "unlimited";
                            }
                        }
                    }

                    chkPlextorGigaRec.Checked   = devInfo.PlextorFeatures.GigaRec;
                    chkPlextorSecuRec.Checked   = devInfo.PlextorFeatures.SecuRec;
                    chkPlextorSpeedRead.Checked = devInfo.PlextorFeatures.SpeedRead;

                    if (devInfo.PlextorFeatures.SpeedRead)
                    {
                        chkPlextorSpeedEnabled.Visible = true;
                        chkPlextorSpeedEnabled.Checked = devInfo.PlextorFeatures.SpeedReadEnabled;
                    }

                    chkPlextorHiding.Checked = devInfo.PlextorFeatures.Hiding;

                    if (devInfo.PlextorFeatures.Hiding)
                    {
                        stkPlextorHiding.Visible           = true;
                        chkPlextorHidesRecordables.Checked = devInfo.PlextorFeatures.HidesRecordables;
                        chkPlextorHidesSessions.Checked    = devInfo.PlextorFeatures.HidesSessions;
                    }

                    chkPlextorVariRec.Checked = devInfo.PlextorFeatures.VariRec;

                    if (devInfo.PlextorFeatures.IsDvd)
                    {
                        stkPlextorDvd.Visible              = true;
                        chkPlextorVariRecDvd.Checked       = devInfo.PlextorFeatures.VariRecDvd;
                        chkPlextorBitSetting.Checked       = devInfo.PlextorFeatures.BitSetting;
                        chkPlextorBitSettingDl.Checked     = devInfo.PlextorFeatures.BitSettingDl;
                        chkPlextorDvdPlusWriteTest.Checked = devInfo.PlextorFeatures.DvdPlusWriteTest;
                    }
                }

                if (devInfo.ScsiInquiry?.KreonPresent == true)
                {
                    tabKreon.Visible = true;
                    chkKreonChallengeResponse.Checked = devInfo.KreonFeatures.HasFlag(KreonFeatures.ChallengeResponse);
                    chkKreonDecryptSs.Checked         = devInfo.KreonFeatures.HasFlag(KreonFeatures.DecryptSs);
                    chkKreonXtremeUnlock.Checked      = devInfo.KreonFeatures.HasFlag(KreonFeatures.XtremeUnlock);
                    chkKreonWxripperUnlock.Checked    = devInfo.KreonFeatures.HasFlag(KreonFeatures.WxripperUnlock);

                    chkKreonChallengeResponse360.Checked =
                        devInfo.KreonFeatures.HasFlag(KreonFeatures.ChallengeResponse360);

                    chkKreonDecryptSs360.Checked      = devInfo.KreonFeatures.HasFlag(KreonFeatures.DecryptSs360);
                    chkKreonXtremeUnlock360.Checked   = devInfo.KreonFeatures.HasFlag(KreonFeatures.XtremeUnlock360);
                    chkKreonWxripperUnlock360.Checked = devInfo.KreonFeatures.HasFlag(KreonFeatures.WxripperUnlock360);
                    chkKreonLock.Checked          = devInfo.KreonFeatures.HasFlag(KreonFeatures.Lock);
                    chkKreonErrorSkipping.Checked = devInfo.KreonFeatures.HasFlag(KreonFeatures.ErrorSkipping);
                }

                if (devInfo.BlockLimits != null)
                {
                    BlockLimits.BlockLimitsData?blockLimits = BlockLimits.Decode(devInfo.BlockLimits);

                    if (blockLimits.HasValue)
                    {
                        tabSsc.Visible = true;

                        if (blockLimits.Value.minBlockLen == blockLimits.Value.maxBlockLen)
                        {
                            lblMinBlockSize.Visible = true;

                            lblMinBlockSize.Text =
                                $"Device's block size is fixed at {blockLimits.Value.minBlockLen} bytes";
                        }
                        else
                        {
                            lblMinBlockSize.Visible = true;
                            lblMaxBlockSize.Visible = true;

                            lblMaxBlockSize.Text = blockLimits.Value.maxBlockLen > 0
                                                       ? $"Device's maximum block size is {blockLimits.Value.maxBlockLen} bytes"
                                                       : "Device does not specify a maximum block size";

                            lblMinBlockSize.Text =
                                $"Device's minimum block size is {blockLimits.Value.minBlockLen} bytes";

                            if (blockLimits.Value.granularity > 0)
                            {
                                lblBlockSizeGranularity.Visible = true;

                                lblBlockSizeGranularity.Text =
                                    $"Device's needs a block size granularity of 2^{blockLimits.Value.granularity} ({Math.Pow(2, blockLimits.Value.granularity)}) bytes";
                            }
                        }
                    }
                }

                if (devInfo.DensitySupport != null)
                {
                    if (devInfo.DensitySupportHeader.HasValue)
                    {
                        stkDensities.Visible = true;
                        txtDensities.Text    = DensitySupport.PrettifyDensity(devInfo.DensitySupportHeader);
                    }
                }

                if (devInfo.MediumDensitySupport != null)
                {
                    if (devInfo.MediaTypeSupportHeader.HasValue)
                    {
                        stkMediaTypes.Visible = true;
                        txtMediumTypes.Text   = DensitySupport.PrettifyMediumType(devInfo.MediaTypeSupportHeader);
                    }

                    txtMediumDensity.Visible = true;
                    txtMediumDensity.Text    = DensitySupport.PrettifyMediumType(devInfo.MediumDensitySupport);
                }
            }

            var tabSdMmcInfo = new tabSdMmcInfo();

            tabSdMmcInfo.LoadData(devInfo.Type, devInfo.CID, devInfo.CSD, devInfo.OCR, devInfo.ExtendedCSD,
                                  devInfo.SCR);

            tabInfos.Pages.Add(tabSdMmcInfo);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Generate a Drive object from a single device
        /// </summary>
        /// <param name="devicePath">Path to the device</param>
        /// <param name="ignoreFixedDrives">True to ignore fixed drives from population, false otherwise</param>
        /// <returns>Drive object for the device, null on error</returns>
        private static Drive GetDriveFromDevice(string devicePath, bool ignoreFixedDrives)
        {
            if (devicePath.Length == 2 &&
                devicePath[1] == ':' &&
                devicePath[0] != '/' &&
                char.IsLetter(devicePath[0]))
            {
                devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':';
            }

            string windowsLocalDevicePath = devicePath;

            if (windowsLocalDevicePath.StartsWith("\\\\.\\"))
            {
                windowsLocalDevicePath = windowsLocalDevicePath.Substring("\\\\.\\".Length);
            }

            var dev = Device.Create(devicePath, out _);

            if (dev == null || dev.Error)
            {
                return(null);
            }

            var devInfo = new Aaru.Core.Devices.Info.DeviceInfo(dev);

            if (devInfo.MmcConfiguration != null)
            {
                Features.SeparatedFeatures ftr = Features.Separate(devInfo.MmcConfiguration);
                if (ftr.Descriptors != null && ftr.Descriptors.Any(d => d.Code == 0x0000))
                {
                    var  desc      = ftr.Descriptors.First(d => d.Code == 0x0000);
                    bool isOptical = IsOptical(desc.Data);
                    if (isOptical)
                    {
                        return(Create(Data.InternalDriveType.Optical, windowsLocalDevicePath));
                    }
                    else if (!ignoreFixedDrives)
                    {
                        return(Create(Data.InternalDriveType.Removable, windowsLocalDevicePath));
                    }
                }
            }

            if (!ignoreFixedDrives)
            {
                switch (dev.Type)
                {
                case DeviceType.MMC:
                    return(Create(Data.InternalDriveType.Removable, windowsLocalDevicePath));

                case DeviceType.SecureDigital:
                    return(Create(Data.InternalDriveType.Removable, windowsLocalDevicePath));
                }

                if (dev.IsUsb)
                {
                    return(Create(Data.InternalDriveType.Removable, windowsLocalDevicePath));
                }

                if (dev.IsFireWire)
                {
                    return(Create(Data.InternalDriveType.Removable, windowsLocalDevicePath));
                }

                if (dev.IsPcmcia)
                {
                    return(Create(Data.InternalDriveType.Removable, windowsLocalDevicePath));
                }
            }

            dev.Close();
            return(null);
        }