Example #1
0
        public static bool IsValid(TMD_Content content, string contentFile)
        {
            if (!File.Exists(contentFile))
            {
                return(false);
            }

            return((ulong)new FileInfo(contentFile).Length == content.Size);
        }
Example #2
0
            private void parseTmd(Stream tmdFile)
            {
                fireDebug("Pasing TMD...");

                tmdFile.Seek(0, SeekOrigin.Begin);
                byte[] temp = new byte[8];

                fireDebug("   Reading Signature Exponent... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 4);
                signatureExponent = Shared.Swap(BitConverter.ToUInt32(temp, 0));

                fireDebug("   Reading Signature... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(signature, 0, signature.Length);

                fireDebug("   Reading Padding... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(padding, 0, padding.Length);

                fireDebug("   Reading Issuer... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(issuer, 0, issuer.Length);

                fireDebug("   Reading Version... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                fireDebug("   Reading CA Crl Version... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                fireDebug("   Reading Signer Crl Version... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                fireDebug("   Reading Padding Byte... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 4);
                version = temp[0];
                caCrlVersion = temp[1];
                signerCrlVersion = temp[2];
                paddingByte = temp[3];

                fireDebug("   Reading Startup IOS... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 8);
                startupIos = Shared.Swap(BitConverter.ToUInt64(temp, 0));

                fireDebug("   Reading Title ID... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 8);
                titleId = Shared.Swap(BitConverter.ToUInt64(temp, 0));

                fireDebug("   Reading Title Type... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 4);
                titleType = Shared.Swap(BitConverter.ToUInt32(temp, 0));

                fireDebug("   Reading Group ID... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 2);
                groupId = Shared.Swap(BitConverter.ToUInt16(temp, 0));

                fireDebug("   Reading Padding2... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 2);
                padding2 = Shared.Swap(BitConverter.ToUInt16(temp, 0));

                fireDebug("   Reading Region... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 2);
                region = Shared.Swap(BitConverter.ToUInt16(temp, 0));

                fireDebug("   Reading Reserved... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(reserved, 0, reserved.Length);

                fireDebug("   Reading Access Rights... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 4);
                accessRights = Shared.Swap(BitConverter.ToUInt32(temp, 0));

                fireDebug("   Reading Title Version... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                fireDebug("   Reading NumOfContents... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                fireDebug("   Reading Boot Index... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                fireDebug("   Reading Padding3... (Offset: 0x{0})", tmdFile.Position.ToString("x8").ToUpper());
                tmdFile.Read(temp, 0, 8);
                titleVersion = Shared.Swap(BitConverter.ToUInt16(temp, 0));
                numOfContents = Shared.Swap(BitConverter.ToUInt16(temp, 2));
                bootIndex = Shared.Swap(BitConverter.ToUInt16(temp, 4));
                padding3 = Shared.Swap(BitConverter.ToUInt16(temp, 6));
                tmdFile.Position = 0xb04;

                contents = new List<TMD_Content>();

                //Read Contents
                for (int i = 0; i < numOfContents; i++) {
                    fireDebug("   Reading Content #{0} of {1}... (Offset: 0x{2})", i + 1, numOfContents, tmdFile.Position.ToString("x8").ToUpper().ToUpper());

                    TMD_Content tempContent = new TMD_Content();
                    tempContent.Hash = new byte[20];

                    tmdFile.Read(temp, 0, 8);
                    tempContent.ContentID = Shared.Swap(BitConverter.ToUInt32(temp, 0));
                    tempContent.Index = Shared.Swap(BitConverter.ToUInt16(temp, 4));
                    tempContent.Type = (ContentType) Shared.Swap(BitConverter.ToUInt16(temp, 6));

                    tmdFile.Read(temp, 0, 8);
                    tempContent.Size = Shared.Swap(BitConverter.ToUInt64(temp, 0));

                    tmdFile.Read(tempContent.Hash, 0, tempContent.Hash.Length);

                    contents.Add(tempContent);
                    byte[] paddingcontent = new byte[12];
                    tmdFile.Read(paddingcontent, 0, 12);
                }

                fireDebug("Pasing TMD Finished...");
            }
Example #3
0
            /// <summary>
            /// Adds a TMD content.
            /// </summary>
            /// <param name="content"></param>
            public void AddContent(TMD_Content content)
            {
                contents.Add(content);

                numOfContents = (ushort) contents.Count;
            }