Пример #1
0
        /// <summary>
        /// The get record data.
        /// </summary>
        /// <param name="RecordType">
        /// The record type.
        /// </param>
        /// <param name="RecordInstance">
        /// The record instance.
        /// </param>
        /// <param name="decode">
        /// The decode.
        /// </param>
        /// <returns>
        /// The <see cref="byte[]"/>.
        /// </returns>
        /// <exception cref="InvalidDataException">
        /// </exception>
        public byte[] GetRecordData(Extractor.RecordType recordType, int recinstance, bool decode = false)
        {
            int  rectype  = (int)recordType;
            uint position = this.Records[rectype][recinstance];

            byte[]  buffer  = this.SegRead(34u, position);
            bStream bStream = new bStream(buffer);
            int     num     = bStream.ReadInt32_At(10u);

            if (rectype != num)
            {
                throw new InvalidDataException("Invalid Record Type");
            }

            int num2 = bStream.ReadInt32();

            if (recinstance != num2)
            {
                throw new InvalidDataException("Invalid Record Instance");
            }

            uint count = bStream.ReadUInt32() - 12u;

            byte[] array = this.SegRead(count, 4294967295u);
            if (decode)
            {
                ulong num3 = (ulong)recinstance;
                int   i    = 0;
                while (i < array.Length)
                {
                    num3 *= 16850947uL;
                    num3 %= 21023087759uL;
                    byte[] arg_B0_0 = array;
                    int    expr_AB  = i++;
                    arg_B0_0[expr_AB] ^= (byte)num3;
                }
            }

            return(array);
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Extractor"/> class.
        /// </summary>
        /// <param name="rdbPath">
        /// The rdb path.
        /// </param>
        public Extractor(string rdbPath = "./")
        {
            Regex regex = new Regex("ResourceDatabase\\.dat(\\.\\d{3})?$", RegexOptions.IgnoreCase);
            SortedSet<string> sortedSet = new SortedSet<string>();
            string[] files = Directory.GetFiles(rdbPath);
            for (int i = 0; i < files.Length; i++)
            {
                string text = files[i];
                if (regex.IsMatch(text))
                {
                    sortedSet.Add(text);
                }
            }

            foreach (string text in sortedSet)
            {
                this.DATs.Add(new bStream(text));
            }

            string path = Path.Combine(rdbPath, "ResourceDatabase.idx");
            bStream bStream = new bStream(File.ReadAllBytes(path));
            this.blockOffset = bStream.ReadUInt32_At(12u);
            this.dataFileSize = bStream.ReadUInt32_At(184u);
            if (this.dataFileSize < 0u)
            {
                this.dataFileSize = (uint)this.DATs[0].Length;
            }

            bStream.Position = bStream.ReadUInt32_At(72u);
            for (uint num = bStream.ReadUInt32(); num > 0u; num = bStream.ReadUInt32_At(num))
            {
                bStream.ReadInt32();
                short num2 = bStream.ReadInt16();
                bStream.Position += 22u;
                this.totalRecords += (uint)num2;
                while (true)
                {
                    short expr_1F6 = num2;
                    num2--;
                    if (expr_1F6 <= 0)
                    {
                        break;
                    }

                    uint value = bStream.ReadUInt32();
                    int key = bStream.ReadInt32_MSB();
                    int key2 = bStream.ReadInt32_MSB();
                    bStream.ReadInt32();
                    if (!this.Records.ContainsKey(key))
                    {
                        this.Records.Add(key, new Dictionary<int, uint>());
                    }

                    this.Records[key].Add(key2, value);
                }
            }

            bStream.Close();
        }
Пример #3
0
        /// <summary>
        /// The get record data.
        /// </summary>
        /// <param name="RecordType">
        /// The record type.
        /// </param>
        /// <param name="RecordInstance">
        /// The record instance.
        /// </param>
        /// <param name="decode">
        /// The decode.
        /// </param>
        /// <returns>
        /// The <see cref="byte[]"/>.
        /// </returns>
        /// <exception cref="InvalidDataException">
        /// </exception>
        public byte[] GetRecordData(Extractor.RecordType recordType, int recinstance, bool decode = false)
        {
            int rectype = (int)recordType;
            uint position = this.Records[rectype][recinstance];
            byte[] buffer = this.SegRead(34u, position);
            bStream bStream = new bStream(buffer);
            int num = bStream.ReadInt32_At(10u);
            if (rectype != num)
            {
                throw new InvalidDataException("Invalid Record Type");
            }

            int num2 = bStream.ReadInt32();
            if (recinstance != num2)
            {
                throw new InvalidDataException("Invalid Record Instance");
            }

            uint count = bStream.ReadUInt32() - 12u;
            byte[] array = this.SegRead(count, 4294967295u);
            if (decode)
            {
                ulong num3 = (ulong)recinstance;
                int i = 0;
                while (i < array.Length)
                {
                    num3 *= 16850947uL;
                    num3 %= 21023087759uL;
                    byte[] arg_B0_0 = array;
                    int expr_AB = i++;
                    arg_B0_0[expr_AB] ^= (byte)num3;
                }
            }

            return array;
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Extractor"/> class.
        /// </summary>
        /// <param name="rdbPath">
        /// The rdb path.
        /// </param>
        public Extractor(string rdbPath = "./")
        {
            Regex regex = new Regex("ResourceDatabase\\.dat(\\.\\d{3})?$", RegexOptions.IgnoreCase);
            SortedSet <string> sortedSet = new SortedSet <string>();

            string[] files = Directory.GetFiles(rdbPath);
            for (int i = 0; i < files.Length; i++)
            {
                string text = files[i];
                if (regex.IsMatch(text))
                {
                    sortedSet.Add(text);
                }
            }

            foreach (string text in sortedSet)
            {
                this.DATs.Add(new bStream(text));
            }

            string path = rdbPath + ((rdbPath.Substring(rdbPath.Length - 1, 1) == "\\") ? string.Empty : "\\")
                          + "ResourceDatabase.idx";
            bStream bStream = new bStream(File.ReadAllBytes(path));

            this.blockOffset  = bStream.ReadUInt32_At(12u);
            this.dataFileSize = bStream.ReadUInt32_At(184u);
            if (this.dataFileSize < 0u)
            {
                this.dataFileSize = (uint)this.DATs[0].Length;
            }

            bStream.Position = bStream.ReadUInt32_At(72u);
            for (uint num = bStream.ReadUInt32(); num > 0u; num = bStream.ReadUInt32_At(num))
            {
                bStream.ReadInt32();
                short num2 = bStream.ReadInt16();
                bStream.Position  += 8u;
                this.totalRecords += (uint)num2;
                while (true)
                {
                    short expr_1F6 = num2;
                    num2--;
                    if (expr_1F6 <= 0)
                    {
                        break;
                    }

                    uint value = bStream.ReadUInt32();
                    int  key   = bStream.ReadInt32_MSB();
                    int  key2  = bStream.ReadInt32_MSB();
                    if (!this.Records.ContainsKey(key))
                    {
                        this.Records.Add(key, new Dictionary <int, uint>());
                    }

                    this.Records[key].Add(key2, value);
                }
            }

            bStream.Close();
            bStream.Dispose();
        }