View Single Post
Old 16 November 2008, 15:02   #48
mr_0rga5m
Tik Gora :D

mr_0rga5m's Avatar
 
Join Date: Oct 2001
Location: Round yo momma's
Posts: 1,273
Quote:
Originally Posted by OddbOd View Post
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;

Last edited by mr_0rga5m; 16 November 2008 at 15:20.
mr_0rga5m is offline  
 
Page generated in 0.04614 seconds with 9 queries