You are viewing our Forum Archives. To view or take place in current topics click here.
EA Checksum / MC02 [C++]
Posted:

EA Checksum / MC02 [C++]Posted:

CLK
  • Wise One
Status: Offline
Joined: Jun 12, 201013Year Member
Posts: 531
Reputation Power: 33
Status: Offline
Joined: Jun 12, 201013Year Member
Posts: 531
Reputation Power: 33
This was basically the first thing I coded in C++... I started it a month or two ago (I don't think Mojo had released his at the time) but something was wrong with it, and I never bothered fixing it. I recently had to try modding an EA game and figured I'd give it another shot and got it working, so here you all go:

[ Register or Signin to view external links. ]

It's not a resigner, simply calculates the checksum.

unsigned int CalcMC02(char *buff, unsigned int length)
{

    unsigned int position = 4;
    // Declare our registers.  Some are used, some aren't.  I tried keeping as close to the
// actual assembly shit as possible
    DWORD r3, r4 = length, r6, r7, r8, r9, r10 = r4 - 4, r11;
    // First step
    DWORD first = _rotr(buff[0], 8) | _rotr(buff[1], 16);
    r7 = _rotl(buff[2], 8);
    first |= r7;
    r11 = buff[3];
    r11 |= first;
    r11 = ~r11;

    for (position = 4; position < length; position++)
    {
      // mask (22, 29), (working from left to right) bits 22-29 are set to 1.
        r7 = _rotl(r11, 10) & 0x3FC;// >> 0x14;
        // Shift r11
        r11 <<= 8;
        // Combine
        r11 |= (unsigned char)buff[position];
        // Grab the value from the crc table
        r7 = CRCTable[r7 >> 2];
      // **** with r11
      r11 ^= r7;
    }
    return r3 = ~r11;
}

The following 1 user thanked CLK for this useful post:

Experiment5X (03-28-2011)
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.