#include <iostream>
#include <string>
#include <windows.h>
std::string GetCPUID()
{
std::string strCPUId;
unsigned long s1, s2;
char buf[32] = { 0 };
__asm
{
mov eax, 01h //eax=1:取CPU序列号
xor edx, edx
cpuid
mov s1, edx
mov s2, eax
}
if (s1)
{
memset(buf, 0, 32);
sprintf_s(buf, 32, "%08X", s1);
strCPUId += buf;
}
if (s2)
{
memset(buf, 0, 32);
sprintf_s(buf, 32, "%08X", s2);
strCPUId += buf;
}
__asm
{
mov eax, 03h
xor ecx, ecx
xor edx, edx
cpuid
mov s1, edx
mov s2, ecx
}
if (s1)
{
memset(buf, 0, 32);
sprintf_s(buf, 32, "%08X", s1);
strCPUId += buf;
}
if (s2)
{
memset(buf, 0, 32);
sprintf_s(buf, 32, "%08X", s2);
strCPUId += buf;
}
return strCPUId;
}
int main(int argc, _TCHAR* argv[])
{
std::cout << "CPUID:" << GetCPUID() << std::endl;
getchar();
return 0;
}
最后
以上就是忧虑发卡最近收集整理的关于汇编获取CPU的id的全部内容,更多相关汇编获取CPU内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复