WMIC ProcessorID 取得的 CPUID

最近有人在群里询问是否有在电脑上生成唯一序列号的方法,有一个群友建议他使用下面的命令来获得:

wmic cpu get processorid

但是在我印象中,很久之前,CPU支持过序列号功能,但是被人指责侵犯隐私,所以现在的 CPU完全没有所谓的序列号。为此,做了一番研究,在【参考1】有介绍过这一段历史,在奔腾3中短暂的引入过这个功能,但是后来很快就移除了。

EAX=3: Processor Serial Number[edit]

See also:  Pentium III § Controversy about privacy issues

This returns the processor's serial number. The processor serial number was introduced on Intel Pentium III, but due to privacy concerns, this feature is no longer implemented on later models (PSN feature bit is always cleared). Transmeta's Efficeon and Crusoe processors also provide this feature. AMD CPUs however, do not implement this feature in any CPU models.

For Intel Pentium III CPUs, the serial number is returned in EDX:ECX registers. For Transmeta Efficeon CPUs, it is returned in EBX:EAX registers. And for Transmeta Crusoe CPUs, it is returned in EBX register only.

Note that the processor serial number feature must be enabled in the BIOS setting in order to function.

"这样取出来的只是 CPUID 指令运行的返回结果,在【参考2】中有指出:

实际上,获取到的值并不是CPU的编号或者序列号,也并不是唯一的,对此,微软在msdn上有相关说明:

msdn链接:http://msdn.microsoft.com/en-us/library/aa394373(v=vs.85).aspx

msdn上的原文是这样说的:

ProcessorId

Data type: string

Access type: Read-only

Processor information that describes the processor features. For an x86 class CPU, the field format depends on the processor support of the CPUID instruction. If the instruction is supported, the property contains 2 (two) DWORD formatted values. The first is an offset of 08h-0Bh, which is the EAX value that a CPUID instruction returns with input EAX set to 1. The second is an offset of 0Ch-0Fh, which is the EDX value that the instruction returns. Only the first two bytes of the property are significant and contain the contents of the DX register at CPU reset—all others are set to 0 (zero), and the contents are in DWORD format."

编写一个C 代码,在我工作机器运行 CPUID指令:

#include "stdafx.h"
#include<iostream>

int main()
{

	int32_t deBuf[4];

	__cpuidex(deBuf, 01, 0);
	printf("%.8x%.8x", deBuf[3], deBuf[0]);

	getchar();
    return 0;
}

运行结果:

自己编写的 CPUID指令程序运行结果

这个结果和我是用 WMIC 命令结果是相同的:

WMIC 取得的 processorid 结果

结论:不要使用 WMIC get processorid 取得的CPUID 作为序列号,这样的话会发现同一批机器结果不同。

参考:

  1. https://blog.csdn.net/fudong071234/article/details/49612083
  2. https://www.cnblogs.com/hhh/p/4022128.html

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注