internal static int detectSAVIndex(byte[] data, ref int savindex)
{
SHA256 mySHA256 = SHA256.Create();
{
byte[] difihash1 = new byte[0x12C];
byte[] difihash2 = new byte[0x12C];
Array.Copy(data, 0x330, difihash1, 0, 0x12C);
Array.Copy(data, 0x200, difihash2, 0, 0x12C);
byte[] hashValue1 = mySHA256.ComputeHash(difihash1);
byte[] hashValue2 = mySHA256.ComputeHash(difihash2);
byte[] actualhash = new byte[0x20];
Array.Copy(data, 0x16C, actualhash, 0, 0x20);
if (hashValue1.SequenceEqual(actualhash))
{
Console.WriteLine("Active DIFI 2 - Save 1.");
savindex = 0;
}
else if (hashValue2.SequenceEqual(actualhash))
{
Console.WriteLine("Active DIFI 1 - Save 2.");
savindex = 1;
}
else
{
Console.WriteLine("ERROR: NO ACTIVE DIFI HASH MATCH");
savindex = 2;
}
}
if ((data[0x168] ^ 1) == savindex || savindex == 2) // success
return savindex;
Console.WriteLine("ERROR: ACTIVE BLOCK MISMATCH");
savindex = 2;
return savindex;
}
internal static ushort ccitt16(byte[] data)