-->

Is WMI a good way to making a hardware fingerprint

2020-03-06 03:58发布

问题:

I want to make a c++ install deployed windows application that would check hardware fingerprint (to verify that the user will use the application only on his computer). After some net research I decided that WMI is my tool. I started with a simple MFC application and for start I wanted to print out the MotherBoard SerialNumber. And just at this point the whole thing crashed. I checked on XP and Win7 and this property is not returned. And this got me thinking - what if there are some classes/properties that won't work on certain windows versions? Or some hardware configurations? I sincerely don't like that. My instant idea for the fingerprint was the MAC address (my application is strictly network driven so if the machine does not have a net connection it is no use at all). However, some machines can have several MAC devices. And some of MACs may be a virtual one's that can vanish from the system after uninstalling (i.e. VPN client). I think that MAC address can be easily changed but if I hashcode the number the user may not figure out that use it. So I ask for your advice - is WMI a good tool for Hardware fingerprint? If it is - which classes/properties would you suggest to use? They should work on all machines and systems and also be safe/unchangeable at the same time (ok we cannot do much if the user changes the whole hardware..) If WMI is not a good solution, than what other C++ framework would you suggest? And following - which HD properties to use then.

回答1:

Yes, the WMI is a very good option to do this task, the key is choose the right classes and properties to use or even better you can access the SMBIOS tables to get information about the system and generate a unique identifier. some time ago I blogged about both subjects, the code is in delphi but can be easily translatable to C++

  • Reading the SMBios Tables using Delphi
  • Generating a “unique” hardware ID using delphi and the WMI


回答2:

From my experience, No. WMI seems to be slow and sometime inaccurate. It would be better to use lower level methods and to query the hardware directly using Win32 API.