From bdffc239bc0419f84e616979b6e31e0b379eb6e8 Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 7 Sep 2023 12:18:15 +0400 Subject: [PATCH] (QLIE): better support for 'FilePackVer1.0' archives. --- ArcFormats/Qlie/Encryption.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ArcFormats/Qlie/Encryption.cs b/ArcFormats/Qlie/Encryption.cs index ff7ee8d3..dbdfcc8b 100644 --- a/ArcFormats/Qlie/Encryption.cs +++ b/ArcFormats/Qlie/Encryption.cs @@ -33,6 +33,8 @@ namespace GameRes.Formats.Qlie { bool IsUnicode { get; } + IndexLayout IndexLayout { get; } + uint CalculateHash (byte[] data, int length); string DecryptName (byte[] name, int name_length); @@ -40,9 +42,17 @@ namespace GameRes.Formats.Qlie void DecryptEntry (byte[] data, int offset, int length, QlieEntry entry); } + internal enum IndexLayout + { + WithoutHash, + WithHash + } + internal abstract class QlieEncryption : IEncryption { - public virtual bool IsUnicode { get { return false; } } + public virtual bool IsUnicode => false; + + public virtual IndexLayout IndexLayout => IndexLayout.WithHash; /// /// Hash generated from the key data contained within archive index. @@ -77,6 +87,8 @@ namespace GameRes.Formats.Qlie internal class EncryptionV1 : QlieEncryption { + public override IndexLayout IndexLayout => IndexLayout.WithoutHash; + public EncryptionV1 () { NameKey = 0xC4; @@ -126,10 +138,15 @@ namespace GameRes.Formats.Qlie internal class EncryptionV2 : QlieEncryption { - public EncryptionV2 () + public override IndexLayout IndexLayout => m_layout; + + private IndexLayout m_layout; + + public EncryptionV2 (IndexLayout layout = IndexLayout.WithHash) { NameKey = 0xC4; ArcKey = 0; + m_layout = layout; } public override uint CalculateHash (byte[] data, int length)