mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 21:55:34 +08:00
(WARC): another decryptor.
This commit is contained in:
parent
25c36072a3
commit
97a6b331c5
@ -93,6 +93,7 @@
|
||||
<Compile Include="ArcCG.cs" />
|
||||
<Compile Include="Artemis\ArcPFS.cs" />
|
||||
<Compile Include="AudioWMA.cs" />
|
||||
<Compile Include="BlackRainbow\ArcDAT.cs" />
|
||||
<Compile Include="BlackRainbow\ArcDX.cs" />
|
||||
<Compile Include="C4\AudioVMD.cs" />
|
||||
<Compile Include="C4\ImageGD.cs" />
|
||||
|
@ -158,13 +158,15 @@ namespace GameRes.Formats.ShiinaRio // 椎名里緒
|
||||
uint unpacked_size = LittleEndian.ToUInt32 (enc_data, 4);
|
||||
sig ^= (unpacked_size ^ 0x82AD82) & 0xffffff;
|
||||
|
||||
if (0 != (wentry.Flags & 0x80000000u) && entry.Size > 8) // encrypted entry
|
||||
warc.Decoder.Decrypt (enc_data, 8, entry.Size-8);
|
||||
if (warc.Decoder.ExtraCrypt != null)
|
||||
warc.Decoder.ExtraCrypt.Decrypt (enc_data, 8, entry.Size-8, 0x202);
|
||||
if (0 != (wentry.Flags & 0x20000000u) && entry.Size > 8)
|
||||
warc.Decoder.Decrypt2 (enc_data, 8, entry.Size-8);
|
||||
|
||||
if (entry.Size > 8)
|
||||
{
|
||||
if (0 != (wentry.Flags & 0x80000000u)) // encrypted entry
|
||||
warc.Decoder.Decrypt (enc_data, 8, entry.Size-8);
|
||||
if (warc.Decoder.ExtraCrypt != null)
|
||||
warc.Decoder.ExtraCrypt.Decrypt (enc_data, 8, entry.Size-8, 0x202);
|
||||
if (0 != (wentry.Flags & 0x20000000u))
|
||||
warc.Decoder.Decrypt2 (enc_data, 8, entry.Size-8);
|
||||
}
|
||||
byte[] unpacked = enc_data;
|
||||
UnpackMethod unpack = null;
|
||||
switch (sig & 0xffffff)
|
||||
|
@ -1126,4 +1126,35 @@ namespace GameRes.Formats.ShiinaRio
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class CountCrypt : IDecryptExtra
|
||||
{
|
||||
public void Decrypt (byte[] data, int index, uint length, uint flags)
|
||||
{
|
||||
if (length >= 0x200 && (flags & 0x204) == 0x204)
|
||||
DoCountCrypt (data, index, (int)length);
|
||||
}
|
||||
|
||||
public void Encrypt (byte[] data, int index, uint length, uint flags)
|
||||
{
|
||||
if (length >= 0x200 && (flags & 0x104) == 0x104)
|
||||
DoCountCrypt (data, index, (int)length);
|
||||
}
|
||||
|
||||
void DoCountCrypt (byte[] data, int index, int length)
|
||||
{
|
||||
length = (length & 0x7E) | 1;
|
||||
byte count_00 = 0, count_FF = 0;
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
if (0xFF == data[index+i])
|
||||
count_FF++;
|
||||
else if (0 == data[index+i])
|
||||
count_00++;
|
||||
}
|
||||
data[index + 0x100] ^= count_00;
|
||||
data[index + 0x104] ^= count_FF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user