CPU序列号

发布于 2024-07-05 07:22:39 字数 22 浏览 10 评论 0原文

如何获取PC中CPU的序列号?

How do I obtain the serial number of the CPU in a PC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

酒绊 2024-07-12 07:22:39

我在没有任何外部库的情况下得到了最终的答案。 只需输入以下内容:

wmic BIOS get Serialnumber

这将为您提供 PC 机箱上的序列号;)
(可在微软知识库中找到)

问候!

I have the ultimate answer for this without any external libraries. Simply type this:

wmic bios get serialnumber

This will give you the Serial Number on the PCs chassis ;)
(found in microsoft's knowledge base)

Regards!

抚你发端 2024-07-12 07:22:39

Intel CPU 中 Pentium III 之后没有 CPU 序列号(PSN;CPUID edx 位 18“psn”处理器序列号); AMD 芯片中从来没有任何 psn:

https://software .intel.com/en-us/forums/watercooler-catchall/topic/308483(2005 年)

但是,请记住,只有 Pentium III Xeon、Mobile Pentium III 和 Pentium III 处理器支持 Pentium III 处理器引入的处理器序列号功能。 没有其他英特尔处理器支持处理器序列号功能

https://en.wikipedia.org/wiki/Pentium_III #Controversy_about_privacy_issues

https://en.wikipedia.org/wiki/CPUID #EAX=3:_Processor_Serial_Number

EAX=3:处理器序列号
另请参阅:奔腾 III § 关于隐私问题的争议

这将返回处理器的序列号。 处理器序列号是在 Intel Pentium III 上引入的,但出于隐私考虑,此功能在后续型号上不再实现(PSN 功能位始终被清除)。 Transmeta 的 Efficeon 和 Crusoe 处理器也提供此功能。 然而,AMD CPU 并未在任何 CPU 型号中实现此功能。

There is no CPU serial ID (PSN; CPUID edx bit 18 "psn" Processor Serial Number) after Pentium III in Intel CPUs; and there was never any psn in AMD chips:

https://software.intel.com/en-us/forums/watercooler-catchall/topic/308483 (at 2005)

However, keep in mind that only the Pentium III Xeon, Mobile Pentium III and Pentium III processors support the processor serial number feature introduced by the Pentium III processor. No other Intel processor supports the processor serial number feature

https://en.wikipedia.org/wiki/Pentium_III#Controversy_about_privacy_issues

https://en.wikipedia.org/wiki/CPUID#EAX=3:_Processor_Serial_Number

EAX=3: Processor Serial Number
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 (the 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.

[旋木] 2024-07-12 07:22:39

即使启用了 CPUID,现代处理器中实际上还有可用的序列号吗? 我记得当整个序列号问题被提出时,Pentium 3 引起了强烈的抗议。

Even with CPUID enabled is there actually a serial number available in modern processors? I remember there being a big outcry in the Pentium 3 days when this whole serial number issue was raised.

甜`诱少女 2024-07-12 07:22:39

这是旧线程。 但我遇到了同样的问题,但我得到了以下逻辑,没有太多的“如果”、“与”或“但是”。

CPU序列号的问题是它并不总是在虚拟化环境中工作。

我对一组基于 Windows 的服务器执行了以下逻辑:

Win32_BIOS 可以为您提供 BIOS 的序列号。 我们需要记住,如果系统是虚拟化的,您最终可能会为所有服务器提供相同的 BIOS 序列号。

Win32_NetworkAdapter 可以为您提供一个您也可以使用的 MAC。 如果您有多个 NIC,您最终将获得多个 MAC。

将这两个 ID 结合起来,我就拥有了跨越物理和虚拟的 6000 台服务器的全部唯一集。 使用 ManagementClass & 实现起来非常简单。 管理对象

但需要注意的是:当您尝试远程获取 MO 实例时,在 <5 毫秒延迟的 10Gbps 光纤网络上将花费几秒钟以上的时间。 所以如果你算一下,我在单线程操作上花费了 3 个多小时。 由于这更像是低优先级流量,我不想向我的网络发送垃圾邮件以收集多线程调用上的 WMI 数据。

This is and old thread. But I had a same problem, but I got the following logic working without too many ifs, ands or buts.

The problem with CPU serial number is that it does not always work in virtualized environment.

I did the following logic with a set of Windows-based servers:

Win32_BIOS can provide you a serial number of the bios. We need to keep in mind that if the system is virtualized, you could end up with same bios serial number for all servers.

Win32_NetworkAdapter can provide you a MAC that you can use as well. In cases where you have multiple NICs, you will end up with multiple-MACs.

Combining both these IDs, I had all unique set over a set of 6000 servers spanning across physical and virtual. This was really simple to implement using ManagementClass & ManagementObject.

But just a caveat: when you try to get the MO instance remotely, it'll take more than a few seconds on a <5ms latency 10Gbps optical network. So if you do the math it took me over 3 hours on a single thread operation. Since this is more like a low-priority traffic I didn't want to spam my network for gathering WMI data on multi-threaded call.

小情绪 2024-07-12 07:22:39

请记住,现在大多数计算机在出厂时都在 BIOS 中禁用了 CPU ID。 请参阅 维基百科上的 CPUID

Remember that most computers these days ship with CPU ID disabled in the BIOS. See CPUID on Wikipedia

一桥轻雨一伞开 2024-07-12 07:22:39

Ivy Bridge CPU 及更新版本均包含 PPIN(受保护的处理器识别号)。 计算机的固件可以阻止对此功能的访问。

https://lore.kernel.org/patchwork/patch/736614/

Ivy Bridge CPUs and newer all include a PPIN (Protected Processor Identification Number). Access to this feature can be blocked by the computer's firmware.

https://lore.kernel.org/patchwork/patch/736614/

把回忆走一遍 2024-07-12 07:22:39

使用正确的寄存器设置执行 CPUID 指令将检索 EAX、EBX、ECX 和 EDX 中的处理器序列号。 但是,此功能仅适用于 Pentium 3 及更高版本的处理器。 同样,在 Pentium 4 和更新的处理器上,该指令始终在所有 4 个寄存器中返回 0x00000000。 更高型号的 Pentium 3 也可能返回 0x00000000。 该功能主要旨在复制保护,允许软件链接到特定处理器。 它在社区中反响不佳,随之而来的是诉讼。 该功能已从最新型号 P3 和所有较新的处理器中删除。 出于兼容性原因,该功能出现在较新的处理器中。 据传,您可以特别订购具有序列号的处理器,btu 的最低购买量约为 100 万个处理器。 有关执行 CPUID 指令之前的具体寄存器设置,请通过其网站查看 Intel 的系统程序员 PDF。

还 -


#include <Windows.h>
#include <stdio.h>
#include <xmmintrin.h>
#include <iphlpapi.h>
#include <Rpc.h>

static void GetMACaddress(void);
static void uuidGetMACaddress(void);

int main(){
    SYSTEM_INFO SysInfo;
    GetSystemInfo(&SysInfo);
    printf("Processors - %d\n" , SysInfo.dwNumberOfProcessors);
    DWORD a , b , c , d , e;
    DWORD BasicLeaves;
    char* VendorID = (char*)malloc(20);
    char* message = (char*)malloc(20);
    _asm {
        pusha
        pushfd
        pop eax
        push eax
        xor eax , 0x00200000
        push eax
        popfd
        pushfd
        pop ecx
        pop eax
        xor eax , ecx
        mov [a] , eax
        }
    if(a & 0x00200000){
        printf("CPUID opcode supported.\n");
        } else {
        printf("CPUID opcode not supported, exiting...\n");
        return 0;
        }

    //DWORD* pa = &a[0];
    //DWORD* pb = &a[1];
    //DWORD* pc = &a[2];
    //DWORD* pd = &a[3];
    //a[4] = 0;
    e = 0;
    __asm {
        mov eax , 0
        cpuid
        mov [BasicLeaves] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }
    memcpy(&VendorID[0] , &b , 4);
    memcpy(&VendorID[4] , &d , 4);
    memcpy(&VendorID[8] , &c , 4);
    VendorID[12] = 0;

    printf("%d Basic Leaves\nVendorID - %s\n" , BasicLeaves , VendorID);

    __asm {
        mov eax , 1
        cpuid
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }
    if(d & 0x00000001) printf("FPU\n");
    if(d & 0x00000200) printf("APIC On-Chip\n");
    if(d & 0x00040000) printf("Processor Serial Number Present\n");
    if(d & 0x00800000) printf("MMX\n");
    if(d & 0x01000000) printf("SSE\n");
    if(d & 0x02000000) printf("SSE2\n");
    if(d & 0x08000000) printf("Hyperthreading (HTT)\n");

    if(c & 0x00000001) printf("SSE3\n");
    if(c & 0x00000200) printf("SSSE3\n");
    if(c & 0x00080000) printf("SSE4.1\n");
    if(c & 0x00100000) printf("SSE4.2\n");
    if(c & 0x02000000) printf("AES\n");


    __asm {
        mov eax , 0x80000000
        cpuid
        and eax , 0x7fffffff;
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }

    printf("%d Extended Leaves\n" , a);

    printf("Processor Brand String - ");
    __asm {
        mov eax , 0x80000002
        cpuid
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }
    memcpy(&message[0] , &a , 4);
    memcpy(&message[4] , &b , 4);
    memcpy(&message[8] , &c , 4);
    memcpy(&message[12] , &d , 4);
    message[16] = 0;
    printf("%s" , message);

    __asm {
        mov eax , 0x80000003
        cpuid
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }

    memcpy(&message[0] , &a , 4);
    memcpy(&message[4] , &b , 4);
    memcpy(&message[8] , &c , 4);
    memcpy(&message[12] , &d , 4);
    message[16] = 0;
    printf("%s" , message);

    __asm {
        mov eax , 0x80000004
        cpuid
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        popa
        }
    memcpy(&message[0] , &a , 4);
    memcpy(&message[4] , &b , 4);
    memcpy(&message[8] , &c , 4);
    memcpy(&message[12] , &d , 4);
    message[16] = 0;
    printf("%s\n" , message);

    char VolumeName[256]; DWORD VolumeSerialNumber; DWORD MaxComponentLength; DWORD FileSystemFlags; char FileSystemNameBuffer[256]; 
    GetVolumeInformationA("c:\\" , VolumeName , 256 , &VolumeSerialNumber , &MaxComponentLength , &FileSystemFlags , (LPSTR)&FileSystemNameBuffer , 256);
    printf("Serialnumber - %X\n" , VolumeSerialNumber);

    GetMACaddress();
    uuidGetMACaddress();

    return 0;
    }

// Fetches the MAC address and prints it
static void GetMACaddress(void){
    IP_ADAPTER_INFO AdapterInfo[16];        // Allocate information 
                                            // for up to 16 NICs
    DWORD dwBufLen = sizeof(AdapterInfo);   // Save memory size of buffer

    DWORD dwStatus = GetAdaptersInfo(       // Call GetAdapterInfo
    AdapterInfo,                            // [out] buffer to receive data
    &dwBufLen);                             // [in] size of receive data buffer
    //assert(dwStatus == ERROR_SUCCESS);    // Verify return value is 
                                            // valid, no buffer overflow

    PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to
                                            // current adapter info
    do {
        printf("Adapter MAC Address - %X-%X-%X-%X-%X-%X\n" , pAdapterInfo->Address[0] , pAdapterInfo->Address[1] , pAdapterInfo->Address[2] , pAdapterInfo->Address[3] , pAdapterInfo->Address[4] , pAdapterInfo->Address[5]);
        printf("Adapter IP Address  - %s\n" , pAdapterInfo->CurrentIpAddress);
        printf("Adapter Type        - %d\n" , pAdapterInfo->Type);
        printf("Adapter Name        - %s\n" , pAdapterInfo->AdapterName);
        printf("Adapter Description - %s\n" , pAdapterInfo->Description);
        uuidGetMACaddress();

        printf("\n");
        //PrintMACaddress(pAdapterInfo->Address); // Print MAC address
        pAdapterInfo = pAdapterInfo->Next;      // Progress through 
                                                // linked list
        } while(pAdapterInfo);                  // Terminate if last adapter
    }

// Fetches the MAC address and prints it

static void uuidGetMACaddress(void)
{
  unsigned char MACData[6];

  UUID uuid;
  UuidCreateSequential( &uuid );    // Ask OS to create UUID

  for (int i=2; i<8; i++)  // Bytes 2 through 7 inclusive 
                           // are MAC address
    MACData[i - 2] = uuid.Data4[i];

  printf("UUID MAC Address - %X-%X-%X-%X-%X-%X\n" , MACData[0] , MACData[1] , MACData[2] , MACData[3] , MACData[4] , MACData[5]);
}//*/

Executing the CPUID instruction with the proper register settings will retrieve the processor serial number in EAX, EBX, ECX, and EDX. However, this functionality is only available on Pentium 3 and later processors. Also on Pentium 4 and newer processors the instruction always returns 0x00000000 in all 4 registers. Later model Pentium 3's may also return 0x00000000's. The feature was primarily aimed at copy protection, allowing software to be linked to specific processors. It did not go over well with the community, and lawsuits ensued. The feature was removed from late model P3's and all newer processors. The feature is present in newer processors for compatibility reasons. it is rumored than you can special order processors with serial numbers, btu the minimum purchase is something like 1 million processors. For the specific register settings prior to executing the CPUID instruction, check Intels system programmer PDF available through their website.

Also -


#include <Windows.h>
#include <stdio.h>
#include <xmmintrin.h>
#include <iphlpapi.h>
#include <Rpc.h>

static void GetMACaddress(void);
static void uuidGetMACaddress(void);

int main(){
    SYSTEM_INFO SysInfo;
    GetSystemInfo(&SysInfo);
    printf("Processors - %d\n" , SysInfo.dwNumberOfProcessors);
    DWORD a , b , c , d , e;
    DWORD BasicLeaves;
    char* VendorID = (char*)malloc(20);
    char* message = (char*)malloc(20);
    _asm {
        pusha
        pushfd
        pop eax
        push eax
        xor eax , 0x00200000
        push eax
        popfd
        pushfd
        pop ecx
        pop eax
        xor eax , ecx
        mov [a] , eax
        }
    if(a & 0x00200000){
        printf("CPUID opcode supported.\n");
        } else {
        printf("CPUID opcode not supported, exiting...\n");
        return 0;
        }

    //DWORD* pa = &a[0];
    //DWORD* pb = &a[1];
    //DWORD* pc = &a[2];
    //DWORD* pd = &a[3];
    //a[4] = 0;
    e = 0;
    __asm {
        mov eax , 0
        cpuid
        mov [BasicLeaves] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }
    memcpy(&VendorID[0] , &b , 4);
    memcpy(&VendorID[4] , &d , 4);
    memcpy(&VendorID[8] , &c , 4);
    VendorID[12] = 0;

    printf("%d Basic Leaves\nVendorID - %s\n" , BasicLeaves , VendorID);

    __asm {
        mov eax , 1
        cpuid
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }
    if(d & 0x00000001) printf("FPU\n");
    if(d & 0x00000200) printf("APIC On-Chip\n");
    if(d & 0x00040000) printf("Processor Serial Number Present\n");
    if(d & 0x00800000) printf("MMX\n");
    if(d & 0x01000000) printf("SSE\n");
    if(d & 0x02000000) printf("SSE2\n");
    if(d & 0x08000000) printf("Hyperthreading (HTT)\n");

    if(c & 0x00000001) printf("SSE3\n");
    if(c & 0x00000200) printf("SSSE3\n");
    if(c & 0x00080000) printf("SSE4.1\n");
    if(c & 0x00100000) printf("SSE4.2\n");
    if(c & 0x02000000) printf("AES\n");


    __asm {
        mov eax , 0x80000000
        cpuid
        and eax , 0x7fffffff;
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }

    printf("%d Extended Leaves\n" , a);

    printf("Processor Brand String - ");
    __asm {
        mov eax , 0x80000002
        cpuid
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }
    memcpy(&message[0] , &a , 4);
    memcpy(&message[4] , &b , 4);
    memcpy(&message[8] , &c , 4);
    memcpy(&message[12] , &d , 4);
    message[16] = 0;
    printf("%s" , message);

    __asm {
        mov eax , 0x80000003
        cpuid
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        }

    memcpy(&message[0] , &a , 4);
    memcpy(&message[4] , &b , 4);
    memcpy(&message[8] , &c , 4);
    memcpy(&message[12] , &d , 4);
    message[16] = 0;
    printf("%s" , message);

    __asm {
        mov eax , 0x80000004
        cpuid
        mov [a] , eax;
        mov [b] , ebx;
        mov [c] , ecx;
        mov [d] , edx;
        popa
        }
    memcpy(&message[0] , &a , 4);
    memcpy(&message[4] , &b , 4);
    memcpy(&message[8] , &c , 4);
    memcpy(&message[12] , &d , 4);
    message[16] = 0;
    printf("%s\n" , message);

    char VolumeName[256]; DWORD VolumeSerialNumber; DWORD MaxComponentLength; DWORD FileSystemFlags; char FileSystemNameBuffer[256]; 
    GetVolumeInformationA("c:\\" , VolumeName , 256 , &VolumeSerialNumber , &MaxComponentLength , &FileSystemFlags , (LPSTR)&FileSystemNameBuffer , 256);
    printf("Serialnumber - %X\n" , VolumeSerialNumber);

    GetMACaddress();
    uuidGetMACaddress();

    return 0;
    }

// Fetches the MAC address and prints it
static void GetMACaddress(void){
    IP_ADAPTER_INFO AdapterInfo[16];        // Allocate information 
                                            // for up to 16 NICs
    DWORD dwBufLen = sizeof(AdapterInfo);   // Save memory size of buffer

    DWORD dwStatus = GetAdaptersInfo(       // Call GetAdapterInfo
    AdapterInfo,                            // [out] buffer to receive data
    &dwBufLen);                             // [in] size of receive data buffer
    //assert(dwStatus == ERROR_SUCCESS);    // Verify return value is 
                                            // valid, no buffer overflow

    PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to
                                            // current adapter info
    do {
        printf("Adapter MAC Address - %X-%X-%X-%X-%X-%X\n" , pAdapterInfo->Address[0] , pAdapterInfo->Address[1] , pAdapterInfo->Address[2] , pAdapterInfo->Address[3] , pAdapterInfo->Address[4] , pAdapterInfo->Address[5]);
        printf("Adapter IP Address  - %s\n" , pAdapterInfo->CurrentIpAddress);
        printf("Adapter Type        - %d\n" , pAdapterInfo->Type);
        printf("Adapter Name        - %s\n" , pAdapterInfo->AdapterName);
        printf("Adapter Description - %s\n" , pAdapterInfo->Description);
        uuidGetMACaddress();

        printf("\n");
        //PrintMACaddress(pAdapterInfo->Address); // Print MAC address
        pAdapterInfo = pAdapterInfo->Next;      // Progress through 
                                                // linked list
        } while(pAdapterInfo);                  // Terminate if last adapter
    }

// Fetches the MAC address and prints it

static void uuidGetMACaddress(void)
{
  unsigned char MACData[6];

  UUID uuid;
  UuidCreateSequential( &uuid );    // Ask OS to create UUID

  for (int i=2; i<8; i++)  // Bytes 2 through 7 inclusive 
                           // are MAC address
    MACData[i - 2] = uuid.Data4[i];

  printf("UUID MAC Address - %X-%X-%X-%X-%X-%X\n" , MACData[0] , MACData[1] , MACData[2] , MACData[3] , MACData[4] , MACData[5]);
}//*/
梦回旧景 2024-07-12 07:22:39

__get_cpuid (unsigned int __level, unsigned int *__eax, unsigned int *__ebx, unsigned int *__ecx, unsigned int *__edx);

  • 标头:#include

注意:处理器序列号是在 Intel Pentium III 上引入的,但出于隐私考虑,此功能在后续型号上不再实现。

来源:维基百科

__get_cpuid (unsigned int __level, unsigned int *__eax, unsigned int *__ebx, unsigned int *__ecx, unsigned int *__edx);

  • Header: #include <cpuid.h>

Note: The processor serial number was introduced on Intel Pentium III, but due to privacy concerns, this feature is no longer implemented on later models.

Source : wikipedia

烟花肆意 2024-07-12 07:22:39

请提供更多详细信息:操作系统、语言。

例如,在 Windows 上,您可以通过使用 WMI 并阅读 Win32_Processor.ProcessorId。

Some more details please: operating system, language.

For example on Windows you can get it by using WMI and reading Win32_Processor.ProcessorId.

海风掠过北极光 2024-07-12 07:22:39

在Windows中,我确信有一个系统调用,在Linux中,人们可以尝试“sudo lshw”,但大多数内核似乎不支持CPU序列号,初步研究似乎表明,对唯一可识别计算机的普遍愤怒意味着有没有完美的答案。

你想做什么? 几乎可以肯定有人以前做过,重复使用或模仿他们所做的事情可能是明智的。

In windows, I am sure there is a system call, In linux one could try "sudo lshw" but most kernels do not seem to support CPU serial numbers, and preliminary research seems to indicate that the general outrage against uniquely identifiable computers means that there is no perfect answer.

What are you trying to do? Almost certainly someone has done it before and it may be wise to reuse or emulate what they have done.

温柔少女心 2024-07-12 07:22:39

您可以使用 CPUID 命令。

You can use CPUID command.

枉心 2024-07-12 07:22:39

我想很多编译器确实提供了一些包装器或类似的东西
命令。 这是一个示例

#include <stdlib.h>
#include <string.h>
#include <intrinsics.h>

_CPUID cpuinfo;
int main(void) {
_cpuid(&cpuinfo);
printf("Vendor: %s\n", cpuinfo.Vendor);
return 0;
}

输出:

Vendor: GenuineIntel

I guess quite a few compiler do offer some wrapper or the like around the mentioned
command. Here's an example

#include <stdlib.h>
#include <string.h>
#include <intrinsics.h>

_CPUID cpuinfo;
int main(void) {
_cpuid(&cpuinfo);
printf("Vendor: %s\n", cpuinfo.Vendor);
return 0;
}

Output:

Vendor: GenuineIntel
行雁书 2024-07-12 07:22:39

我的建议是获取 HDD/SSD 序列号,许多语言都支持此。

My suggestion is to get HDD/SSD serial number, many languages have support for this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文