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;
|
entry.Cipher = crypt_algorithm.Value;
|
||||||
else
|
else
|
||||||
entry.Cipher = NoCryptAlgorithm;
|
entry.Cipher = NoCryptAlgorithm;
|
||||||
entry.IsEncrypted = !(entry.Cipher is NoCrypt);
|
|
||||||
|
|
||||||
var name = new string (header.ReadChars (name_size));
|
var name = new string (header.ReadChars (name_size));
|
||||||
if (entry.Cipher.ObfuscatedIndex && ObfuscatedPathRe.IsMatch (name))
|
if (entry.Cipher.ObfuscatedIndex && ObfuscatedPathRe.IsMatch (name))
|
||||||
@ -208,6 +207,8 @@ namespace GameRes.Formats.KiriKiri
|
|||||||
}
|
}
|
||||||
entry.Name = name;
|
entry.Name = name;
|
||||||
entry.Type = FormatCatalog.Instance.GetTypeFromName (entry.Name);
|
entry.Type = FormatCatalog.Instance.GetTypeFromName (entry.Name);
|
||||||
|
entry.IsEncrypted = !(entry.Cipher is NoCrypt)
|
||||||
|
&& !(entry.Cipher.StratupTjsNotEncrypted && "startup.tjs" == name);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x6d676573: // "segm"
|
case 0x6d676573: // "segm"
|
||||||
@ -522,13 +523,14 @@ NextEntry:
|
|||||||
|
|
||||||
var xp3entry = new Xp3Entry {
|
var xp3entry = new Xp3Entry {
|
||||||
Name = name,
|
Name = name,
|
||||||
IsEncrypted = use_encryption,
|
|
||||||
Cipher = scheme,
|
Cipher = scheme,
|
||||||
|
IsEncrypted = use_encryption
|
||||||
|
&& !(scheme.StratupTjsNotEncrypted && name.EndsWith ("startup.tjs"))
|
||||||
};
|
};
|
||||||
bool compress = compress_contents && ShouldCompressFile (entry);
|
bool compress = compress_contents && ShouldCompressFile (entry);
|
||||||
using (var file = File.Open (name, FileMode.Open, FileAccess.Read))
|
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);
|
RawFileCopy (file, xp3entry, output, compress);
|
||||||
else
|
else
|
||||||
EncryptedFileCopy (file, xp3entry, output, compress);
|
EncryptedFileCopy (file, xp3entry, output, compress);
|
||||||
@ -787,6 +789,7 @@ NextEntry:
|
|||||||
int read = m_stream.Read (buffer, offset, count);
|
int read = m_stream.Read (buffer, offset, count);
|
||||||
if (0 != read)
|
if (0 != read)
|
||||||
{
|
{
|
||||||
|
if (m_entry.IsEncrypted)
|
||||||
m_entry.Cipher.Decrypt (m_entry, m_offset, buffer, offset, read);
|
m_entry.Cipher.Decrypt (m_entry, m_offset, buffer, offset, read);
|
||||||
m_offset += read;
|
m_offset += read;
|
||||||
total += read;
|
total += read;
|
||||||
@ -807,6 +810,7 @@ NextEntry:
|
|||||||
b = m_stream.ReadByte();
|
b = m_stream.ReadByte();
|
||||||
if (-1 != b)
|
if (-1 != b)
|
||||||
{
|
{
|
||||||
|
if (m_entry.IsEncrypted)
|
||||||
b = m_entry.Cipher.Decrypt (m_entry, m_offset++, (byte)b);
|
b = m_entry.Cipher.Decrypt (m_entry, m_offset++, (byte)b);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -36,12 +36,17 @@ namespace GameRes.Formats.KiriKiri
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool HashAfterCrypt { get { return false; } }
|
public virtual bool HashAfterCrypt { get { return false; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// sometimes startup.tjs file is not encrypted.
|
||||||
|
/// </summary>
|
||||||
|
public bool StratupTjsNotEncrypted { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// whether XP3 index is obfuscated:
|
/// whether XP3 index is obfuscated:
|
||||||
/// - duplicate entries
|
/// - duplicate entries
|
||||||
/// - entries have additional dummy segments
|
/// - entries have additional dummy segments
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual bool ObfuscatedIndex { get { return false; } }
|
public bool ObfuscatedIndex { get; set; }
|
||||||
|
|
||||||
public virtual byte Decrypt (Xp3Entry entry, long offset, byte value)
|
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
|
/* CxEncryption base branch order
|
||||||
OddBranchOrder
|
OddBranchOrder
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user