/********************************************************/ /* ntapi: Native API core library */ /* Copyright (C) 2013--2017 Z. Gilboa */ /* Released under GPLv2 and GPLv3; see COPYING.NTAPI. */ /********************************************************/ #include #include #include "ntapi_impl.h" static const uint64_t crc64_table[256] = NTAPI_CRC64_TABLE; uint64_t __ntapi_tt_buffer_crc64( uint64_t prev_hash, const void * buffer, size_t size) { const unsigned char * ch; uint64_t crc64; crc64 = prev_hash ^ 0xFFFFFFFFFFFFFFFF; ch = buffer; for (; size; size--,ch++) crc64 = (crc64 >> 8) ^ crc64_table[(crc64 ^ *ch) & 0xFF]; return (crc64 ^ 0xFFFFFFFFFFFFFFFF); } uint64_t __cdecl __ntapi_tt_mbstr_crc64(const void * str) { const unsigned char * ch; uint64_t crc64; crc64 = 0 ^ 0xFFFFFFFFFFFFFFFF; ch = str; while (*ch) { crc64 = (crc64 >> 8) ^ crc64_table[(crc64 ^ *ch) & 0xFF]; ch++; } return (crc64 ^ 0xFFFFFFFFFFFFFFFF); } const uint64_t * __cdecl __ntapi_tt_crc64_table(void) { return crc64_table; }