public Pkg ReadPkg() { var header = ReadHeader(); s.Position = 0xFE0; var headerDigest = s.ReadBytes(32); var headerSignature = s.ReadBytes(256); s.Position = header.entry_table_offset; var metasEntry = new MetasEntry(); for (var i = 0; i < header.entry_count; i++) { metasEntry.Metas.Add(MetaEntry.Read(s)); } var pkg = new Pkg { Header = header, HeaderDigest = headerDigest, HeaderSignature = headerSignature, Metas = metasEntry, }; foreach (var entry in pkg.Metas.Metas) { switch (entry.id) { case EntryId.PARAM_SFO: s.Position = entry.DataOffset; pkg.ParamSfo = new SfoEntry(SFO.ParamSfo.FromStream(s)); break; case EntryId.ENTRY_KEYS: pkg.EntryKeys = KeysEntry.Read(entry, s); break; case EntryId.IMAGE_KEY: s.Position = entry.DataOffset; pkg.ImageKey = new GenericEntry(EntryId.IMAGE_KEY) { FileData = s.ReadBytes((int)entry.DataSize), meta = entry }; break; case EntryId.GENERAL_DIGESTS: s.Position = entry.DataOffset; pkg.GeneralDigests = GeneralDigestsEntry.Read(s); break; } } return(pkg); }
public Pkg ReadPkg() { var header = ReadHeader(); s.Position = 0xFE0; var headerDigest = s.ReadBytes(32); var headerSignature = s.ReadBytes(256); s.Position = header.entry_table_offset; var metasEntry = new MetasEntry(); for (var i = 0; i < header.entry_count; i++) { metasEntry.Metas.Add(MetaEntry.Read(s)); } return(new Pkg { Header = header, HeaderDigest = headerDigest, HeaderSignature = headerSignature, Metas = metasEntry, }); }
public Pkg ReadPkg() { var header = ReadHeader(); s.Position = 0xFE0; var headerDigest = s.ReadBytes(32); var headerSignature = s.ReadBytes(256); s.Position = header.entry_table_offset; var metasEntry = new MetasEntry(); for (var i = 0; i < header.entry_count; i++) { metasEntry.Metas.Add(MetaEntry.Read(s)); } var pkg = new Pkg { Header = header, HeaderDigest = headerDigest, HeaderSignature = headerSignature, Metas = metasEntry, }; foreach (var entry in pkg.Metas.Metas) { switch (entry.id) { case EntryId.METAS: pkg.Metas.meta = entry; break; case EntryId.ENTRY_NAMES: pkg.EntryNames = NameTableEntry.Read(entry, s); break; case EntryId.PARAM_SFO: s.Position = entry.DataOffset; pkg.ParamSfo = new SfoEntry(SFO.ParamSfo.FromStream(s)); pkg.ParamSfo.meta = entry; break; case EntryId.ENTRY_KEYS: pkg.EntryKeys = KeysEntry.Read(entry, s); pkg.EntryKeys.meta = entry; break; case EntryId.IMAGE_KEY: s.Position = entry.DataOffset; pkg.ImageKey = new GenericEntry(EntryId.IMAGE_KEY) { FileData = s.ReadBytes((int)entry.DataSize), meta = entry }; break; case EntryId.GENERAL_DIGESTS: s.Position = entry.DataOffset; pkg.GeneralDigests = GeneralDigestsEntry.Read(s); pkg.GeneralDigests.meta = entry; break; case EntryId.DIGESTS: s.Position = entry.DataOffset; pkg.Digests = new GenericEntry(EntryId.DIGESTS) { FileData = s.ReadBytes((int)entry.DataSize), meta = entry, }; break; case EntryId.LICENSE_DAT: try { var licenseDatBytes = new byte[entry.DataSize]; s.Position = entry.DataOffset; s.Read(licenseDatBytes, 0, (int)entry.DataSize); using (var ms = new System.IO.MemoryStream(Entry.Decrypt(licenseDatBytes, pkg, entry))) { pkg.LicenseDat = new Rif.LicenseDatReader(ms).Read(); pkg.LicenseDat.meta = entry; } } catch (Exception) { } break; } } return(pkg); }