The following section contains the details on how the Checksum algorithm generates identifier values for those device drivers that do not support the new ICM DeviceCapabilities indices.
If the driver does not return the manufacturer and model to the DeviceCapabilities call, GDI constructs these form the (unfriendly) printer name. A CRC is applied to the whole name to get the model identifier. The CRC is determined as follows:
WORD wCRC16a[16]={
0000000, 0140301, 0140601, 0000500,
0141401, 0001700, 0001200, 0141101,
0143001, 0003300, 0003600, 0143501,
0002400, 0142701, 0142201, 0002100,
};
WORD wCRC16b[16]={
0000000, 0146001, 0154001, 0012000,
0170001, 0036000, 0024000, 0162001,
0120001, 0066000, 0074000, 0132001,
0050000, 0116001, 0104001, 0043000,
};
void Get_CRC_CheckSum(PVOID pBuffer, ULONG ulSize, PULONG pulSeed)
{
PBYTE pb;
BYTE bTmp;
for (pb=(BYTE *)pBuffer; ulSize; ulSize--, pb++)
{
bTmp=(BYTE)(((WORD)*pb)^((WORD)*pulSeed)); // Xor CRC with new char
*pulSeed=((*pulSeed)>>8) ^ wCRC16a[bTmp&0x0F] ^ wCRC16b[bTmp>>4];
}
}