Generalized Crc32 implementation so it can be used for LG (TLL), Panasonic (.bin and .db) and Sony (sdb.xml)

This commit is contained in:
hbeham
2019-07-20 02:08:51 +02:00
parent 8e6d32e557
commit 1e26ef9cd4
4 changed files with 68 additions and 320 deletions

View File

@@ -426,7 +426,7 @@ namespace ChanSort.Loader.LG
this.dvbsSubblockCrcOffset[i] = off;
int subblockLength = satConfig.dvbsSubblockLength[i];
uint fileCrc = BitConverter.ToUInt32(fileContent, off);
uint calcCrc = Crc32.CalcCrc32(fileContent, off + 4, subblockLength);
uint calcCrc = Crc32.Reversed.CalcCrc32(fileContent, off + 4, subblockLength);
if (fileCrc != calcCrc)
throw new FileLoadException(string.Format(ERR_wrongChecksum, fileCrc, calcCrc));
off += 4 + subblockLength;
@@ -1008,7 +1008,7 @@ namespace ChanSort.Loader.LG
{
for (int i = 0; i < this.dvbsSubblockCrcOffset.Length; i++)
{
uint crc32 = Crc32.CalcCrc32(fileContent, this.dvbsSubblockCrcOffset[i] + 4, satConfig.dvbsSubblockLength[i]);
uint crc32 = Crc32.Reversed.CalcCrc32(fileContent, this.dvbsSubblockCrcOffset[i] + 4, satConfig.dvbsSubblockLength[i]);
var bytes = BitConverter.GetBytes(crc32);
for (int j = 0; j < bytes.Length; j++)
fileContent[this.dvbsSubblockCrcOffset[i] + j] = bytes[j];