示例#1
0
        /// <summary>
        /// Reads a header from a byte buffer.
        /// </summary>
        /// <param name="header"></param>
        /// <returns></returns>
        public static GTVolumeHeader FromStream(Span <byte> header)
        {
            var gtHeader = new GTVolumeHeader();

            SpanReader sr = new SpanReader(header, Endian.Big);

            byte[] magic = sr.ReadBytes(4);
            if (!magic.AsSpan().SequenceEqual(HeaderMagic.AsSpan()) && !magic.AsSpan().SequenceEqual(OldHeaderMagic.AsSpan()))
            {
                return(null);
            }

            bool isOld = magic.AsSpan().SequenceEqual(OldHeaderMagic.AsSpan());

            if (!isOld)
            {
                gtHeader.TOCEntryIndex     = sr.ReadUInt32();
                gtHeader.CompressedTOCSize = sr.ReadUInt32();
                gtHeader.TOCSize           = sr.ReadUInt32();
                gtHeader.PFSVersion        = sr.ReadUInt64();
                gtHeader.TotalVolumeSize   = sr.ReadUInt64();
                gtHeader.TitleID           = sr.ReadString0();
            }
            else
            {
                sr.Position               += 4;
                gtHeader.TOCEntryIndex     = sr.ReadUInt32();
                gtHeader.CompressedTOCSize = sr.ReadUInt32();
                gtHeader.TOCSize           = sr.ReadUInt32();
            }

            return(gtHeader);
        }
示例#2
0
        /// <summary>
        /// Reads a buffer containing the header of a main volume file.
        /// </summary>
        /// <param name="header"></param>
        /// <returns></returns>
        private bool ReadHeader(Span <byte> header)
        {
            GTVolumeHeader volHeader = GTVolumeHeader.FromStream(header);

            if (volHeader is null)
            {
                return(false);
            }

            Program.Log($"[>] Table of Contents Entry Index: {volHeader.TOCEntryIndex}");
            Program.Log($"[>] TOC Size: {volHeader.CompressedTOCSize} bytes ({volHeader.TOCSize} decompressed)");
            Program.Log($"[>] Total Volume Size: {MiscUtils.BytesToString((long)volHeader.TotalVolumeSize)}");
            Program.Log($"[>] Title ID: '{volHeader.TitleID}'");
            VolumeHeader = volHeader;

            return(true);
        }
示例#3
0
        /// <summary>
        /// Reads a header from a byte buffer.
        /// </summary>
        /// <param name="header"></param>
        /// <returns></returns>
        public static GTVolumeHeader FromStream(Span <byte> header)
        {
            var gtHeader = new GTVolumeHeader();

            SpanReader sr = new SpanReader(header, Endian.Big);

            byte[] magic = sr.ReadBytes(4);
            if (!magic.AsSpan().SequenceEqual(HeaderMagic.AsSpan()))
            {
                return(null);
            }

            gtHeader.TOCEntryIndex     = sr.ReadUInt32();
            gtHeader.CompressedTOCSize = sr.ReadUInt32();
            gtHeader.TOCSize           = sr.ReadUInt32();
            gtHeader.Unk             = sr.ReadUInt64();
            gtHeader.TotalVolumeSize = sr.ReadUInt64();
            gtHeader.TitleID         = sr.ReadString0();

            return(gtHeader);
        }
示例#4
0
 public GTVolumeTOC(GTVolumeHeader parentHeader, GTVolume parentVolume)
 {
     ParentHeader = parentHeader;
     ParentVolume = parentVolume;
 }