Пример #1
0
        public byte[] GetAsData()
        {
            BigEndianMemoryStream buffer = new BigEndianMemoryStream(GetDataSize());

            buffer.WriteBigEndian(signatureType);
            buffer.Write(signature);
            buffer.Seek(60, SeekOrigin.Current);
            buffer.Write(issuer);

            buffer.WriteByte(version);
            buffer.WriteByte(CACRLVersion);
            buffer.WriteByte(signerCRLVersion);
            buffer.Seek(1, SeekOrigin.Current);

            buffer.WriteBigEndian(systemVersion);
            buffer.WriteBigEndian(ticket.titleID);
            buffer.WriteBigEndian(titleType);
            buffer.WriteBigEndian(groupID);
            buffer.WriteBigEndian(appType);
            buffer.Seek(58, SeekOrigin.Current);
            buffer.WriteBigEndian(accessRights);
            buffer.WriteBigEndian(titleVersion);
            buffer.WriteBigEndian(contentCount);
            buffer.WriteBigEndian(bootIndex);
            buffer.Seek(2, SeekOrigin.Current);

            buffer.Write(SHA2);

            buffer.Write(contentInfo.GetAsData());
            buffer.Write(contents.GetAsData());

            return(buffer.GetBuffer());
        }
Пример #2
0
        public byte[] GetAsData()
        {
            BigEndianMemoryStream buffer = new BigEndianMemoryStream(GetDataSize());

            if (isRoot)
            {
                buffer.WriteByte(1);
                buffer.Seek(7, SeekOrigin.Current);
                buffer.WriteBigEndian(rootEntryCount);
                buffer.Seek(4, SeekOrigin.Current);
            }
            else
            {
                buffer.WriteByte(GetTypeAsByte());
                buffer.WriteByte((byte)(nameOffset >> 16)); // We need to write a 24bit int (big endian)
                buffer.WriteByte((byte)(nameOffset >> 8));
                buffer.WriteByte((byte)nameOffset);

                if (isDir)
                {
                    buffer.WriteBigEndian(parentOffset);
                    buffer.WriteBigEndian(nextOffset);
                }
                else
                {
                    buffer.WriteBigEndian((int)(fileOffset >> 5));
                    buffer.WriteBigEndian((int)fileSize);
                }

                buffer.WriteBigEndian(flags);
                buffer.WriteBigEndian((short)content.ID);
            }

            foreach (FSTEntry entry in children)
            {
                buffer.Write(entry.GetAsData());
            }

            return(buffer.GetBuffer());
        }
Пример #3
0
        public KeyValuePair <long, byte[]> GetFSTContentHeaderAsData(long oldContentOffset)
        {
            BigEndianMemoryStream buffer = new BigEndianMemoryStream(staticFSTContentHeaderDataSize);

            byte unknown;
            long content_offset           = oldContentOffset;
            long fst_content_size         = encryptedFileSize / CONTENT_FILE_PADDING;
            long fst_content_size_written = fst_content_size;

            if (IsHashed)
            {
                unknown = 2;
                fst_content_size_written -= ((fst_content_size / 64) + 1) * 2;
                if (fst_content_size_written < 0)
                {
                    fst_content_size_written = 0;
                }
            }
            else
            {
                unknown = 1;
            }

            if (isFSTContent)
            {
                unknown = 0;
                if (fst_content_size == 1)
                {
                    fst_content_size = 0;
                }

                content_offset += fst_content_size + 2;
            }
            else
            {
                content_offset += fst_content_size;
            }

            buffer.WriteBigEndian((int)oldContentOffset);
            buffer.WriteBigEndian((int)fst_content_size_written);
            buffer.WriteBigEndian(parentTitleID);
            buffer.WriteBigEndian(groupID);
            buffer.WriteByte(unknown);

            return(new KeyValuePair <long, byte[]>(content_offset, buffer.GetBuffer()));
        }