예제 #1
0
        public pnlScsiInfo(ScsiInfo scsiInfo)
        {
            XamlReader.Load(this);

            this.scsiInfo = scsiInfo;


            Stream logo = ResourceHandler.GetResourceStream($"DiscImageChef.Gui.Assets.Logos.Media.{scsiInfo.MediaType}.svg");

/*            if(logo != null)
 *          {
 *              svgMediaLogo.SvgStream = logo;
 *              svgMediaLogo.Visible   = true;
 *          }
 *          else
 *          {*/
            logo =
                ResourceHandler.GetResourceStream($"DiscImageChef.Gui.Assets.Logos.Media.{scsiInfo.MediaType}.png");
            if (logo != null)
            {
                imgMediaLogo.Image   = new Bitmap(logo);
                imgMediaLogo.Visible = true;
            }
            //}

            switch (this.scsiInfo.MediaType)
            {
            case MediaType.HDDVDROM:
            case MediaType.HDDVDRAM:
            case MediaType.HDDVDR:
            case MediaType.HDDVDRW:
            case MediaType.HDDVDRDL:
            case MediaType.HDDVDRWDL:
                tabDvd.Text = "HD DVD";
                break;

            default:
                tabDvd.Text = "DVD";
                break;
            }

            switch (this.scsiInfo.MediaType)
            {
            case MediaType.DVDR:
                tabDvdr.Text = "DVD-R";
                break;

            case MediaType.DVDRW:
                tabDvdr.Text = "DVD-RW";
                break;

            case MediaType.DVDPR:
                tabDvdr.Text = "DVD+R";
                break;

            case MediaType.DVDPRW:
                tabDvdr.Text = "DVD+RW";
                break;

            case MediaType.DVDPRWDL:
                tabDvdr.Text = "DVD+RW DL";
                break;

            case MediaType.DVDRDL:
                tabDvdr.Text = "DVD-R DL";
                break;

            case MediaType.DVDPRDL:
                tabDvdr.Text = "DVD+R DL";
                break;

            case MediaType.DVDRAM:
                tabDvdr.Text = "DVD-RAM";
                break;

            case MediaType.DVDRWDL:
                tabDvdr.Text = "DVD-RW DL";
                break;

            case MediaType.HDDVDRAM:
                tabDvdr.Text = "HD DVD-RAM";
                break;

            case MediaType.HDDVDR:
                tabDvdr.Text = "HD DVD-R";
                break;

            case MediaType.HDDVDRW:
                tabDvdr.Text = "HD DVD-RW";
                break;

            case MediaType.HDDVDRDL:
                tabDvdr.Text = "HD DVD-R DL";
                break;

            case MediaType.HDDVDRWDL:
                tabDvdr.Text = "HD DVD-RW DL";
                break;
            }

            txtType.Text      = scsiInfo.MediaType.ToString();
            lblMediaSize.Text =
                $"Media has {scsiInfo.Blocks} blocks of {scsiInfo.BlockSize} bytes/each. (for a total of {scsiInfo.Blocks * scsiInfo.BlockSize} bytes)";
            lblMediaSize.Visible = scsiInfo.Blocks != 0 && scsiInfo.BlockSize != 0;

            if (scsiInfo.MediaSerialNumber != null)
            {
                stkMediaSerial.Visible = true;
                StringBuilder sbSerial = new StringBuilder();
                for (int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
                {
                    sbSerial.AppendFormat("{0:X2}", scsiInfo.MediaSerialNumber[i]);
                }

                txtMediaSerial.Text = sbSerial.ToString();
            }

            btnSaveReadMediaSerial.Visible = this.scsiInfo.MediaSerialNumber != null;
            btnSaveReadCapacity.Visible    = this.scsiInfo.ReadCapacity != null;
            btnSaveReadCapacity16.Visible  = this.scsiInfo.ReadCapacity16 != null;

            btnSaveGetConfiguration.Visible       = this.scsiInfo.MmcConfiguration != null;
            btnSaveRecognizedFormatLayers.Visible = this.scsiInfo.RecognizedFormatLayers != null;
            btnSaveWriteProtectionStatus.Visible  = this.scsiInfo.WriteProtectionStatus != null;
            tabMmc.Visible = btnSaveGetConfiguration.Visible || btnSaveRecognizedFormatLayers.Visible ||
                             btnSaveWriteProtectionStatus.Visible;

            if (this.scsiInfo.DensitySupportHeader.HasValue)
            {
                grpDensitySupport.Visible = true;
                txtDensitySupport.Text    = DensitySupport.PrettifyDensity(scsiInfo.DensitySupportHeader);
            }

            if (this.scsiInfo.MediaTypeSupportHeader.HasValue)
            {
                grpMediumSupport.Visible = true;
                txtMediumSupport.Text    = DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupportHeader);
            }

            btnSaveDensitySupport.Visible = scsiInfo.DensitySupport != null;
            btnSaveMediumSupport.Visible  = scsiInfo.MediaTypeSupport != null;
            tabSsc.Visible = grpDensitySupport.Visible || grpMediumSupport.Visible || btnSaveDensitySupport.Visible ||
                             btnSaveMediumSupport.Visible;

            if (this.scsiInfo.DecodedCompactDiscInformation.HasValue)
            {
                tabCdInformation.Visible = true;
                txtCdInformation.Text    = DiscInformation.Prettify000b(scsiInfo.DecodedCompactDiscInformation);
                btnCdInformation.Visible = scsiInfo.CompactDiscInformation != null;
            }

            if (this.scsiInfo.DecodedToc.HasValue)
            {
                tabCdToc.Visible = true;
                txtCdToc.Text    = TOC.Prettify(scsiInfo.DecodedToc);
                btnCdToc.Visible = scsiInfo.Toc != null;
            }

            if (this.scsiInfo.FullToc.HasValue)
            {
                tabCdFullToc.Visible = true;
                txtCdFullToc.Text    = FullTOC.Prettify(scsiInfo.FullToc);
                btnCdFullToc.Visible = scsiInfo.RawToc != null;
            }

            if (this.scsiInfo.DecodedSession.HasValue)
            {
                tabCdSession.Visible = true;
                txtCdSession.Text    = Session.Prettify(scsiInfo.DecodedSession);
                btnCdSession.Visible = scsiInfo.Session != null;
            }

            if (this.scsiInfo.DecodedCdTextLeadIn.HasValue)
            {
                tabCdText.Visible = true;
                txtCdText.Text    = CDTextOnLeadIn.Prettify(this.scsiInfo.DecodedCdTextLeadIn);
                btnCdText.Visible = scsiInfo.CdTextLeadIn != null;
            }

            if (this.scsiInfo.DecodedAtip.HasValue)
            {
                tabCdAtip.Visible = true;
                txtCdAtip.Text    = ATIP.Prettify(this.scsiInfo.Atip);
                btnCdAtip.Visible = scsiInfo.Atip != null;
            }

            if (!string.IsNullOrEmpty(scsiInfo.Mcn))
            {
                stkMcn.Visible = true;
                txtMcn.Text    = scsiInfo.Mcn;
            }

            if (this.scsiInfo.Isrcs != null && this.scsiInfo.Isrcs.Count > 0)
            {
                grpIsrcs.Visible = true;

                TreeGridItemCollection isrcsItems = new TreeGridItemCollection();

                grdIsrcs.Columns.Add(new GridColumn {
                    HeaderText = "ISRC", DataCell = new TextBoxCell(0)
                });
                grdIsrcs.Columns.Add(new GridColumn {
                    HeaderText = "Track", DataCell = new TextBoxCell(0)
                });

                grdIsrcs.AllowMultipleSelection = false;
                grdIsrcs.ShowHeader             = true;
                grdIsrcs.DataStore = isrcsItems;

                foreach (KeyValuePair <byte, string> isrc in this.scsiInfo.Isrcs)
                {
                    isrcsItems.Add(new TreeGridItem {
                        Values = new object[] { isrc.Key.ToString(), isrc.Value }
                    });
                }
            }

            btnCdPma.Visible = this.scsiInfo.Pma != null;

            tabCdMisc.Visible = stkMcn.Visible || grpIsrcs.Visible || btnCdPma.Visible;

            tabCd.Visible = tabCdInformation.Visible || tabCdToc.Visible || tabCdFullToc.Visible ||
                            tabCdSession.Visible || tabCdText.Visible || tabCdAtip.Visible || stkMcn.Visible ||
                            grpIsrcs.Visible || btnCdPma.Visible;

            if (this.scsiInfo.DecodedPfi.HasValue)
            {
                grpDvdPfi.Visible = true;
                txtDvdPfi.Text    = PFI.Prettify(this.scsiInfo.DecodedPfi);
            }

            if (this.scsiInfo.DvdCmi != null)
            {
                grpDvdCmi.Visible     = true;
                txtDvdCmi.Text        = CSS_CPRM.PrettifyLeadInCopyright(this.scsiInfo.DvdCmi);
                btnSaveDvdCmi.Visible = true;
            }

            btnSaveDvdPfi.Visible   = this.scsiInfo.DvdPfi != null;
            btnSaveDvdDmi.Visible   = this.scsiInfo.DvdDmi != null;
            btnSaveDvdCmi.Visible   = this.scsiInfo.DvdCmi != null;
            btnSaveHdDvdCmi.Visible = this.scsiInfo.HddvdCopyrightInformation != null;
            btnSaveDvdBca.Visible   = this.scsiInfo.DvdBca != null;
            btnSaveDvdAacs.Visible  = this.scsiInfo.DvdAacs != null;

            tabDvd.Visible = grpDvdPfi.Visible || grpDvdCmi.Visible || btnSaveDvdPfi.Visible ||
                             btnSaveDvdDmi.Visible ||
                             btnSaveDvdCmi.Visible || btnSaveHdDvdCmi.Visible || btnSaveDvdBca.Visible ||
                             btnSaveDvdAacs.Visible;

            if (this.scsiInfo.XgdInfo != null)
            {
                stkXboxInformation.Visible = true;
                txtXboxL0Video.Text        = $"{this.scsiInfo.XgdInfo.L0Video} sectors";
                txtXboxL1Video.Text        = $"{this.scsiInfo.XgdInfo.L1Video} sectors";
                txtXboxMiddleZone.Text     = $"{this.scsiInfo.XgdInfo.MiddleZone} sectors";
                txtXboxGameSize.Text       = $"{this.scsiInfo.XgdInfo.GameSize} sectors";
                txtXboxTotalSize.Text      = $"{this.scsiInfo.XgdInfo.TotalSize} sectors";
                txtXboxRealBreak.Text      = this.scsiInfo.XgdInfo.LayerBreak.ToString();
            }

            if (this.scsiInfo.DvdDmi != null)
            {
                if (DMI.IsXbox(scsiInfo.DvdDmi))
                {
                    grpXboxDmi.Visible = true;
                    txtXboxDmi.Text    = DMI.PrettifyXbox(scsiInfo.DvdDmi);
                }
                else if (DMI.IsXbox360(scsiInfo.DvdDmi))
                {
                    grpXboxDmi.Visible = true;
                    txtXboxDmi.Text    = DMI.PrettifyXbox360(scsiInfo.DvdDmi);
                }
            }

            if (this.scsiInfo.DecodedXboxSecuritySector.HasValue)
            {
                grpXboxSs.Visible = true;
                txtXboxSs.Text    = SS.Prettify(this.scsiInfo.DecodedXboxSecuritySector);
            }

            btnSaveXboxSs.Visible = this.scsiInfo.XboxSecuritySector != null;
            tabXbox.Visible       = stkXboxInformation.Visible || grpXboxDmi.Visible || grpXboxSs.Visible ||
                                    btnSaveXboxSs.Visible;

            if (this.scsiInfo.DvdRamDds != null)
            {
                grpDvdRamDds.Visible     = true;
                btnSaveDvdRamDds.Visible = true;
                txtDvdRamDds.Text        = DDS.Prettify(this.scsiInfo.DvdRamDds);
            }

            if (this.scsiInfo.DvdRamCartridgeStatus != null)
            {
                grpDvdRamCartridgeStatus.Visible     = true;
                btnSaveDvdRamCartridgeStatus.Visible = true;
                txtDvdRamCartridgeStatus.Text        = Cartridge.Prettify(this.scsiInfo.DvdRamCartridgeStatus);
            }

            if (this.scsiInfo.DvdRamSpareArea != null)
            {
                grpDvdRamSpareAreaInformation.Visible     = true;
                btnSaveDvdRamSpareAreaInformation.Visible = true;
                txtDvdRamSpareAreaInformation.Text        = Spare.Prettify(this.scsiInfo.DvdRamSpareArea);
            }

            btnSaveDvdRamDds.Visible                     = this.scsiInfo.DvdRamDds != null;
            btnSaveDvdRamCartridgeStatus.Visible         = this.scsiInfo.DvdRamCartridgeStatus != null;
            btnSaveDvdRamSpareAreaInformation.Visible    = this.scsiInfo.DvdRamSpareArea != null;
            btnSaveLastBorderOutRmd.Visible              = this.scsiInfo.LastBorderOutRmd != null;
            btnSaveDvdPreRecordedInfo.Visible            = this.scsiInfo.DvdPreRecordedInfo != null;
            btnSaveDvdrMediaIdentifier.Visible           = this.scsiInfo.DvdrMediaIdentifier != null;
            btnSaveDvdrPhysicalInformation.Visible       = this.scsiInfo.DvdrPhysicalInformation != null;
            btnSaveHddvdrMediumStatus.Visible            = this.scsiInfo.HddvdrMediumStatus != null;
            btnSaveHddvdrLastRmd.Visible                 = this.scsiInfo.HddvdrLastRmd != null;
            btnSaveDvdrLayerCapacity.Visible             = this.scsiInfo.DvdrLayerCapacity != null;
            btnSaveDvdrDlMiddleZoneStart.Visible         = this.scsiInfo.DvdrDlMiddleZoneStart != null;
            btnSaveDvdrDlJumpIntervalSize.Visible        = this.scsiInfo.DvdrDlJumpIntervalSize != null;
            btnSaveDvdrDlManualLayerJumpStartLba.Visible = this.scsiInfo.DvdrDlManualLayerJumpStartLba != null;
            btnSaveDvdrDlRemapAnchorPoint.Visible        = this.scsiInfo.DvdrDlRemapAnchorPoint != null;
            btnSaveDvdPlusAdip.Visible                   = this.scsiInfo.DvdPlusAdip != null;
            btnSaveDvdPlusDcb.Visible                    = this.scsiInfo.DvdPlusDcb != null;

            tabDvdr.Visible = grpDvdRamDds.Visible || grpDvdRamCartridgeStatus.Visible ||
                              grpDvdRamSpareAreaInformation.Visible || btnSaveDvdRamDds.Visible ||
                              btnSaveDvdRamCartridgeStatus.Visible || btnSaveDvdRamSpareAreaInformation.Visible ||
                              btnSaveLastBorderOutRmd.Visible || btnSaveDvdPreRecordedInfo.Visible ||
                              btnSaveDvdrMediaIdentifier.Visible || btnSaveDvdrPhysicalInformation.Visible ||
                              btnSaveHddvdrMediumStatus.Visible || btnSaveHddvdrLastRmd.Visible ||
                              btnSaveDvdrLayerCapacity.Visible || btnSaveDvdrDlMiddleZoneStart.Visible ||
                              btnSaveDvdrDlJumpIntervalSize.Visible || btnSaveDvdrDlManualLayerJumpStartLba.Visible ||
                              btnSaveDvdrDlRemapAnchorPoint.Visible || btnSaveDvdPlusAdip.Visible ||
                              btnSaveDvdPlusDcb.Visible;

            if (this.scsiInfo.BlurayDiscInformation != null)
            {
                grpBlurayDiscInformation.Visible     = true;
                btnSaveBlurayDiscInformation.Visible = true;
                txtBlurayDiscInformation.Text        = DI.Prettify(this.scsiInfo.BlurayDiscInformation);
            }

            if (this.scsiInfo.BlurayBurstCuttingArea != null)
            {
                grpBlurayBurstCuttingArea.Visible     = true;
                btnSaveBlurayBurstCuttingArea.Visible = true;
                txtBlurayBurstCuttingArea.Text        = BCA.Prettify(this.scsiInfo.BlurayBurstCuttingArea);
            }

            if (this.scsiInfo.BlurayDds != null)
            {
                grpBlurayDds.Visible     = true;
                btnSaveBlurayDds.Visible = true;
                txtBlurayDds.Text        = Decoders.Bluray.DDS.Prettify(this.scsiInfo.BlurayDds);
            }

            if (this.scsiInfo.BlurayCartridgeStatus != null)
            {
                grpBlurayCartridgeStatus.Visible     = true;
                btnSaveBlurayCartridgeStatus.Visible = true;
                txtBlurayCartridgeStatus.Text        =
                    Decoders.Bluray.Cartridge.Prettify(this.scsiInfo.BlurayCartridgeStatus);
            }

            if (this.scsiInfo.BluraySpareAreaInformation != null)
            {
                grpBluraySpareAreaInformation.Visible     = true;
                btnSaveBluraySpareAreaInformation.Visible = true;
                txtBluraySpareAreaInformation.Text        =
                    Decoders.Bluray.Spare.Prettify(this.scsiInfo.BluraySpareAreaInformation);
            }

            if (this.scsiInfo.BlurayPowResources != null)
            {
                grpBlurayPowResources.Visible     = true;
                btnSaveBlurayPowResources.Visible = true;
                txtBlurayPowResources.Text        = DiscInformation.Prettify(this.scsiInfo.BlurayPowResources);
            }

            if (this.scsiInfo.BlurayTrackResources != null)
            {
                grpBlurayTrackResources.Visible     = true;
                btnSaveBlurayTrackResources.Visible = true;
                txtBlurayTrackResources.Text        = DiscInformation.Prettify(this.scsiInfo.BlurayTrackResources);
            }

            btnSaveBlurayRawDfl.Visible = this.scsiInfo.BlurayRawDfl != null;
            btnSaveBlurayPac.Visible    = this.scsiInfo.BlurayPac != null;

            tabBluray.Visible = grpBlurayDiscInformation.Visible || grpBlurayBurstCuttingArea.Visible ||
                                grpBlurayDds.Visible || grpBlurayCartridgeStatus.Visible ||
                                grpBluraySpareAreaInformation.Visible || grpBlurayPowResources.Visible ||
                                grpBlurayTrackResources.Visible || btnSaveBlurayRawDfl.Visible ||
                                btnSaveBlurayPac.Visible;
        }
예제 #2
0
        // TODO: More graphically aware decoders
        void OnCmbTagSelectedIndexChanged(object sender, EventArgs e)
        {
            if (!(cmbTag.SelectedValue is MediaTagWithData tagWithData))
            {
                return;
            }

            // TODO: Decoders should be able to handle tags with/without length header
            txtPrintHex.Text   = PrintHex.ByteArrayToHexArrayString(tagWithData.Data, HEX_COLUMNS);
            tabDecoded.Visible = true;
            switch (tagWithData.Tag)
            {
            case MediaTagType.CD_TOC:
                txtDecoded.Text = TOC.Prettify(tagWithData.Data);
                break;

            case MediaTagType.CD_SessionInfo:
                txtDecoded.Text = Session.Prettify(tagWithData.Data);
                break;

            case MediaTagType.CD_FullTOC:
                txtDecoded.Text = FullTOC.Prettify(tagWithData.Data);
                break;

            case MediaTagType.CD_PMA:
                txtDecoded.Text = PMA.Prettify(tagWithData.Data);
                break;

            case MediaTagType.CD_ATIP:
                txtDecoded.Text = ATIP.Prettify(tagWithData.Data);
                break;

            case MediaTagType.CD_TEXT:
                txtDecoded.Text = CDTextOnLeadIn.Prettify(tagWithData.Data);
                break;

            case MediaTagType.CD_MCN:
                txtDecoded.Text = Encoding.ASCII.GetString(tagWithData.Data);
                break;

            case MediaTagType.DVD_PFI:
                txtDecoded.Text = PFI.Prettify(tagWithData.Data);
                break;

            case MediaTagType.DVD_CMI:
                txtDecoded.Text = CSS_CPRM.PrettifyLeadInCopyright(tagWithData.Data);
                break;

            case MediaTagType.DVDRAM_DDS:
                txtDecoded.Text = DDS.Prettify(tagWithData.Data);
                break;

            case MediaTagType.DVDRAM_SpareArea:
                txtDecoded.Text = Spare.Prettify(tagWithData.Data);
                break;

            case MediaTagType.DVDR_PFI:
                txtDecoded.Text = PFI.Prettify(tagWithData.Data);
                break;

            case MediaTagType.HDDVD_MediumStatus:
                txtDecoded.Text = PFI.Prettify(tagWithData.Data);
                break;

            case MediaTagType.BD_DI:
                txtDecoded.Text = DI.Prettify(tagWithData.Data);
                break;

            case MediaTagType.BD_BCA:
                txtDecoded.Text = BCA.Prettify(tagWithData.Data);
                break;

            case MediaTagType.BD_DDS:
                txtDecoded.Text = Decoders.Bluray.DDS.Prettify(tagWithData.Data);
                break;

            case MediaTagType.BD_CartridgeStatus:
                txtDecoded.Text = Cartridge.Prettify(tagWithData.Data);
                break;

            case MediaTagType.BD_SpareArea:
                txtDecoded.Text = Decoders.Bluray.Spare.Prettify(tagWithData.Data);
                break;

            case MediaTagType.MMC_WriteProtection:
                txtDecoded.Text = WriteProtect.PrettifyWriteProtectionStatus(tagWithData.Data);
                break;

            case MediaTagType.MMC_DiscInformation:
                txtDecoded.Text = DiscInformation.Prettify(tagWithData.Data);
                break;

            case MediaTagType.SCSI_INQUIRY:
                txtDecoded.Text = Inquiry.Prettify(tagWithData.Data);
                break;

            case MediaTagType.SCSI_MODEPAGE_2A:
                txtDecoded.Text = Modes.PrettifyModePage_2A(tagWithData.Data);
                break;

            case MediaTagType.ATA_IDENTIFY:
            case MediaTagType.ATAPI_IDENTIFY:
                txtDecoded.Text = Identify.Prettify(tagWithData.Data);
                break;

            case MediaTagType.Xbox_SecuritySector:
                txtDecoded.Text = SS.Prettify(tagWithData.Data);
                break;

            case MediaTagType.SCSI_MODESENSE_6:
                txtDecoded.Text = Modes.PrettifyModeHeader6(tagWithData.Data, PeripheralDeviceTypes.DirectAccess);
                break;

            case MediaTagType.SCSI_MODESENSE_10:
                txtDecoded.Text = Modes.PrettifyModeHeader10(tagWithData.Data, PeripheralDeviceTypes.DirectAccess);
                break;

            case MediaTagType.Xbox_DMI:
                txtDecoded.Text = DMI.IsXbox360(tagWithData.Data)
                                          ? DMI.PrettifyXbox360(tagWithData.Data)
                                          : DMI.PrettifyXbox(tagWithData.Data);
                break;

            default:
                tabDecoded.Visible = false;
                break;
            }
        }
예제 #3
0
        static void DoScsiMediaInfo(string outputPrefix, Device dev)
        {
            ScsiInfo scsiInfo = new ScsiInfo(dev);

            if (!scsiInfo.MediaInserted)
            {
                return;
            }

            if (scsiInfo.DeviceInfo.ScsiModeSense6 != null)
            {
                DataFile.WriteTo("Media-Info command", outputPrefix, "_scsi_modesense6.bin", "SCSI MODE SENSE (6)",
                                 scsiInfo.DeviceInfo.ScsiModeSense6);
            }
            if (scsiInfo.DeviceInfo.ScsiModeSense10 != null)
            {
                DataFile.WriteTo("Media-Info command", outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE (10)",
                                 scsiInfo.DeviceInfo.ScsiModeSense10);
            }

            switch (dev.ScsiType)
            {
            case PeripheralDeviceTypes.DirectAccess:
            case PeripheralDeviceTypes.MultiMediaDevice:
            case PeripheralDeviceTypes.OCRWDevice:
            case PeripheralDeviceTypes.OpticalDevice:
            case PeripheralDeviceTypes.SimplifiedDevice:
            case PeripheralDeviceTypes.WriteOnceDevice:
                if (scsiInfo.ReadCapacity != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readcapacity.bin", "SCSI READ CAPACITY",
                                     scsiInfo.ReadCapacity);
                }

                if (scsiInfo.ReadCapacity16 != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readcapacity16.bin",
                                     "SCSI READ CAPACITY(16)", scsiInfo.ReadCapacity16);
                }

                if (scsiInfo.Blocks != 0 && scsiInfo.BlockSize != 0)
                {
                    DicConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)",
                                         scsiInfo.Blocks, scsiInfo.BlockSize, scsiInfo.Blocks * scsiInfo.BlockSize);
                }

                break;

            case PeripheralDeviceTypes.SequentialAccess:
                if (scsiInfo.DensitySupport != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_ssc_reportdensitysupport_media.bin",
                                     "SSC REPORT DENSITY SUPPORT (MEDIA)", scsiInfo.DensitySupport);
                    if (scsiInfo.DensitySupportHeader.HasValue)
                    {
                        DicConsole.WriteLine("Densities supported by currently inserted media:");
                        DicConsole.WriteLine(DensitySupport.PrettifyDensity(scsiInfo.DensitySupportHeader));
                    }
                }

                if (scsiInfo.MediaTypeSupport != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix,
                                     "_ssc_reportdensitysupport_medium_media.bin",
                                     "SSC REPORT DENSITY SUPPORT (MEDIUM & MEDIA)", scsiInfo.MediaTypeSupport);
                    if (scsiInfo.MediaTypeSupportHeader.HasValue)
                    {
                        DicConsole.WriteLine("Medium types currently inserted in device:");
                        DicConsole.WriteLine(DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupportHeader));
                    }

                    DicConsole.WriteLine(DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupport));
                }

                break;
            }

            if (dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
            {
                if (scsiInfo.MmcConfiguration != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_getconfiguration_current.bin",
                                     "SCSI GET CONFIGURATION", scsiInfo.MmcConfiguration);
                }

                if (scsiInfo.RecognizedFormatLayers != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_formatlayers.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.RecognizedFormatLayers);
                }

                if (scsiInfo.WriteProtectionStatus != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_writeprotection.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.WriteProtectionStatus);
                }

                if (scsiInfo.DvdPfi != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_pfi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdPfi);

                    if (scsiInfo.DecodedPfi.HasValue)
                    {
                        DicConsole.WriteLine("PFI:\n{0}", PFI.Prettify(scsiInfo.DecodedPfi));
                    }
                }

                if (scsiInfo.DvdDmi != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_dmi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdDmi);
                    if (DMI.IsXbox(scsiInfo.DvdDmi))
                    {
                        DicConsole.WriteLine("Xbox DMI:\n{0}", DMI.PrettifyXbox(scsiInfo.DvdDmi));
                    }
                    else if (DMI.IsXbox360(scsiInfo.DvdDmi))
                    {
                        DicConsole.WriteLine("Xbox 360 DMI:\n{0}", DMI.PrettifyXbox360(scsiInfo.DvdDmi));
                    }
                }

                if (scsiInfo.DvdCmi != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_cmi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdCmi);
                    DicConsole.WriteLine("Lead-In CMI:\n{0}", CSS_CPRM.PrettifyLeadInCopyright(scsiInfo.DvdCmi));
                }

                if (scsiInfo.DvdBca != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_bca.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdBca);
                }
                if (scsiInfo.DvdAacs != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_aacs.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdAacs);
                }
                if (scsiInfo.DvdRamDds != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_dds.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdRamDds);
                    DicConsole.WriteLine("Disc Definition Structure:\n{0}", DDS.Prettify(scsiInfo.DvdRamDds));
                }

                if (scsiInfo.DvdRamCartridgeStatus != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_status.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdRamCartridgeStatus);
                    DicConsole.WriteLine("Medium Status:\n{0}", Cartridge.Prettify(scsiInfo.DvdRamCartridgeStatus));
                }

                if (scsiInfo.DvdRamSpareArea != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_spare.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdRamSpareArea);
                    DicConsole.WriteLine("Spare Area Information:\n{0}", Spare.Prettify(scsiInfo.DvdRamSpareArea));
                }

                if (scsiInfo.LastBorderOutRmd != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_lastrmd.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.LastBorderOutRmd);
                }

                if (scsiInfo.DvdPreRecordedInfo != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_pri.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdPreRecordedInfo);
                }

                if (scsiInfo.DvdrMediaIdentifier != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_mediaid.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrMediaIdentifier);
                }
                if (scsiInfo.DvdrPhysicalInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_pfi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrPhysicalInformation);
                }
                if (scsiInfo.DvdPlusAdip != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd+_adip.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusAdip);
                }

                if (scsiInfo.DvdPlusDcb != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd+_dcb.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusDcb);
                }
                if (scsiInfo.HddvdCopyrightInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvd_cmi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.HddvdCopyrightInformation);
                }
                if (scsiInfo.HddvdrMediumStatus != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvdr_status.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.HddvdrMediumStatus);
                }

                if (scsiInfo.HddvdrLastRmd != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvdr_lastrmd.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.HddvdrLastRmd);
                }

                if (scsiInfo.DvdrLayerCapacity != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_layercap.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrLayerCapacity);
                }

                if (scsiInfo.DvdrDlMiddleZoneStart != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_mzs.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlMiddleZoneStart);
                }

                if (scsiInfo.DvdrDlJumpIntervalSize != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_jis.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlJumpIntervalSize);
                }

                if (scsiInfo.DvdrDlManualLayerJumpStartLba != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_manuallj.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlManualLayerJumpStartLba);
                }

                if (scsiInfo.DvdrDlRemapAnchorPoint != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_remapanchor.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlRemapAnchorPoint);
                }
                if (scsiInfo.BlurayDiscInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_di.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayDiscInformation);
                    DicConsole.WriteLine("Blu-ray Disc Information:\n{0}", DI.Prettify(scsiInfo.BlurayDiscInformation));
                }

                if (scsiInfo.BlurayPac != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_pac.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayPac);
                }

                if (scsiInfo.BlurayBurstCuttingArea != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_bca.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayBurstCuttingArea);
                    DicConsole.WriteLine("Blu-ray Burst Cutting Area:\n{0}",
                                         BCA.Prettify(scsiInfo.BlurayBurstCuttingArea));
                }

                if (scsiInfo.BlurayDds != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_dds.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayDds);
                    DicConsole.WriteLine("Blu-ray Disc Definition Structure:\n{0}",
                                         Decoders.Bluray.DDS.Prettify(scsiInfo.BlurayDds));
                }

                if (scsiInfo.BlurayCartridgeStatus != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_cartstatus.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayCartridgeStatus);
                    DicConsole.WriteLine("Blu-ray Cartridge Status:\n{0}",
                                         Decoders.Bluray.Cartridge.Prettify(scsiInfo.BlurayCartridgeStatus));
                }

                if (scsiInfo.BluraySpareAreaInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_spare.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BluraySpareAreaInformation);
                    DicConsole.WriteLine("Blu-ray Spare Area Information:\n{0}",
                                         Decoders.Bluray.Spare.Prettify(scsiInfo.BluraySpareAreaInformation));
                }

                if (scsiInfo.BlurayRawDfl != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_dfl.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayRawDfl);
                }

                if (scsiInfo.BlurayTrackResources != null)
                {
                    DicConsole.WriteLine("Track Resources Information:\n{0}",
                                         DiscInformation.Prettify(scsiInfo.BlurayTrackResources));
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_001b.bin",
                                     "SCSI READ DISC INFORMATION", scsiInfo.BlurayTrackResources);
                }

                if (scsiInfo.BlurayPowResources != null)
                {
                    DicConsole.WriteLine("POW Resources Information:\n{0}",
                                         DiscInformation.Prettify(scsiInfo.BlurayPowResources));
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_010b.bin",
                                     "SCSI READ DISC INFORMATION", scsiInfo.BlurayPowResources);
                }

                if (scsiInfo.Toc != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_toc.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.Toc);
                    if (scsiInfo.DecodedToc.HasValue)
                    {
                        DicConsole.WriteLine("TOC:\n{0}", TOC.Prettify(scsiInfo.DecodedToc));
                    }
                }

                if (scsiInfo.Atip != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_atip.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.Atip);
                    if (scsiInfo.DecodedAtip.HasValue)
                    {
                        DicConsole.WriteLine("ATIP:\n{0}", ATIP.Prettify(scsiInfo.DecodedAtip));
                    }
                }

                if (scsiInfo.CompactDiscInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_000b.bin",
                                     "SCSI READ DISC INFORMATION", scsiInfo.CompactDiscInformation);
                    if (scsiInfo.DecodedCompactDiscInformation.HasValue)
                    {
                        DicConsole.WriteLine("Standard Disc Information:\n{0}",
                                             DiscInformation.Prettify000b(scsiInfo.DecodedCompactDiscInformation));
                    }
                }

                if (scsiInfo.Session != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_session.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.Session);
                    if (scsiInfo.DecodedSession.HasValue)
                    {
                        DicConsole.WriteLine("Session information:\n{0}", Session.Prettify(scsiInfo.DecodedSession));
                    }
                }

                if (scsiInfo.RawToc != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_rawtoc.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.RawToc);
                    if (scsiInfo.FullToc.HasValue)
                    {
                        DicConsole.WriteLine("Raw TOC:\n{0}", FullTOC.Prettify(scsiInfo.RawToc));
                    }
                }

                if (scsiInfo.Pma != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_pma.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.Pma);
                    DicConsole.WriteLine("PMA:\n{0}", PMA.Prettify(scsiInfo.Pma));
                }

                if (scsiInfo.CdTextLeadIn != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_cdtext.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.CdTextLeadIn);
                    if (scsiInfo.DecodedCdTextLeadIn.HasValue)
                    {
                        DicConsole.WriteLine("CD-TEXT on Lead-In:\n{0}",
                                             CDTextOnLeadIn.Prettify(scsiInfo.DecodedCdTextLeadIn));
                    }
                }

                if (!string.IsNullOrEmpty(scsiInfo.Mcn))
                {
                    DicConsole.WriteLine("MCN: {0}", scsiInfo.Mcn);
                }

                if (scsiInfo.Isrcs != null)
                {
                    foreach (KeyValuePair <byte, string> isrc in scsiInfo.Isrcs)
                    {
                        DicConsole.WriteLine("Track's {0} ISRC: {1}", isrc.Key, isrc.Value);
                    }
                }

                if (scsiInfo.XboxSecuritySector != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_xbox_ss.bin", "KREON EXTRACT SS",
                                     scsiInfo.XboxSecuritySector);
                }

                if (scsiInfo.DecodedXboxSecuritySector.HasValue)
                {
                    DicConsole.WriteLine("Xbox Security Sector:\n{0}", SS.Prettify(scsiInfo.DecodedXboxSecuritySector));
                }

                if (scsiInfo.XgdInfo != null)
                {
                    DicConsole.WriteLine("Video layer 0 size: {0} sectors", scsiInfo.XgdInfo.L0Video);
                    DicConsole.WriteLine("Video layer 1 size: {0} sectors", scsiInfo.XgdInfo.L1Video);
                    DicConsole.WriteLine("Middle zone size: {0} sectors", scsiInfo.XgdInfo.MiddleZone);
                    DicConsole.WriteLine("Game data size: {0} sectors", scsiInfo.XgdInfo.GameSize);
                    DicConsole.WriteLine("Total size: {0} sectors", scsiInfo.XgdInfo.TotalSize);
                    DicConsole.WriteLine("Real layer break: {0}", scsiInfo.XgdInfo.LayerBreak);
                    DicConsole.WriteLine();
                }
            }

            if (scsiInfo.MediaSerialNumber != null)
            {
                DataFile.WriteTo("Media-Info command", outputPrefix, "_mediaserialnumber.bin",
                                 "SCSI READ MEDIA SERIAL NUMBER", scsiInfo.MediaSerialNumber);

                DicConsole.Write("Media Serial Number: ");
                for (int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
                {
                    DicConsole.Write("{0:X2}", scsiInfo.MediaSerialNumber[i]);
                }

                DicConsole.WriteLine();
            }

            DicConsole.WriteLine("Media identified as {0}", scsiInfo.MediaType);
            Core.Statistics.AddMedia(scsiInfo.MediaType, true);
        }
예제 #4
0
        static void DoScsiMediaInfo(bool debug, bool verbose, string outputPrefix, Devices.Device dev)
        {
            var scsiInfo = new ScsiInfo(dev);

            if (!scsiInfo.MediaInserted)
            {
                return;
            }

            if (scsiInfo.DeviceInfo.ScsiModeSense6 != null)
            {
                DataFile.WriteTo("Media-Info command", outputPrefix, "_scsi_modesense6.bin", "SCSI MODE SENSE (6)",
                                 scsiInfo.DeviceInfo.ScsiModeSense6);
            }

            if (scsiInfo.DeviceInfo.ScsiModeSense10 != null)
            {
                DataFile.WriteTo("Media-Info command", outputPrefix, "_scsi_modesense10.bin", "SCSI MODE SENSE (10)",
                                 scsiInfo.DeviceInfo.ScsiModeSense10);
            }

            switch (dev.ScsiType)
            {
            case PeripheralDeviceTypes.DirectAccess:
            case PeripheralDeviceTypes.MultiMediaDevice:
            case PeripheralDeviceTypes.OCRWDevice:
            case PeripheralDeviceTypes.OpticalDevice:
            case PeripheralDeviceTypes.SimplifiedDevice:
            case PeripheralDeviceTypes.WriteOnceDevice:
                if (scsiInfo.ReadCapacity != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readcapacity.bin", "SCSI READ CAPACITY",
                                     scsiInfo.ReadCapacity);
                }

                if (scsiInfo.ReadCapacity16 != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readcapacity16.bin",
                                     "SCSI READ CAPACITY(16)", scsiInfo.ReadCapacity16);
                }

                if (scsiInfo.Blocks != 0 &&
                    scsiInfo.BlockSize != 0)
                {
                    DicConsole.WriteLine("Media has {0} blocks of {1} bytes/each. (for a total of {2} bytes)",
                                         scsiInfo.Blocks, scsiInfo.BlockSize, scsiInfo.Blocks * scsiInfo.BlockSize);
                }

                break;

            case PeripheralDeviceTypes.SequentialAccess:
                if (scsiInfo.DensitySupport != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_ssc_reportdensitysupport_media.bin",
                                     "SSC REPORT DENSITY SUPPORT (MEDIA)", scsiInfo.DensitySupport);

                    if (scsiInfo.DensitySupportHeader.HasValue)
                    {
                        DicConsole.WriteLine("Densities supported by currently inserted media:");
                        DicConsole.WriteLine(DensitySupport.PrettifyDensity(scsiInfo.DensitySupportHeader));
                    }
                }

                if (scsiInfo.MediaTypeSupport != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix,
                                     "_ssc_reportdensitysupport_medium_media.bin",
                                     "SSC REPORT DENSITY SUPPORT (MEDIUM & MEDIA)", scsiInfo.MediaTypeSupport);

                    if (scsiInfo.MediaTypeSupportHeader.HasValue)
                    {
                        DicConsole.WriteLine("Medium types currently inserted in device:");
                        DicConsole.WriteLine(DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupportHeader));
                    }

                    DicConsole.WriteLine(DensitySupport.PrettifyMediumType(scsiInfo.MediaTypeSupport));
                }

                break;
            }

            if (dev.ScsiType == PeripheralDeviceTypes.MultiMediaDevice)
            {
                if (scsiInfo.MmcConfiguration != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_getconfiguration_current.bin",
                                     "SCSI GET CONFIGURATION", scsiInfo.MmcConfiguration);
                }

                if (scsiInfo.RecognizedFormatLayers != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_formatlayers.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.RecognizedFormatLayers);
                }

                if (scsiInfo.WriteProtectionStatus != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_writeprotection.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.WriteProtectionStatus);
                }

                if (scsiInfo.DvdPfi != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_pfi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdPfi);

                    if (scsiInfo.DecodedPfi.HasValue)
                    {
                        DicConsole.WriteLine("PFI:\n{0}", PFI.Prettify(scsiInfo.DecodedPfi));
                    }
                }

                if (scsiInfo.DvdDmi != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_dmi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdDmi);

                    if (DMI.IsXbox(scsiInfo.DvdDmi))
                    {
                        DicConsole.WriteLine("Xbox DMI:\n{0}", DMI.PrettifyXbox(scsiInfo.DvdDmi));
                    }
                    else if (DMI.IsXbox360(scsiInfo.DvdDmi))
                    {
                        DicConsole.WriteLine("Xbox 360 DMI:\n{0}", DMI.PrettifyXbox360(scsiInfo.DvdDmi));
                    }
                }

                if (scsiInfo.DvdCmi != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_cmi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdCmi);

                    DicConsole.WriteLine("Lead-In CMI:\n{0}", CSS_CPRM.PrettifyLeadInCopyright(scsiInfo.DvdCmi));
                }

                if (scsiInfo.DvdBca != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_bca.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdBca);
                }

                if (scsiInfo.DvdAacs != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_aacs.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdAacs);
                }

                if (scsiInfo.DvdRamDds != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_dds.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdRamDds);

                    DicConsole.WriteLine("Disc Definition Structure:\n{0}", DDS.Prettify(scsiInfo.DvdRamDds));
                }

                if (scsiInfo.DvdRamCartridgeStatus != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_status.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdRamCartridgeStatus);

                    DicConsole.WriteLine("Medium Status:\n{0}", Cartridge.Prettify(scsiInfo.DvdRamCartridgeStatus));
                }

                if (scsiInfo.DvdRamSpareArea != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdram_spare.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdRamSpareArea);

                    DicConsole.WriteLine("Spare Area Information:\n{0}", Spare.Prettify(scsiInfo.DvdRamSpareArea));
                }

                if (scsiInfo.LastBorderOutRmd != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_lastrmd.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.LastBorderOutRmd);
                }

                if (scsiInfo.DvdPreRecordedInfo != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_pri.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdPreRecordedInfo);
                }

                if (scsiInfo.DvdrMediaIdentifier != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_mediaid.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrMediaIdentifier);
                }

                if (scsiInfo.DvdrPhysicalInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_pfi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrPhysicalInformation);
                }

                if (scsiInfo.DvdPlusAdip != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd+_adip.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusAdip);
                }

                if (scsiInfo.DvdPlusDcb != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd+_dcb.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdPlusDcb);
                }

                if (scsiInfo.HddvdCopyrightInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvd_cmi.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.HddvdCopyrightInformation);
                }

                if (scsiInfo.HddvdrMediumStatus != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvdr_status.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.HddvdrMediumStatus);
                }

                if (scsiInfo.HddvdrLastRmd != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_hddvdr_lastrmd.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.HddvdrLastRmd);
                }

                if (scsiInfo.DvdrLayerCapacity != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvdr_layercap.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrLayerCapacity);
                }

                if (scsiInfo.DvdrDlMiddleZoneStart != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_mzs.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlMiddleZoneStart);
                }

                if (scsiInfo.DvdrDlJumpIntervalSize != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_jis.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlJumpIntervalSize);
                }

                if (scsiInfo.DvdrDlManualLayerJumpStartLba != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_manuallj.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlManualLayerJumpStartLba);
                }

                if (scsiInfo.DvdrDlRemapAnchorPoint != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_dvd_remapanchor.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.DvdrDlRemapAnchorPoint);
                }

                if (scsiInfo.BlurayDiscInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_di.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayDiscInformation);

                    DicConsole.WriteLine("Blu-ray Disc Information:\n{0}", DI.Prettify(scsiInfo.BlurayDiscInformation));
                }

                if (scsiInfo.BlurayPac != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_pac.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayPac);
                }

                if (scsiInfo.BlurayBurstCuttingArea != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_bca.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayBurstCuttingArea);

                    DicConsole.WriteLine("Blu-ray Burst Cutting Area:\n{0}",
                                         BCA.Prettify(scsiInfo.BlurayBurstCuttingArea));
                }

                if (scsiInfo.BlurayDds != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_dds.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayDds);

                    DicConsole.WriteLine("Blu-ray Disc Definition Structure:\n{0}",
                                         Decoders.Bluray.DDS.Prettify(scsiInfo.BlurayDds));
                }

                if (scsiInfo.BlurayCartridgeStatus != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_cartstatus.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayCartridgeStatus);

                    DicConsole.WriteLine("Blu-ray Cartridge Status:\n{0}",
                                         Decoders.Bluray.Cartridge.Prettify(scsiInfo.BlurayCartridgeStatus));
                }

                if (scsiInfo.BluraySpareAreaInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_spare.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BluraySpareAreaInformation);

                    DicConsole.WriteLine("Blu-ray Spare Area Information:\n{0}",
                                         Decoders.Bluray.Spare.Prettify(scsiInfo.BluraySpareAreaInformation));
                }

                if (scsiInfo.BlurayRawDfl != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscstructure_bd_dfl.bin",
                                     "SCSI READ DISC STRUCTURE", scsiInfo.BlurayRawDfl);
                }

                if (scsiInfo.BlurayTrackResources != null)
                {
                    DicConsole.WriteLine("Track Resources Information:\n{0}",
                                         DiscInformation.Prettify(scsiInfo.BlurayTrackResources));

                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_001b.bin",
                                     "SCSI READ DISC INFORMATION", scsiInfo.BlurayTrackResources);
                }

                if (scsiInfo.BlurayPowResources != null)
                {
                    DicConsole.WriteLine("POW Resources Information:\n{0}",
                                         DiscInformation.Prettify(scsiInfo.BlurayPowResources));

                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_010b.bin",
                                     "SCSI READ DISC INFORMATION", scsiInfo.BlurayPowResources);
                }

                if (scsiInfo.Toc != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_toc.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.Toc);

                    if (scsiInfo.DecodedToc.HasValue)
                    {
                        DicConsole.WriteLine("TOC:\n{0}", TOC.Prettify(scsiInfo.DecodedToc));
                    }
                }

                if (scsiInfo.Atip != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_atip.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.Atip);

                    if (scsiInfo.DecodedAtip.HasValue)
                    {
                        DicConsole.WriteLine("ATIP:\n{0}", ATIP.Prettify(scsiInfo.DecodedAtip));
                    }
                }

                if (scsiInfo.CompactDiscInformation != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_readdiscinformation_000b.bin",
                                     "SCSI READ DISC INFORMATION", scsiInfo.CompactDiscInformation);

                    if (scsiInfo.DecodedCompactDiscInformation.HasValue)
                    {
                        DicConsole.WriteLine("Standard Disc Information:\n{0}",
                                             DiscInformation.Prettify000b(scsiInfo.DecodedCompactDiscInformation));
                    }
                }

                if (scsiInfo.Session != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_session.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.Session);

                    if (scsiInfo.DecodedSession.HasValue)
                    {
                        DicConsole.WriteLine("Session information:\n{0}", Session.Prettify(scsiInfo.DecodedSession));
                    }
                }

                if (scsiInfo.RawToc != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_rawtoc.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.RawToc);

                    if (scsiInfo.FullToc.HasValue)
                    {
                        DicConsole.WriteLine("Raw TOC:\n{0}", FullTOC.Prettify(scsiInfo.RawToc));
                    }
                }

                if (scsiInfo.Pma != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_pma.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.Pma);

                    DicConsole.WriteLine("PMA:\n{0}", PMA.Prettify(scsiInfo.Pma));
                }

                if (scsiInfo.CdTextLeadIn != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_cdtext.bin", "SCSI READ TOC/PMA/ATIP",
                                     scsiInfo.CdTextLeadIn);

                    if (scsiInfo.DecodedCdTextLeadIn.HasValue)
                    {
                        DicConsole.WriteLine("CD-TEXT on Lead-In:\n{0}",
                                             CDTextOnLeadIn.Prettify(scsiInfo.DecodedCdTextLeadIn));
                    }
                }

                if (!string.IsNullOrEmpty(scsiInfo.Mcn))
                {
                    DicConsole.WriteLine("MCN: {0}", scsiInfo.Mcn);
                }

                if (scsiInfo.Isrcs != null)
                {
                    foreach (KeyValuePair <byte, string> isrc in scsiInfo.Isrcs)
                    {
                        DicConsole.WriteLine("Track's {0} ISRC: {1}", isrc.Key, isrc.Value);
                    }
                }

                if (scsiInfo.XboxSecuritySector != null)
                {
                    DataFile.WriteTo("Media-Info command", outputPrefix, "_xbox_ss.bin", "KREON EXTRACT SS",
                                     scsiInfo.XboxSecuritySector);
                }

                if (scsiInfo.DecodedXboxSecuritySector.HasValue)
                {
                    DicConsole.WriteLine("Xbox Security Sector:\n{0}", SS.Prettify(scsiInfo.DecodedXboxSecuritySector));
                }

                if (scsiInfo.XgdInfo != null)
                {
                    DicConsole.WriteLine("Video layer 0 size: {0} sectors", scsiInfo.XgdInfo.L0Video);
                    DicConsole.WriteLine("Video layer 1 size: {0} sectors", scsiInfo.XgdInfo.L1Video);
                    DicConsole.WriteLine("Middle zone size: {0} sectors", scsiInfo.XgdInfo.MiddleZone);
                    DicConsole.WriteLine("Game data size: {0} sectors", scsiInfo.XgdInfo.GameSize);
                    DicConsole.WriteLine("Total size: {0} sectors", scsiInfo.XgdInfo.TotalSize);
                    DicConsole.WriteLine("Real layer break: {0}", scsiInfo.XgdInfo.LayerBreak);
                    DicConsole.WriteLine();
                }
            }

            if (scsiInfo.MediaSerialNumber != null)
            {
                DataFile.WriteTo("Media-Info command", outputPrefix, "_mediaserialnumber.bin",
                                 "SCSI READ MEDIA SERIAL NUMBER", scsiInfo.MediaSerialNumber);

                DicConsole.Write("Media Serial Number: ");

                for (int i = 4; i < scsiInfo.MediaSerialNumber.Length; i++)
                {
                    DicConsole.Write("{0:X2}", scsiInfo.MediaSerialNumber[i]);
                }

                DicConsole.WriteLine();
            }

            DicConsole.WriteLine("Media identified as {0}", scsiInfo.MediaType);
            Statistics.AddMedia(scsiInfo.MediaType, true);

            if (scsiInfo.Toc != null ||
                scsiInfo.RawToc != null)
            {
                uint blockSize = 2352;

                Track[] tracks = Dump.GetCdTracks(ref blockSize, dev, scsiInfo.MediaType, null, false,
                                                  out long lastSector, null, null, null, TrackSubchannelType.None,
                                                  out _, null, null);

                if (tracks != null)
                {
                    bool supportsPqSubchannel = Dump.SupportsPqSubchannel(dev, null, null);
                    bool supportsRwSubchannel = Dump.SupportsRwSubchannel(dev, null, null);

                    // Open master database
                    var ctx = DicContext.Create(Settings.Settings.MasterDbPath);

                    // Search for device in master database
                    Database.Models.Device dbDev =
                        ctx.Devices.FirstOrDefault(d => d.Manufacturer == dev.Manufacturer && d.Model == dev.Model &&
                                                   d.Revision == dev.FirmwareRevision);

                    Dump.SolveTrackPregaps(dev, null, null, tracks, supportsPqSubchannel, supportsRwSubchannel, dbDev,
                                           out bool inexactPositioning);

                    for (int t = 1; t < tracks.Length; t++)
                    {
                        tracks[t - 1].TrackEndSector = tracks[t].TrackStartSector - 1;
                    }

                    tracks[tracks.Length - 1].TrackEndSector = (ulong)lastSector;

                    DicConsole.WriteLine();
                    DicConsole.WriteLine("Track calculations:");

                    if (inexactPositioning)
                    {
                        DicConsole.
                        WriteLine("WARNING: The drive has returned incorrect Q positioning when calculating pregaps. A best effort has been tried but they may be incorrect.");
                    }

                    foreach (Track track in tracks)
                    {
                        DicConsole.
                        WriteLine("Track {0} starts at LBA {1}, ends at LBA {2}, has a pregap of {3} sectors and is of type {4}",
                                  track.TrackSequence, track.TrackStartSector, track.TrackEndSector,
                                  track.TrackPregap, track.TrackType);
                    }

                    DicConsole.WriteLine();
                    DicConsole.WriteLine("Offsets:");

                    CdOffset cdOffset = null;

                    // Search for read offset in master database
                    cdOffset = ctx.CdOffsets.FirstOrDefault(d => d.Manufacturer == dev.Manufacturer &&
                                                            d.Model == dev.Model);

                    CompactDisc.GetOffset(cdOffset, dbDev, debug, dev, scsiInfo.MediaType, null, tracks, null,
                                          out int?driveOffset, out int?combinedOffset);

                    if (combinedOffset is null)
                    {
                        if (driveOffset is null)
                        {
                            DicConsole.WriteLine("Drive reading offset not found in database.");
                            DicConsole.WriteLine("Disc offset cannot be calculated.");
                        }
                        else
                        {
                            DicConsole.
                            WriteLine($"Drive reading offset is {driveOffset} bytes ({driveOffset / 4} samples).");

                            DicConsole.WriteLine("Disc write offset is unknown.");
                        }
                    }
                    else
                    {
                        int offsetBytes = combinedOffset.Value;

                        if (driveOffset is null)
                        {
                            DicConsole.WriteLine("Drive reading offset not found in database.");

                            DicConsole.
                            WriteLine($"Combined disc and drive offset are {offsetBytes} bytes ({offsetBytes / 4} samples).");
                        }
                        else
                        {
                            DicConsole.
                            WriteLine($"Drive reading offset is {driveOffset} bytes ({driveOffset / 4} samples).");

                            DicConsole.WriteLine($"Combined offset is {offsetBytes} bytes ({offsetBytes / 4} samples)");

                            int?discOffset = offsetBytes - driveOffset;

                            DicConsole.WriteLine($"Disc offset is {discOffset} bytes ({discOffset / 4} samples)");
                        }
                    }
                }
            }

            dev.Close();
        }