예제 #1
0
            public static EncryptedChunkEntry Read(Stream input, Endian endian)
            {
                EncryptedChunkEntry instance;

                instance.Chunk      = ChunkEntry.Read(input, endian);
                instance.CryptoInfo = CryptoInfo.Read(input, endian);
                return(instance);
            }
예제 #2
0
        public static CatalogFile Read(Stream input)
        {
            const Endian endian = Endian.Little;

            var magic1 = input.ReadValueU64(endian);
            var magic2 = input.ReadValueU64(endian);

            if (magic1 != Signature || magic2 != Signature)
            {
                throw new FormatException();
            }

            var instance = new CatalogFile();

            var chunkCount          = input.ReadValueU32(endian);
            var patchCount          = input.ReadValueU32(endian);
            var encryptedChunkCount = input.ReadValueU32(endian);
            var unknown1C           = input.ReadValueS32(endian);
            var unknown20           = input.ReadValueS32(endian);
            var unknown24           = input.ReadValueS32(endian);

            if (patchCount != 0 || unknown1C != 0 || unknown20 != 0 || unknown24 != 0)
            {
                throw new FormatException();
            }

            instance.ChunkEntries.Clear();

            for (int i = 0; i < chunkCount; i++)
            {
                var chunk = ChunkEntry.Read(input, endian);

                if (chunk.IsEncrypted == true)
                {
                    throw new FormatException();
                }

                instance.ChunkEntries.Add(chunk);
            }

            for (int i = 0; i < encryptedChunkCount; i++)
            {
                var encryptedChunk = EncryptedChunkEntry.Read(input, endian);

                if (encryptedChunk.Chunk.IsEncrypted == false)
                {
                    throw new FormatException();
                }

                if (encryptedChunk.Chunk.Size != encryptedChunk.CryptoInfo.Size)
                {
                    throw new FormatException();
                }

                instance.EncryptedChunkEntries.Add(encryptedChunk);
            }

            if (input.Position != input.Length)
            {
                throw new FormatException();
            }

            return(instance);
        }