Does anyone know how checksum is calculated for adj after editing it? Is there other tools available other than hutools?
It's a CRC32 stored between bytes 0 and 3 (inclusive).
This is the function that calculates it:
Code:
UINT32 crcCalc(UINT32 crc,UINT8 *data,UINT32 len)
{
UINT32 crct;
uint uVar1;
int iVar2;
UINT32 i;
uint uVar3;
UINT32 j;
int iVar4;
UINT32 crcTab [256];
iVar2 = 0;
do {
iVar4 = 0;
uVar1 = iVar2 << 0x18;
do {
if ((int)uVar1 < 0) {
uVar1 = uVar1 * 2 ^ 0x4c11db7;
}
else {
uVar1 = uVar1 * 2;
}
iVar4 = iVar4 + 1;
} while (iVar4 != 8);
crcTab[iVar2] = uVar1;
iVar2 = iVar2 + 1;
} while (iVar2 != 0x100);
uVar1 = ~((uint)data[1] << 0x10 | (uint)*data << 0x18 | (uint)data[2] << 8 | (uint)data[3]);
for (uVar3 = 0; uVar3 < len - 4; uVar3 = uVar3 + 1) {
uVar1 = crcTab[uVar1 >> 0x18] ^ (uVar1 << 8 | (uint)data[uVar3 + 4]);
}
return ~uVar1;
}
0x4c11db7 POLY and reverse=true.
I don't have the time to figure out the exact offsets of the data it computes over.
There's a much simpler way tho. Modify your adjust file, put it on a flash drive and run:
Code:
sysetadjread --check=/fs/usb0/adjust_edited.bin
Output:
Code:
sysetadjread: WARNING: check: stored CRC: 7B19ACE5, calculated CRC: 2D026109
FAILURE
Note that the sum is stored in Little Endian in the file.
-PS I did not test what happens if you try to push this file. But since the CS is obtained from the OS binary it's definitely correct.