Quote:
Originally Posted by OddbOd
At a guess I would say you are currently holding the bootblock in a byte array and trying to convert to an array of ULongs so you can proceed with checksum calculation.
|
(u)long is 64bit .. he would be better with (u)int.
Here is my go...
Code:
C# .net:
uint checksum = 0;
uint precsum = 0;
for (int i = 0; i < 0x100; i++) // 0x100 = 1024 byte bootblock / 4
{
precsum = checksum;
if ((checksum += (uint)(((byteArray[i * 4]) << 24) | ((byteArray[(i * 4) + 1]) << 16) | ((byteArray[(i * 4) + 2]) << 8) | byteArray[(i * 4) + 3])) < precsum)
++checksum;
}
checksum = ~checksum;