Clone of Akilla's acserver @ https://github.com/deregtd/ACServer

wembly_crc.cpp 388B

12345678910111213141516171819202122232425
  1. DWORD GetMagicNumber(BYTE * buf, UINT cb, BOOL bIncludeSize)
  2. {
  3. DWORD dwCS = 0;
  4. UINT i;
  5. if ( bIncludeSize )
  6. {
  7. dwCS += cb<<16;
  8. }
  9. // sum up the DWORDs:
  10. for ( i = 0; i<(cb>>2); i++ )
  11. {
  12. dwCS += ((DWORD *)buf)[i];
  13. }
  14. // now any remaining bytes are summed in reverse endian
  15. int shift=3;
  16. for ( i=(i<<2); i<cb; i++ )
  17. {
  18. dwCS += buf[i]<<(shift*8);
  19. shift--;
  20. }
  21. return dwCS;
  22. }