static std::string cpu() { std::string result; Registers r; // r.eax, r.ebx, r.ecx, r.edx; r = cpuID(0x80000000); if (r.eax & 0x80000000 && r.eax >= 0x80000004) { uint32 brand[13]; char * p; r = cpuID(0x80000002); brand[0] = r.eax; brand[1] = r.ebx; brand[2] = r.ecx; brand[3] = r.edx; r = cpuID(0x80000003); brand[4] = r.eax; brand[5] = r.ebx; brand[6] = r.ecx; brand[7] = r.edx; r = cpuID(0x80000004); brand[8] = r.eax; brand[9] = r.ebx; brand[10] = r.ecx; brand[11] = r.edx; brand[12] = 0; p = (char *)brand; while (*p != 0 && *p == ' ') { p++; } result = p; } return result; }
QString SystemUtils::cpuType() { int CPUInfo[4] = {-1}; unsigned nExIds, i = 0; char CPUBrandString[0x40]; // Get the information associated with each extended ID. cpuID(0x80000000, CPUInfo); nExIds = CPUInfo[0]; for (i = 0x80000000; i <= nExIds; ++i) { cpuID(i, CPUInfo); // Interpret CPU brand string if (i == 0x80000002) memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo)); else if (i == 0x80000003) memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo)); else if (i == 0x80000004) memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo)); } //string includes manufacturer, model and clockspeed return QString(CPUBrandString).trimmed(); }
static std::string cpuid() { std::ostringstream s; Registers r; uint32 family; //, extendedFamily; uint32 model; //, extendedModel; uint32 stepping; uint32 vendor[4]; char * p; r = cpuID(1); family = (r.eax & 0xf00) >> 8; model = (r.eax & 0xf0) >> 4; stepping = r.eax & 0xf; if (family == 0x06 || family == 0x0f) { if (family == 0x0f) { family += ((r.eax & 0xff00000) >> 20); } model += ((r.eax & 0x000f0000) >> 12); }
uint32 vendor[4]; char * p; r = cpuID(1); family = (r.eax & 0xf00) >> 8; model = (r.eax & 0xf0) >> 4; stepping = r.eax & 0xf; if (family == 0x06 || family == 0x0f) { if (family == 0x0f) { family += ((r.eax & 0xff00000) >> 20); } model += ((r.eax & 0x000f0000) >> 12); } //std::cout << "!" << std::endl; r = cpuID(0); vendor[0] = r.ebx; vendor[1] = r.edx; vendor[2] = r.ecx; vendor[3] = 0; p = (char *)vendor; s << p << " Family " << family << " Model " << model << " Stepping " << stepping; return s.str(); } static bool cpusse() { Registers r; r = cpuID(0x00000001);