(MrgOpener.Decrypt): added array range parameters.

This commit is contained in:
morkt
2015-11-23 21:29:35 +04:00
parent 203172be77
commit bcc3583885

View File

@@ -75,7 +75,7 @@ namespace GameRes.Formats.FC01
var key = GuessKey (file, index); var key = GuessKey (file, index);
if (null == key) if (null == key)
throw new UnknownEncryptionScheme(); throw new UnknownEncryptionScheme();
Decrypt (index, key.Value); Decrypt (index, 0, index.Length, key.Value);
int current_offset = 0; int current_offset = 0;
uint next_offset = LittleEndian.ToUInt32 (index, current_offset+0x1C); uint next_offset = LittleEndian.ToUInt32 (index, current_offset+0x1C);
@@ -132,14 +132,13 @@ namespace GameRes.Formats.FC01
return input; return input;
} }
static public void Decrypt (byte[] data, int key) static public void Decrypt (byte[] data, int index, int length, int key)
{ {
int remaining = data.Length; while (length > 0)
for (int i = 0; i < data.Length; ++i)
{ {
var v = data[i]; var v = data[index];
data[i] = (byte)((v << 1 | v >> 7) ^ key); data[index++] = (byte)((v << 1 | v >> 7) ^ key);
key += remaining--; key += length--;
} }
} }