Beispiel #1
0
        public bool Open(Stream fs)
        {
            var intBytes = new byte[4];

            Header = MarshalUtil.ReadStruct <CIAHeader>(fs); //read header

            CertificateChainOffset = Align(Marshal.SizeOf(Header), 64);
            TicketOffset           = Align(CertificateChainOffset + Header.CertificateChainLength, 64);
            TMDOffset     = Align(TicketOffset + Header.TicketLength, 64);
            ContentOffset = Align(TMDOffset + Header.TMDLength, 64);
            MetaOffset    = Align(ContentOffset + (long)Header.ContentLength, 64);


            fs.Seek(CertificateChainOffset, SeekOrigin.Begin);
            CertificatesContext = new CertificatesContext();
            if (!CertificatesContext.Open(fs))
            {
                errorMessage = CertificatesContext.GetErrorMessage();
                return(false);
            }

            fs.Seek(TicketOffset, SeekOrigin.Begin);
            TicketContext = new TicketContext();
            if (!TicketContext.Open(fs))
            {
                errorMessage = TicketContext.GetErrorMessage();
                return(false);
            }

            fs.Seek(TMDOffset, SeekOrigin.Begin);
            TMDContext = new TMDContext();
            if (!TMDContext.Open(fs))
            {
                errorMessage = TMDContext.GetErrorMessage();
                return(false);
            }

            if (Header.MetaLength > 0)
            {
                fs.Seek(MetaOffset, SeekOrigin.Begin);
                MetaHeaderEntries = new ArrayList();
                var metaHeaderEntry = MarshalUtil.ReadStruct <CIAMetaHeaderEntry>(fs);
                while (metaHeaderEntry.ID[6] == 4)
                {
                    MetaHeaderEntries.Add(metaHeaderEntry);
                    metaHeaderEntry = MarshalUtil.ReadStruct <CIAMetaHeaderEntry>(fs);
                }
                fs.Seek(MetaOffset + 0x400, SeekOrigin.Begin); //Jump to the header
                ICN = new ICNContext();
                ICN.Open(fs);
            }
            return(true);
        }
Beispiel #2
0
        public bool Open(Stream fs)
        {
            var intBytes = new byte[4];
            Header = MarshalUtil.ReadStruct<CIAHeader>(fs); //read header

            CertificateChainOffset = Align(Marshal.SizeOf(Header),64);
            TicketOffset = Align(CertificateChainOffset + Header.CertificateChainLength,64);
            TMDOffset = Align(TicketOffset + Header.TicketLength,64);
            ContentOffset = Align(TMDOffset + Header.TMDLength,64);
            MetaOffset = Align(ContentOffset + (long)Header.ContentLength,64);

            
            fs.Seek(CertificateChainOffset, SeekOrigin.Begin);
            CertificatesContext = new CertificatesContext();
            if (!CertificatesContext.Open(fs))
            {
                errorMessage = CertificatesContext.GetErrorMessage();
                return false;
            }
            
            fs.Seek(TicketOffset, SeekOrigin.Begin);
            TicketContext = new TicketContext();
            if (!TicketContext.Open(fs))
            {
                errorMessage = TicketContext.GetErrorMessage();
                return false;
            }
            
            fs.Seek(TMDOffset, SeekOrigin.Begin);
            TMDContext = new TMDContext();
            if (!TMDContext.Open(fs))
            {
                errorMessage = TMDContext.GetErrorMessage();
                return false;
            }
           
            if (Header.MetaLength > 0)
            {
                fs.Seek(MetaOffset, SeekOrigin.Begin);
                MetaHeaderEntries = new ArrayList();
                var metaHeaderEntry = MarshalUtil.ReadStruct<CIAMetaHeaderEntry>(fs);
                while (metaHeaderEntry.ID[6] == 4)
                {
                    MetaHeaderEntries.Add(metaHeaderEntry);
                    metaHeaderEntry = MarshalUtil.ReadStruct<CIAMetaHeaderEntry>(fs);
                }
                fs.Seek(MetaOffset + 0x400, SeekOrigin.Begin); //Jump to the header
                ICN = new ICNContext();
                ICN.Open(fs);
            }
            return true;
        }