C ++获取处理器ID [英] C++ get Processor ID

查看:112
本文介绍了C ++获取处理器ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个线程确定。
如何获取处理器和主板ID? p>

我想使用不使用WMI或任何第三方库的C ++代码获取处理器ID。



或任何在计算机上显示为唯一的内容。
一件事是以太网ID,但在某些机器上又可以移除。这我主要用于许可目的。



处理器ID是否唯一且在所有主要处理器上都可用?

解决方案

我最近有一个类似的问题,我做了以下。首先,我获得了一些唯一的系统标识值:





  • GetComputerName (此当然不是唯一的,但是我们的系统使用计算机名称来识别LAN上的客户端,所以对我来说很好)


  • a href =http://msdn.microsoft.com/en-us/library/hskdteyh%28v=vs.80%29.aspx> __ cpuid (特别是PSN - 处理器序列number字段)





我把这些值,并以任意但确定的方式组合它们 (添加,修饰,划分和保留剩余部分等) 迭代这些值,就好像它们是字符串并且具有创造性。最后,您将获得一个字节字面值,您可以将其转换为ASCII字母和数字范围,以获得一个看起来不像噪声的独特的可读代码。



另一种方法可以简单地连接这些值,然后通过在它们之间隐藏一些东西来覆盖它们(并且可能再次转换为字母)。



我说它是唯一的,因为至少有一个输入应该是唯一的(MAC地址)。



重要更新:自从这篇文章我学习了一些关于加密的东西,我认为组成一个任意组合(基本上你自己的哈希)几乎肯定是一个坏主意。在实践中使用的哈希函数被构造为良好行为(如在低的碰撞概率)并且难以断开(该能力构造具有与另一个哈希值相同的哈希值)。构建这样的函数是一个非常困难的计算机科学问题,除非你有资格,你不应该尝试。正确的方法是连接您可以收集的有关硬件(即我在列表中列出的那些)的任何信息,并使用加密散列或数字签名来获得可验证和安全的输出。也不要自己实现加密算法;有很多漏洞陷阱需要大量的知识来避免。使用一个着名的和可信的库来实现算法。


This thread is ok. How to get Processor and Motherboard Id?

I wanted to get processor ID using C++ code not using WMI or any third party lib.

OR anything on a computer that turns out to be unique. One thing is Ethernet ID but which is again removable on some machines. This I want to use mostly for licensing purpose.

Is processor ID unique and available on all major processors?

解决方案

I had a similar problem lately and I did the following. First I gained some unique system identification values:

  • GetVolumeInformation for HDD serial number

  • GetComputerName (this of course is not unique, but our system was using the computer names to identify clients on a LAN, so it was good for me)

  • __cpuid (and specifically the PSN - processor serial number field)

  • GetAdaptersInfo for MAC addresses

I took these values and combined them in an arbitrary but deterministic way (read update below!) (adding, xoring, dividing and keeping the remainder etc.). Iterate over the values as if they were strings and be creative. In the end, you will get a byte literal which you can transform to the ASCII range of letters and numbers to get a unique, "readable" code that doesn't look like noise.

Another approach can be simply concatenating these values and then "cover them up" with xoring something over them (and maybe transforming to letters again).

I'm saying it's unique, because at least one of the inputs is supposed to be unique (the MAC address). Of course you need some understanding of number theory to not blew away this uniqueness, but it should be good enough anyway.

Important update: Since this post I learned a few things about cryptography, and I'm on the opinion that making up an arbitrary combination (essentially your own hash) is almost certainly a bad idea. Hash functions used in practice are constructed to be well-behaved (as in low probability of collisions) and to be hard to break (the ability construct a value that has the same hash value as another). Constructing such a function is a very hard computer science problem and unless you are qualified, you shouldn't attempt. The correct approach for this is to concatenate whatever information you can collect about the hardware (i.e. the ones I listed in the post) and use a cryptographic hash or digital signature to get a verifiable and secure output. Do not implement the cryptographic algorithms yourself either; there are lots of vulnerability pitfalls that take lots of knowledge to avoid. Use a well-known and trusted library for the implementation of the algorithms.

这篇关于C ++获取处理器ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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