コード例 #1
0
        public const int ENCRYPTED_MAGIC = 0x636D66; // todo: use the thingy again?

        public ContentManifestFile(ClientHandler client, Stream stream, string name)
        {
            using (BinaryReader reader = new BinaryReader(stream)) {
                m_header = reader.Read <CMFHeader>();
                if (m_header.m_buildVersion < ProductHandler_Tank.VERSION_148_PTR)   // before 1.48
                {
                    stream.Position = 0;
                    m_header        = reader.Read <CMFHeader25>().Upgrade();
                }

                if (m_header.m_buildVersion >= 12923648 || m_header.m_buildVersion < 52320)
                {
                    throw new NotSupportedException("Overwatch 1.29 or earlier is not supported");
                }

                if (m_header.IsEncrypted())
                {
                    using (var decryptedReader = ManifestCryptoHandler.GetDecryptedReader(name, "CMF", m_header, m_header.m_buildVersion, client.Product, stream))
                        ParseEntries(decryptedReader);
                }
                else
                {
                    ParseEntries(reader);
                }
            }
        }
コード例 #2
0
        public ResourceGraph(ClientHandler client, Stream stream, string name)
        {
            using (BinaryReader reader = new BinaryReader(stream)) {
                m_header = reader.Read <TRGHeader>();
                if (IsPre152(m_header))
                {
                    stream.Position = 0;
                    m_header        = reader.Read <TRGHeader6>().Upgrade();
                }

                var version = m_header.GetVersion();
                if (version != 5 && version != 6 && version != 7 && version != 8)
                {
                    throw new InvalidDataException($"unable to parse TRG. invalid version {version}, expected 5, 6, 7 or 8");
                }

                var isEnc = m_header.IsEncrypted();

                if (!isEnc)
                {
                    ParseBlocks(reader, name);
                }
                else
                {
                    using (var decryptedReader = ManifestCryptoHandler.GetDecryptedReader(name, "TRG", m_header, m_header.m_buildVersion, client.Product, stream))
                        ParseBlocks(decryptedReader, name);
                }
            }

            if (m_packages == null)
            {
                throw new NullReferenceException(nameof(m_packages));
            }
            if (m_skins == null)
            {
                throw new NullReferenceException(nameof(m_skins));
            }
            if (m_graphBlock == null)
            {
                throw new NullReferenceException(nameof(m_graphBlock));
            }
        }