static bool compare_timespec(hdr_timespec* a, hdr_timespec* b) { char a_str[128]; char b_str[128]; long a_tv_msec = ns_to_ms(a->tv_nsec); long b_tv_msec = ns_to_ms(b->tv_nsec); if (a->tv_sec == b->tv_sec && a_tv_msec == b_tv_msec) { return true; } if (a->tv_sec != b->tv_sec) { #if defined(_MSC_VER) _ctime32_s(a_str, sizeof(a_str), &a->tv_sec); _ctime32_s(b_str, sizeof(b_str), &b->tv_sec); printf("tv_sec: %s != %s\n", a_str, b_str); #else printf( "tv_sec: %s != %s\n", ctime_r(&a->tv_sec, a_str), ctime_r(&b->tv_sec, b_str)); #endif } if (a_tv_msec == b_tv_msec) { printf("%ld != %ld\n", a->tv_nsec, b->tv_nsec); } return false; }
DWORD GetHWIDchunk(int chunk) { VU("GetHWIDchunk"); int res = -1; switch (chunk) { case 1: { //CPUID char cpudata[0x50]; memset(cpudata, 0, 0x50); __asm { pushad lea edi, cpudata add edi, 0x4C mov esi, 0x80000004 mov eax, 0x80000000 cpuid cmp eax, esi jl errora loopa: mov eax, esi cpuid mov [edi], edx mov [edi-4], ecx mov [edi-8], ebx mov [edi-12], eax sub edi, 0x10 dec esi cmp esi, 0x7FFFFFFF jne loopa mov res, 1 jmp exita errora: mov res, 0 exita: popad } PrintBuffer((BYTE *)cpudata, 0x50, 16); info("GetHWIDchunk(%d) %d res", chunk, res); if (res = 1) return GetCRC32(cpudata, 0x50); info("GetHWIDchunk() Fail, returning default for request %d.", chunk); return 0xBAADD00D; } break; case 2: { //windows installation date char windir[256]; memset(windir, 0, 256); GetWindowsDirectoryA(windir, 255); info("GetHWIDchunk() Windows folder = %s", windir); struct _stat32 f_stats; if (_stat32(windir, &f_stats) == 0) { char timebuf[256]; _ctime32_s(timebuf, 26, &f_stats.st_ctime); info("GetHWIDchunk() Windows folder (%s) creation date = %s", windir, timebuf); if (strstr(timebuf, V(" 201")) == NULL && strstr(timebuf, V(" 200")) == NULL) return 0xBAADD00D; return f_stats.st_ctime ^ GetCRC32(windir, 20); } info("GetHWIDchunk() Fail, returning default for request %d.", chunk); return 0xBAADD00D; } break; case 3: { char compname[256]; memset(compname, 0, 256); DWORD maxlen = 256; GetComputerNameA(compname, &maxlen); return GetCRC32(compname, sizeof(compname)); } break; default: return 0; } return 0; VE(); }