I didn't have too much time today, but I managed to take a look at the decompiled method. The results look promising, even if the code seems incomplete:
I assume that the first loop is computing the CRC using 8 bytes steps, until less than 8 bytes remain. The second loop is processing these remaining bytes.
- _t51, _t52,..., _t57 are pointers to consecutive bytes from an array, so we can replace them with r2, r2[i+1], ..., r2[i+7]
[*]*((intOrPtr*)(4509488 + (index * 4)) can be considered as a value in a lookup table
Code:
L00401B60(_unknown_ r1, char* r2, _unknown_ r9)
{
_unknown_ r4;
_unknown_ r5;
_unknown_ r6;
_unknown_ _t49;
_unknown_ _t50;
char* _t51;
char* _t52;
char* _t53;
char* _t54;
char* _t55;
char* _t56;
char* _t57;
_unknown_ _t83;
_unknown_ _t84;
signed int _t85;
signed int _t86;
_unknown_ _t88;
_unknown_ _t89;
_t88 = __eflags;
_t51 = __ecx;
_push(_t85);
_push(_t83);
_t84 = 32;
_t86 = _t85 | 255;
__ebp = _t84 - 28;
do {
data(i) = (r2[i] & 255 ^ _t86)& 255;
crc(i) = _t86 >> 8 ^ crcTable[data(i)];
data(i+1) = (r2[i+1] & 255 ^ crc(i))& 255;
crc(i+1) = crc(i) >> 8 ^ crcTable[data(i+1)];
data(i+2) = (r2[i+2] & 255 ^ crc(i+1)) &255;
crc(i+2) = crc(i+1) >> 8 ^ crcTable[data(i+2)];
data(i+3) = (r2[i+3] & 255 ^ crc(i+2))& 255;
crc(i+3) = crc(i+2) >> 8 ^ crcTable[data(i+3)];
data(i+4) = (r2[i+4] & 255 ^ crc(i+3))&255;
crc(i+4) = crc(i+3) >> 8 ^ crcTable[data(i+4)];
data(i+5) = ((r2[i+5] & 255 ^ crc(i+4))&255);
crc(i+5) = crc(i+4) >> 8 ^ crcTable[data(i+5)];
data(i+6) = ((r2[i+6]& 255 ^ crc(i+5))&255);
crc(i+6) = crc(i+5) >> 8 ^ crcTable[data(i+6)];
_t51 = _t51 + 8;
_t84 = _t84 - 8;
__ebp = __ebp - 1;
data(i+7) = ((r2[i+7] & 255 ^ crc(i+6))&255);
_t86 = crc(i+6) >> 8 ^ crcTable[data(i+7)];
} while(_t88 != 0);
while(_t89 != 0) {
data(i) = (r2[i] & 255 ^ _t86)& 255;
_t86 = _t86 >> 8 ^ crcTable[data(i)];
_t51 = _t51 + 1;
_t84 = _t84 - 1;
}
_pop(__edi);
_pop(__esi);
return !_t86;
}
I assume that the first loop is computing the CRC using 8 bytes steps, until less than 8 bytes remain. The second loop is processing these remaining bytes.
Last edited: