Exemplo n.º 1
0
            public static EncryptedChunkEntry Read(Stream input, Endian endian)
            {
                EncryptedChunkEntry instance;

                instance.Entry      = NormalEntry.Read(input, endian);
                instance.CryptoInfo = CryptoInfo.Read(input, endian);
                return(instance);
            }
Exemplo n.º 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 normalCount    = input.ReadValueU32(endian);
            var patchCount     = input.ReadValueU32(endian);
            var encryptedCount = input.ReadValueU32(endian);
            var unknown1C      = input.ReadValueS32(endian); // patch version related?
            var unknown20      = input.ReadValueS32(endian); // patch version related?
            var unknown24      = input.ReadValueS32(endian); // patch version related?

            instance.NormalEntries.Clear();
            for (int i = 0; i < normalCount; i++)
            {
                var entry = NormalEntry.Read(input, endian);
                if (entry.IsEncrypted == true)
                {
                    throw new FormatException();
                }
                instance.NormalEntries.Add(entry);
            }

            instance.EncryptedEntries.Clear();
            for (int i = 0; i < encryptedCount; i++)
            {
                var encryptedEntry = EncryptedChunkEntry.Read(input, endian);
                if (encryptedEntry.Entry.IsEncrypted == false)
                {
                    throw new FormatException();
                }
                if (encryptedEntry.Entry.Size != encryptedEntry.CryptoInfo.Size)
                {
                    throw new FormatException();
                }
                instance.EncryptedEntries.Add(encryptedEntry);
            }

            instance.PatchEntries.Clear();
            for (int i = 0; i < patchCount; i++)
            {
                var entry = PatchEntry.Read(input, endian);
                instance.PatchEntries.Add(entry);
            }

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

            return(instance);
        }