mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-27 15:44:00 +08:00
(Xp3): added StratupTjsNotEncrypted encryption scheme property.
This commit is contained in:
parent
b91fdeddf1
commit
8297d6daff
@ -199,7 +199,6 @@ namespace GameRes.Formats.KiriKiri
|
||||
entry.Cipher = crypt_algorithm.Value;
|
||||
else
|
||||
entry.Cipher = NoCryptAlgorithm;
|
||||
entry.IsEncrypted = !(entry.Cipher is NoCrypt);
|
||||
|
||||
var name = new string (header.ReadChars (name_size));
|
||||
if (entry.Cipher.ObfuscatedIndex && ObfuscatedPathRe.IsMatch (name))
|
||||
@ -208,6 +207,8 @@ namespace GameRes.Formats.KiriKiri
|
||||
}
|
||||
entry.Name = name;
|
||||
entry.Type = FormatCatalog.Instance.GetTypeFromName (entry.Name);
|
||||
entry.IsEncrypted = !(entry.Cipher is NoCrypt)
|
||||
&& !(entry.Cipher.StratupTjsNotEncrypted && "startup.tjs" == name);
|
||||
break;
|
||||
}
|
||||
case 0x6d676573: // "segm"
|
||||
@ -522,13 +523,14 @@ NextEntry:
|
||||
|
||||
var xp3entry = new Xp3Entry {
|
||||
Name = name,
|
||||
IsEncrypted = use_encryption,
|
||||
Cipher = scheme,
|
||||
IsEncrypted = use_encryption
|
||||
&& !(scheme.StratupTjsNotEncrypted && name.EndsWith ("startup.tjs"))
|
||||
};
|
||||
bool compress = compress_contents && ShouldCompressFile (entry);
|
||||
using (var file = File.Open (name, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
if (!use_encryption || 0 == file.Length)
|
||||
if (!xp3entry.IsEncrypted || 0 == file.Length)
|
||||
RawFileCopy (file, xp3entry, output, compress);
|
||||
else
|
||||
EncryptedFileCopy (file, xp3entry, output, compress);
|
||||
@ -787,6 +789,7 @@ NextEntry:
|
||||
int read = m_stream.Read (buffer, offset, count);
|
||||
if (0 != read)
|
||||
{
|
||||
if (m_entry.IsEncrypted)
|
||||
m_entry.Cipher.Decrypt (m_entry, m_offset, buffer, offset, read);
|
||||
m_offset += read;
|
||||
total += read;
|
||||
@ -807,6 +810,7 @@ NextEntry:
|
||||
b = m_stream.ReadByte();
|
||||
if (-1 != b)
|
||||
{
|
||||
if (m_entry.IsEncrypted)
|
||||
b = m_entry.Cipher.Decrypt (m_entry, m_offset++, (byte)b);
|
||||
break;
|
||||
}
|
||||
|
@ -36,12 +36,17 @@ namespace GameRes.Formats.KiriKiri
|
||||
/// </summary>
|
||||
public virtual bool HashAfterCrypt { get { return false; } }
|
||||
|
||||
/// <summary>
|
||||
/// sometimes startup.tjs file is not encrypted.
|
||||
/// </summary>
|
||||
public bool StratupTjsNotEncrypted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// whether XP3 index is obfuscated:
|
||||
/// - duplicate entries
|
||||
/// - entries have additional dummy segments
|
||||
/// </summary>
|
||||
public virtual bool ObfuscatedIndex { get { return false; } }
|
||||
public bool ObfuscatedIndex { get; set; }
|
||||
|
||||
public virtual byte Decrypt (Xp3Entry entry, long offset, byte value)
|
||||
{
|
||||
|
@ -514,16 +514,6 @@ namespace GameRes.Formats.KiriKiri
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ZecchouCrypt : CxEncryption
|
||||
{
|
||||
public ZecchouCrypt (CxScheme scheme) : base (scheme)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool ObfuscatedIndex { get { return true; } }
|
||||
}
|
||||
|
||||
/* CxEncryption base branch order
|
||||
OddBranchOrder
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user