예제 #1
0
        public static Bhd5BucketEntry Read(BinaryReader reader)
        {
            Bhd5BucketEntry result = new Bhd5BucketEntry();

            result.FileNameHash   = reader.ReadUInt32();
            result.PaddedFileSize = reader.ReadUInt32();
            result.FileOffset     = reader.ReadInt64();
            long saltedHashOffset = reader.ReadInt64();
            long aesKeyOffset     = reader.ReadInt64();

            result.FileSize = reader.ReadInt64();

            if (saltedHashOffset != 0)
            {
                long currentPosition = reader.GetPosition();
                reader.Seek(saltedHashOffset, SeekOrigin.Begin);
                result.ShaHash = Bhd5SaltedShaHash.Read(reader);
                reader.Seek(currentPosition, SeekOrigin.Begin);
            }

            if (aesKeyOffset != 0)
            {
                long currentPosition = reader.GetPosition();
                reader.Seek(aesKeyOffset, SeekOrigin.Begin);
                result.AesKey = Bhd5AesKey.Read(reader);
                reader.Seek(currentPosition, SeekOrigin.Begin);
            }

            return(result);
        }
예제 #2
0
        public static Bhd5BucketEntry Read(BinaryReader reader, GameVersion version, int bhdVersion)
        {
            Bhd5BucketEntry result = new Bhd5BucketEntry();

            result.FileNameHash   = reader.ReadUInt32();
            result.PaddedFileSize = reader.ReadUInt32();
            result.FileOffset     = reader.ReadInt64();
            long saltedHashOffset = 0;
            long aesKeyOffset     = 0;

            if (bhdVersion == 511)
            {
                saltedHashOffset = reader.ReadInt64();
                aesKeyOffset     = reader.ReadInt64();

                switch (version)
                {
                case GameVersion.DarkSouls3:
                    result.FileSize = reader.ReadInt64();
                    break;

                default:
                    result.FileSize = result.PaddedFileSize;
                    break;
                }
            }
            else
            {
                result.FileSize = result.PaddedFileSize;
            }

            if (saltedHashOffset != 0)
            {
                long currentPosition = reader.GetPosition();
                reader.Seek(saltedHashOffset, SeekOrigin.Begin);
                result.ShaHash = Bhd5SaltedShaHash.Read(reader);
                reader.Seek(currentPosition, SeekOrigin.Begin);
            }

            if (aesKeyOffset != 0)
            {
                long currentPosition = reader.GetPosition();
                reader.Seek(aesKeyOffset, SeekOrigin.Begin);
                result.AesKey = Bhd5AesKey.Read(reader);
                reader.Seek(currentPosition, SeekOrigin.Begin);
            }

            return(result);
        }
예제 #3
0
        public static Bhd5SaltedShaHash Read(BinaryReader reader)
        {
            Bhd5SaltedShaHash result = new Bhd5SaltedShaHash();

            result.Hash = reader.ReadBytes(32);
            int rangeCount = reader.ReadInt32();

            Bhd5Range[] ranges = new Bhd5Range[rangeCount];
            for (int i = 0; i < rangeCount; i++)
            {
                ranges[i] = Bhd5Range.Read(reader);
            }
            result.Ranges = ranges;

            return(result);
        }