Ejemplo n.º 1
0
        private void LoadRootFile()
        {
            var encKeyStr = mBuildConfig["root"].FirstOrDefault();

            if (encKeyStr == null)
            {
                throw new InvalidOperationException("Build config is missing root key");
            }
            var encodingKey = encKeyStr.HexToBytes().ToArray();

            Log.Debug(string.Format("Root file key is {0}", encKeyStr));

            EncodingEntry encEntry;

            if (mEncodingData.TryGetValue(new Binary(encodingKey), out encEntry) == false || encEntry.Keys.Length == 0)
            {
                throw new InvalidOperationException("Unable to find encoding value for root file");
            }

            IndexEntry entry;

            if (mIndexData.TryGetValue(new Binary(encEntry.Keys[0].ToArray().Take(9).ToArray()), out entry) == false)
            {
                throw new InvalidOperationException("Unable to locate root file in index table");
            }

            var strm = GetDataStream(entry.Index);

            using (var fileReader = new BinaryReader(strm.Stream, Encoding.UTF8, true))
            {
                fileReader.BaseStream.Position = entry.Offset + 30;
                using (var reader = new BinaryReader(BlteGetData(fileReader, entry.Size - 30)))
                {
                    try
                    {
                        while (true)
                        {
                            var count = reader.ReadInt32();
                            reader.ReadBytes(8 + count * 4);
                            var entries = reader.ReadArray <RootEntryFile>(count);
                            foreach (var e in entries)
                            {
                                var b         = e.md5;
                                var rootEntry = new RootEntry
                                {
                                    Hash = e.hash,
                                    Md5  = new Binary(new[]
                                    {
                                        b.v1, b.v2, b.v3, b.v4, b.v5, b.v6, b.v7, b.v8, b.v9, b.v10, b.v11,
                                        b.v12, b.v13, b.v14, b.v15, b.v16
                                    })
                                };
                                if (mRootData.ContainsKey(e.hash))
                                {
                                    mRootData[e.hash].Add(rootEntry);
                                }
                                else
                                {
                                    mRootData.Add(e.hash, new List <RootEntry>(20)
                                    {
                                        rootEntry
                                    });
                                }
                            }
                        }
                    }
                    catch (EndOfStreamException)
                    {
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void LoadRootFile()
        {
            var encKeyStr = mBuildConfig["root"].FirstOrDefault();
            if (encKeyStr == null) throw new InvalidOperationException("Build config is missing root key");
            var encodingKey = encKeyStr.HexToBytes().ToArray();

            EncodingEntry encEntry;
            if (mEncodingData.TryGetValue(new Binary(encodingKey), out encEntry) == false || encEntry.Keys.Length == 0)
                throw new InvalidOperationException("Unable to find encoding value for root file");

            IndexEntry entry;
            if (mIndexData.TryGetValue(new Binary(encEntry.Keys[0].ToArray().Take(9).ToArray()), out entry) == false)
                throw new InvalidOperationException("Unable to locate root file in index table");

            var strm = GetDataStream(entry.Index);
            using (var fileReader = new BinaryReader(strm.Stream, Encoding.UTF8, true))
            {
                fileReader.BaseStream.Position = entry.Offset + 30;
                using (var reader = new BinaryReader(BlteGetData(fileReader, entry.Size - 30)))
                {
                    try
                    {
                        while(true)
                        {
                            var count = reader.ReadInt32();
                            reader.ReadBytes(8 + count * 4);
                            var entries = reader.ReadArray<RootEntryFile>(count);
                            foreach (var e in entries)
                            {
                                var b = e.md5;
                                var rootEntry = new RootEntry
                                {
                                    Hash = e.hash,
                                    Md5 = new Binary(new[]
                                    {
                                        b.v1, b.v2, b.v3, b.v4, b.v5, b.v6, b.v7, b.v8, b.v9, b.v10, b.v11,
                                        b.v12, b.v13, b.v14, b.v15, b.v16
                                    })
                                };
                                if (mRootData.ContainsKey(e.hash))
                                    mRootData[e.hash].Add(rootEntry);
                                else
                                    mRootData.Add(e.hash, new List<RootEntry>(20) {rootEntry});
                            }
                        }
                    }
                    catch(EndOfStreamException)
                    {

                    }
                }
            }
        }