Win32_Processor.ProcessorId 的格式是什么? [英] What's the format of Win32_Processor.ProcessorId?

查看:44
本文介绍了Win32_Processor.ProcessorId 的格式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试生成随机 ProcessorId,为了做到这一点,我需要弄清楚它的格式.

I'm trying to generate random ProcessorId, in order to do that, I need to figure out its format.

我计算机上的 ProcessorId:

The ProcessorId on my computer:

Get-WmiObject -Query "SELECT NAME, ProcessorId FROM Win32_Processor"

Get-WmiObject -Query "SELECT NAME, ProcessorId FROM Win32_Processor"

__GENUS          : 2
__CLASS          : Win32_Processor
__SUPERCLASS     :
__DYNASTY        :
__RELPATH        :
__PROPERTY_COUNT : 2
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
Name             : Intel(R) Core(TM) i7-3537U CPU @ 2.00GHz
ProcessorId      : BFEBFBFF000306A9
PSComputerName   :

来自 WMI 的 ProcessorId 属性具有以下描述:

The ProcessorId property from WMI has following description:

描述处理器功能的处理器信息.为x86 类 CPU,字段格式取决于处理器支持CPUID 指令.如果支持该指令,则属性包含 2(两个)DWORD 格式的值.第一个是偏移量08h-0Bh,这是 CPUID 指令返回的 EAX 值输入 EAX 设置为 1.第二个是 0Ch-0Fh 的偏移量,这是指令返回的 EDX 值.只有前两个字节该属性很重要并且包含 DX 的内容CPU 复位时的寄存器——所有其他设置为 0(零),并且内容DWORD 格式.

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.

该值来自 Processor 的 Processor ID 成员SMBIOS信息中的信息结构.

This value comes from the Processor ID member of the Processor Information structure in the SMBIOS information.

谁能详细解释一下Win32_Processor.ProcessorId的格式?

Can anyone explain deeply the format of Win32_Processor.ProcessorId?

如何从函数__cpuid生成它?

(此答案中的方法不起作用.)

(The method in this answer doesn't work.)

推荐答案

我还是不太明白 ProcessorId 的描述.

I still don't understand the ProcessorId description very well.

此代码生成与 Win32_Processor.ProcessorId 完全相同的字符串.

This code generate exactly the same string with Win32_Processor.ProcessorId.

#include <array>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <string>

std::string GetProcessorId() {
    std::array<int, 4> cpuInfo;
    __cpuid(cpuInfo.data(), 1);
    std::ostringstream buffer;
    buffer
        << std::uppercase << std::hex << std::setfill('0')
        << std::setw(8) << cpuInfo.at(3)
        << std::setw(8) << cpuInfo.at(0);
    return buffer.str();
}

int main(void) {
    std::cout << GetProcessorId() << std::endl;
    return 0;
}

这篇关于Win32_Processor.ProcessorId 的格式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆