Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }