4

VMWare configuration files contains a line like

uuid.bios = "56 4d ed cf 3c cd 63 20-53 78 95 86 26 92 22 c8"

And afaik most (every?) physical BIOS has such an UUID. Is there any Windows API call to get this identifier?

I've tried the WMI class Win32_ComputerSystemProduct.UUID property but the value is different from the uuid.bios value. The value of HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\MachineGuid is different, too.

cytrinox
  • 1,846
  • 5
  • 25
  • 46
  • what about `WIN32_BIOS` class (http://msdn.microsoft.com/en-us/library/windows/desktop/aa394077%28v=vs.85%29.aspx)? – teran Mar 30 '12 at 09:11
  • This class contains no UUID (SerialNumber is something different). Interesting: dmidecode shows the uuid.bios UUID as mainboard UUID, not BIOS UUID. – cytrinox Mar 30 '12 at 09:15

1 Answers1

8

That value is called Universal Unique ID number and is part of the SMBIOS tables, if you use the SerialNumber property of the Win32_BIOS WMI class youu will get the same id of the uuid.bios (from the vmx file) entry plus the prefix VMware- (example : VMware-56 4d af ac d8 bd 4d 2c-06 df ca af 89 71 44 93)

uses
  SysUtils,
  ActiveX,
  ComObj,
  Variants;

// The Win32_BIOS class represents the attributes of the computer system's basic input/output services (BIOS) that are installed on the computer.

procedure  GetWin32_BIOSInfo;
const
  WbemUser            ='';
  WbemPassword        ='';
  WbemComputer        ='localhost';
  wbemFlagForwardOnly = $00000020;
var
  FSWbemLocator : OLEVariant;
  FWMIService   : OLEVariant;
  FWbemObjectSet: OLEVariant;
  FWbemObject   : OLEVariant;
  oEnum         : IEnumvariant;
  iValue        : LongWord;
begin;
  FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
  FWMIService   := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword);
  FWbemObjectSet:= FWMIService.ExecQuery('SELECT SerialNumber FROM Win32_BIOS','WQL',wbemFlagForwardOnly);
  oEnum         := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant;
  if oEnum.Next(1, FWbemObject, iValue) = 0 then
    Writeln(Format('SerialNumber    %s',[String(FWbemObject.SerialNumber)]));// String
end;


begin
 try
    CoInitialize(nil);
    try
      GetWin32_BIOSInfo;
    finally
      CoUninitialize;
    end;
 except
    on E:EOleException do
        Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode])); 
    on E:Exception do
        Writeln(E.Classname, ':', E.Message);
 end;
 Writeln('Press Enter to exit');
 Readln;      
end.

If you want return the same uuid without the VMware- prefix you must read the SMBIOS tables directly (check the System Information table type 1 and the UUID field), try this article Reading the SMBios Tables using Delphi whcih include has a sample code to list this value.

UUID Format

From the System Management BIOS (SMBIOS) Reference Specification

A UUID is an identifier that is designed to be unique across both time and space. It requires no central registration process. The UUID is 128 bits long. Its format is described in RFC 4122, but the actual field contents are opaque and not significant to the SMBIOS specification, which is only concerned with the byte order. Table 10 shows the field names; these field names, particularly for multiplexed fields, follow historical practice.

enter image description here

Although RFC 4122 recommends network byte order for all fields, the PC industry (including the ACPI, UEFI, and Microsoft specifications) has consistently used little-endian byte encoding for the first three fields: time_low, time_mid, time_hi_and_version. The same encoding, also known as wire format, should also be used for the SMBIOS representation of the UUID.

The UUID {00112233-4455-6677-8899-AABBCCDDEEFF} would thus be represented as: 33 22 11 00 55 44 77 66 88 99 AA BB CC DD EE FF.

If the value is all FFh, the ID is not currently present in the system, but it can be set. If the value is all 00h, the ID is not present in the system.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
  • 2
    This returns only the string "SerialNumber System Serial Number". – cytrinox Mar 30 '12 at 13:49
  • The SMBIOS example works, the UUID is identical to the vmware or kvm uuid. But why has Win32_ComputerSystemProduct.UUID a different value? – cytrinox Mar 30 '12 at 14:14
  • The UUID is the same but some fields are represented in another format. check the update to the answer. – RRUZ Mar 30 '12 at 14:50
  • Doh.. okay thank you! :) So I can use the Win32_ComputerSystemProduct.UUID property instead of parsing SMBIOS data. – cytrinox Apr 02 '12 at 06:51