void OnNmuSectorValueChanged(object sender, EventArgs e)
 {
     txtPrintHex.Text =
         PrintHex
         .ByteArrayToHexArrayString(chkLongSector.Checked == true ? inputFormat.ReadSectorLong((ulong)nmuSector.Value) : inputFormat.ReadSector((ulong)nmuSector.Value),
                                    HEX_COLUMNS);
 }
Пример #2
0
        public static string PrettifyCPRMMediaKeyBlock(CPRMMediaKeyBlock?CPRMMKBResponse)
        {
            if (CPRMMKBResponse == null)
            {
                return(null);
            }

            CPRMMediaKeyBlock response = CPRMMKBResponse.Value;

            var sb = new StringBuilder();

        #if DEBUG
            if (response.Reserved != 0)
            {
                sb.AppendFormat("Reserved = 0x{0:X2}", response.Reserved).AppendLine();
            }
        #endif
            sb.AppendFormat("Total number of CPRM Media Key Blocks available to transfer: {0}", response.TotalPacks).
            AppendLine();

            sb.AppendFormat("CPRM Media Key Blocks in hex follows:");
            sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.MKBPackData, 80));

            return(sb.ToString());
        }
Пример #3
0
        public static string Prettify(BurstCuttingArea?BCAResponse)
        {
            if (BCAResponse == null)
            {
                return(null);
            }

            BurstCuttingArea response = BCAResponse.Value;

            StringBuilder sb = new StringBuilder();

            #if DEBUG
            if (response.Reserved1 != 0)
            {
                sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
            }
            if (response.Reserved2 != 0)
            {
                sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
            }
            #endif

            sb.AppendFormat("Blu-ray Burst Cutting Area in hex follows:");
            sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.BCA, 80));

            return(sb.ToString());
        }
Пример #4
0
        public static string PrettifyAACSDataKeys(AACSDataKeys?AACSDKResponse)
        {
            if (AACSDKResponse == null)
            {
                return(null);
            }

            AACSDataKeys response = AACSDKResponse.Value;

            StringBuilder sb = new StringBuilder();

            #if DEBUG
            if (response.Reserved1 != 0)
            {
                sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
            }
            if (response.Reserved2 != 0)
            {
                sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
            }
            #endif
            sb.AppendFormat("AACS Data Keys in hex follows:");
            sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.DataKeys, 80));

            return(sb.ToString());
        }
Пример #5
0
        public static string PrettifyAACSVolumeIdentifier(AACSVolumeIdentifier? AACSVIResponse)
        {
            if(AACSVIResponse == null)
                return null;

            AACSVolumeIdentifier response = AACSVIResponse.Value;

            var sb = new StringBuilder();

        #if DEBUG
            if(response.Reserved1 != 0)
                sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();

            if(response.Reserved2 != 0)
                sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
        #endif
            sb.AppendFormat("AACS Volume Identifier in hex follows:");
            sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.VolumeIdentifier, 80));

            return sb.ToString();
        }
Пример #6
0
        public static string PrettifyAACSMediaKeyBlock(AACSMediaKeyBlock? AACSMKBResponse)
        {
            if(AACSMKBResponse == null)
                return null;

            AACSMediaKeyBlock response = AACSMKBResponse.Value;

            var sb = new StringBuilder();

        #if DEBUG
            if(response.Reserved != 0)
                sb.AppendFormat("Reserved = 0x{0:X2}", response.Reserved).AppendLine();
        #endif
            sb.AppendFormat("Total number of media key blocks available to transfer {0}", response.TotalPacks).
               AppendLine();

            sb.AppendFormat("AACS Media Key Blocks in hex follows:");
            sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.MediaKeyBlockPacks, 80));

            return sb.ToString();
        }
Пример #7
0
        public static string Prettify(DiscDefinitionStructure? DDSResponse)
        {
            if(DDSResponse == null) return null;

            DiscDefinitionStructure response = DDSResponse.Value;

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("DDS Format: 0x{0:X2}", response.Format).AppendLine();
            sb.AppendFormat("DDS has ben updated {0} times", response.UpdateCount).AppendLine();
            sb.AppendFormat("First PSN of Drive Area: 0x{0:X8}", response.DriveAreaPSN).AppendLine();
            sb.AppendFormat("First PSN of Defect List: 0x{0:X8}", response.DefectListPSN).AppendLine();
            sb.AppendFormat("PSN of User Data Area's LSN 0: 0x{0:X8}", response.PSNofLSNZero).AppendLine();
            sb.AppendFormat("Last User Data Area's LSN 0: 0x{0:X8}", response.LastUserAreaLSN).AppendLine();
            sb.AppendFormat("ISA0 size: {0}", response.ISA0).AppendLine();
            sb.AppendFormat("OSA size: {0}", response.OSA).AppendLine();
            sb.AppendFormat("ISA1 size: {0}", response.ISA1).AppendLine();
            sb.AppendFormat("Spare Area Full Flags: 0x{0:X2}", response.SpareAreaFullFlags).AppendLine();
            sb.AppendFormat("Disc Type Specific Field 1: 0x{0:X2}", response.DiscTypeSpecificField1).AppendLine();
            sb.AppendFormat("Disc Type Specific Field 2: 0x{0:X8}", response.DiscTypeSpecificField2).AppendLine();
            sb.AppendFormat("Blu-ray DDS Status Bits in hex follows:");
            sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.StatusBits, 80));
            sb.AppendFormat("Blu-ray DDS Disc Type Specific Data in hex follows:");
            sb.AppendLine(PrintHex.ByteArrayToHexArrayString(response.DiscTypeSpecificData, 80));

#if DEBUG
            if(response.Reserved1 != 0) sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
            if(response.Reserved2 != 0) sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
            if(response.Reserved3 != 0) sb.AppendFormat("Reserved3 = 0x{0:X2}", response.Reserved3).AppendLine();
            if(response.Reserved4 != 0) sb.AppendFormat("Reserved4 = 0x{0:X16}", response.Reserved4).AppendLine();
            if(response.Reserved5 != 0) sb.AppendFormat("Reserved5 = 0x{0:X8}", response.Reserved5).AppendLine();
            if(response.Reserved6 != 0) sb.AppendFormat("Reserved6 = 0x{0:X8}", response.Reserved6).AppendLine();
            if(response.Reserved7 != 0) sb.AppendFormat("Reserved7 = 0x{0:X2}", response.Reserved7).AppendLine();
            if(response.Reserved8 != 0) sb.AppendFormat("Reserved8 = 0x{0:X2}", response.Reserved8).AppendLine();
            if(response.Reserved9 != 0) sb.AppendFormat("Reserved9 = 0x{0:X8}", response.Reserved9).AppendLine();
#endif

            return sb.ToString();
        }
Пример #8
0
        public static string Prettify(CDText?CDTextResponse)
        {
            if (CDTextResponse == null)
            {
                return(null);
            }

            CDText        response = CDTextResponse.Value;
            StringBuilder sb       = new StringBuilder();

            #if DEBUG
            if (response.Reserved1 != 0)
            {
                sb.AppendFormat("Reserved1 = 0x{0:X2}", response.Reserved1).AppendLine();
            }
            if (response.Reserved2 != 0)
            {
                sb.AppendFormat("Reserved2 = 0x{0:X2}", response.Reserved2).AppendLine();
            }
            #endif

            foreach (CDTextPack descriptor in response.DataPacks)
            {
                if ((descriptor.HeaderID1 & 0x80) != 0x80)
                {
                    // Ignore NOPs
                    if ((descriptor.HeaderID1 & 0x80) != 0)
                    {
                        sb.AppendFormat("Incorrect CD-Text pack type {0}, not decoding", descriptor.HeaderID1)
                        .AppendLine();
                    }
                }
                else
                {
                    switch (descriptor.HeaderID1)
                    {
                    case 0x80:
                    {
                        sb.Append("CD-Text pack contains title for ");
                        if (descriptor.HeaderID2 == 0x00)
                        {
                            sb.AppendLine("album");
                        }
                        else
                        {
                            sb.AppendFormat("track {0}", descriptor.HeaderID2).AppendLine();
                        }
                        break;
                    }

                    case 0x81:
                    {
                        sb.Append("CD-Text pack contains performer for ");
                        if (descriptor.HeaderID2 == 0x00)
                        {
                            sb.AppendLine("album");
                        }
                        else
                        {
                            sb.AppendFormat("track {0}", descriptor.HeaderID2).AppendLine();
                        }
                        break;
                    }

                    case 0x82:
                    {
                        sb.Append("CD-Text pack contains songwriter for ");
                        if (descriptor.HeaderID2 == 0x00)
                        {
                            sb.AppendLine("album");
                        }
                        else
                        {
                            sb.AppendFormat("track {0}", descriptor.HeaderID2).AppendLine();
                        }
                        break;
                    }

                    case 0x83:
                    {
                        if (descriptor.HeaderID2 == 0x00)
                        {
                            sb.AppendLine("album");
                        }
                        else
                        {
                            sb.AppendFormat("track {0}", descriptor.HeaderID2).AppendLine();
                        }
                        break;
                    }

                    case 0x84:
                    {
                        sb.Append("CD-Text pack contains arranger for ");
                        if (descriptor.HeaderID2 == 0x00)
                        {
                            sb.AppendLine("album");
                        }
                        else
                        {
                            sb.AppendFormat("track {0}", descriptor.HeaderID2).AppendLine();
                        }
                        break;
                    }

                    case 0x85:
                    {
                        sb.Append("CD-Text pack contains content provider's message for ");
                        if (descriptor.HeaderID2 == 0x00)
                        {
                            sb.AppendLine("album");
                        }
                        else
                        {
                            sb.AppendFormat("track {0}", descriptor.HeaderID2).AppendLine();
                        }
                        break;
                    }

                    case 0x86:
                    {
                        sb.AppendLine("CD-Text pack contains disc identification information");
                        break;
                    }

                    case 0x87:
                    {
                        sb.AppendLine("CD-Text pack contains genre identification information");
                        break;
                    }

                    case 0x88:
                    {
                        sb.AppendLine("CD-Text pack contains table of contents information");
                        break;
                    }

                    case 0x89:
                    {
                        sb.AppendLine("CD-Text pack contains second table of contents information");
                        break;
                    }

                    case 0x8A:
                    case 0x8B:
                    case 0x8C:
                    {
                        sb.AppendLine("CD-Text pack contains reserved data");
                        break;
                    }

                    case 0x8D:
                    {
                        sb.AppendLine("CD-Text pack contains data reserved for content provider only");
                        break;
                    }

                    case 0x8E:
                    {
                        if (descriptor.HeaderID2 == 0x00)
                        {
                            sb.AppendLine("CD-Text pack contains UPC");
                        }
                        else
                        {
                            sb.AppendFormat("track {0}", descriptor.HeaderID2).AppendLine();
                        }
                        break;
                    }

                    case 0x8F:
                    {
                        sb.AppendLine("CD-Text pack contains size block information");
                        break;
                    }
                    }

                    switch (descriptor.HeaderID1)
                    {
                    case 0x80:
                    case 0x81:
                    case 0x82:
                    case 0x83:
                    case 0x84:
                    case 0x85:
                    case 0x86:
                    case 0x87:
                    case 0x8E:
                    {
                        if (descriptor.DBCC)
                        {
                            sb.AppendLine("Double Byte Character Code is used");
                        }
                        sb.AppendFormat("Block number {0}", descriptor.BlockNumber).AppendLine();
                        sb.AppendFormat("Character position {0}", descriptor.CharacterPosition).AppendLine();
                        sb.AppendFormat("Text field: \"{0}\"",
                                        StringHandlers.CToString(descriptor.TextDataField,
                                                                 Encoding.GetEncoding("iso-8859-1"))).AppendLine();
                        break;
                    }

                    default:
                    {
                        sb.AppendFormat("Binary contents: {0}",
                                        PrintHex.ByteArrayToHexArrayString(descriptor.TextDataField, 28))
                        .AppendLine();
                        break;
                    }
                    }

                    sb.AppendFormat("CRC: 0x{0:X4}", descriptor.CRC).AppendLine();
                }
            }

            return(sb.ToString());
        }
Пример #9
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;
            }
        }
Пример #10
0
        public static string Prettify(DiscInformation?DIResponse)
        {
            if (DIResponse == null)
            {
                return(null);
            }

            DiscInformation response = DIResponse.Value;

            StringBuilder sb = new StringBuilder();

            foreach (DiscInformationUnits unit in response.Units)
            {
                sb.AppendFormat("DI Unit Sequence: {0}", unit.Sequence).AppendLine();
                sb.AppendFormat("DI Unit Format: 0x{0:X2}", unit.Format).AppendLine();
                sb.AppendFormat("There are {0} per block", unit.UnitsPerBlock).AppendLine();
                sb.AppendFormat("This DI refers to layer {0}", unit.Layer).AppendLine();
                if (Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDRE)
                {
                    sb.AppendFormat("Legacy value: 0x{0:X2}", unit.Legacy).AppendLine();
                }
                sb.AppendLine(unit.Continuation ? "This DI continues previous unit" : "This DI starts a new unit");
                sb.AppendFormat("DI Unit is {0} bytes", unit.Length).AppendLine();
                sb.AppendFormat("Disc type identifier: \"{0}\"", Encoding.ASCII.GetString(unit.DiscTypeIdentifier))
                .AppendLine();
                switch (unit.DiscSize)
                {
                case BluSize.OneTwenty:
                    sb.AppendLine("Disc size: 120mm");
                    break;

                case BluSize.Eighty:
                    sb.AppendLine("Disc size: 80mm");
                    break;

                default:
                    sb.AppendFormat("Disc size: Unknown code {0}", (byte)unit.DiscSize).AppendLine();
                    break;
                }

                sb.AppendFormat("Disc class: {0}", unit.DiscClass).AppendLine();
                sb.AppendFormat("Disc version: {0}", unit.DiscVersion).AppendLine();
                sb.AppendFormat("This disc has {0} layers", unit.Layers).AppendLine();
                switch (unit.DvdLayer)
                {
                case HybridLayer.None:
                    sb.AppendLine("This disc does not contain a DVD layer.");
                    break;

                case HybridLayer.ReadOnly:
                    sb.AppendLine("This disc contains a DVD-ROM layer.");
                    break;

                case HybridLayer.Recordable:
                    sb.AppendLine("This disc contains a DVD-R layer.");
                    break;

                case HybridLayer.Rewritable:
                    sb.AppendLine("This disc contains a DVD-RW layer.");
                    break;
                }

                switch (unit.CdLayer)
                {
                case HybridLayer.None:
                    sb.AppendLine("This disc does not contain a CD layer.");
                    break;

                case HybridLayer.ReadOnly:
                    sb.AppendLine("This disc contains a CD-ROM layer.");
                    break;

                case HybridLayer.Recordable:
                    sb.AppendLine("This disc contains a CD-R layer.");
                    break;

                case HybridLayer.Rewritable:
                    sb.AppendLine("This disc contains a CD-RW layer.");
                    break;
                }

                switch (unit.ChannelLength)
                {
                case ChannelLength.Seventy:
                    sb.AppendLine("Disc uses a 74.5nm channel giving 25 Gb per layer.");
                    break;

                case ChannelLength.Sixty:
                    sb.AppendLine("Disc uses a 69.0nm channel giving 27 Gb per layer.");
                    break;

                default:
                    sb.AppendFormat("Disc uses unknown channel length with code {0}", (byte)unit.ChannelLength)
                    .AppendLine();
                    break;
                }

                switch (unit.Polarity)
                {
                case 0:
                    sb.AppendLine("Disc uses positive polarity.");
                    break;

                case 1:
                    sb.AppendLine("Disc uses negative polarity.");
                    break;

                default:
                    sb.AppendFormat("Disc uses unknown polarity with code {0}", unit.Polarity).AppendLine();
                    break;
                }

                if (Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDR)
                {
                    switch (unit.RecordedPolarity)
                    {
                    case 0:
                        sb.AppendLine("Recorded marks have a lower reflectivity than unrecorded ones (HTL disc).");
                        break;

                    case 1:
                        sb.AppendLine("Recorded marks have a higher reflectivity than unrecorded ones (LTH disc).");
                        break;

                    default:
                        sb.AppendFormat("Disc uses unknown recorded reflectivity polarity with code {0}",
                                        unit.RecordedPolarity).AppendLine();
                        break;
                    }
                }

                switch (unit.Bca)
                {
                case 0:
                    sb.AppendLine("Disc doesn't have a BCA.");
                    break;

                case 1:
                    sb.AppendLine("Disc has a BCA.");
                    break;

                default:
                    sb.AppendFormat("Disc uses unknown BCA code {0}", unit.Bca).AppendLine();
                    break;
                }

                if (unit.MaxTransfer > 0)
                {
                    sb.AppendFormat("Disc has a maximum transfer rate of {0} Mbit/sec.", unit.MaxTransfer).AppendLine();
                }
                else
                {
                    sb.AppendLine("Disc does not specify a maximum transfer rate.");
                }

                sb.AppendFormat("Last user data PSN for disc: {0}", unit.LastPsn).AppendLine();
                sb.AppendFormat("First address unit number of data zone in this layer: {0}", unit.FirstAun)
                .AppendLine();
                sb.AppendFormat("Last address unit number of data zone in this layer: {0}", unit.LastAun).AppendLine();

                if (Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDR ||
                    Encoding.ASCII.GetString(unit.DiscTypeIdentifier) == DiscTypeBDRE)
                {
                    sb.AppendFormat("Disc manufacturer ID: \"{0}\"", Encoding.ASCII.GetString(unit.ManufacturerID))
                    .AppendLine();
                    sb.AppendFormat("Disc media type ID: \"{0}\"", Encoding.ASCII.GetString(unit.MediaTypeID))
                    .AppendLine();
                    sb.AppendFormat("Disc timestamp: 0x{0:X2}", unit.TimeStamp).AppendLine();
                    sb.AppendFormat("Disc product revison number: {0}", unit.ProductRevisionNumber).AppendLine();
                }

                sb.AppendFormat("Blu-ray DI Unit format dependent contents as hex follows:");
                sb.AppendLine(PrintHex.ByteArrayToHexArrayString(unit.FormatDependentContents, 80));
            }

            return(sb.ToString());
        }