void Executecpuid(DWORD veax) { // The following 4 DWORD variable store the four registers values after cpuid DWORD deax; DWORD debx; DWORD decx; DWORD dedx;
EAX Version Information: Type, Family, Model, and Stepping ID EBX Bits 7-0: Brand Index Bits 15-8: CLFLUSH line size Bits 23-16: Maximum number of logical processors inthis physical package. Bits 31-24: Initial APIC ID ECX Extended Feature Information EDX Feature Information
struct SerialNumber ...{ WORD nibble[6]; // 6 WORD nibble; SerialNumber() //constructor ...{ memset(nibble, 0, sizeof(nibble)); } }; Executecpuid(1); // Execute cpuid instruction with eax = 1 bool isSupport = m_edx & (1<<18); // Check if Serial Number is supported if (false== isSupport) // not support ...{ returnfalse; } memcpy(&serial.nibble[4], &m_eax, 4); // eax is the higher 2 nibble Executecpuid(3); // Execute cpuid instruction with eax = 3 memcpy(&serial.nibble[0], &m_ecx, 8); // ecx and edx constains the middle and first 4 nibble