Strange UuidCreateSequential Behavior

I have software that runs more than 2000 computers in my company, without any problems.

This software will at some point generate a GUID (or UUID ) using UuidCreateSequential() (

+4
source share
3 answers

I contacted Microsoft and it seems that the error only occurs in Windows XP when the first byte of the MAC address is greater than or equal to 0x80 .

This is fixed for Windows Vista and Windows Seven. It will not be fixed for Windows XP.

+6
source

This was a bug in Windows XP and Windows Server 2003.

The MAC address is 48 bits, usually represented as:

 00-01-02-0A-0B-0C 00:01:02:0a:0b:0c 

The first three bytes represent Organziation , the remaining three bytes are any numbering scheme that the organization wants to use. The organization identifier is transmitted by the IEEE.

For all public MAC addresses, the second-least (second least significant bit) of the first byte will be zero. If you want to create your own local MAC addresses, you can set the bit to 1:

 00-01-02-0A-0B-0C 00000000-00000001-00000010-00001010-00001011-00001100 ^ | +- 0: Universal 1: Locally Administered 

Or an image taken from Wikipedia:

enter image description here

Windows checked the wrong bit

The error in Windows XP and Windows Server 2003 is that they checked the wrong bit. They mistakenly checked the high bit:

I hate throwing Raymond under the bus, but here is an example of the wrong information :

The last 48 bits is the unique address of the computer network card. If the computer does not have a network card, set the upper bit and use the random number generator for the other 47. An invalid network card will have the upper bit set in its address , so there is no possibility that the GUID generated from the computer without the network card will accidentally collide with GUID generated from a computer with a network card.

The emphasis is mine. The correction will be that:

... set the second least significant bit ... There is no valid network card that will have the second least significant bit.

Testing

I tested this on my computer. My computer has a MAC address:

 ‎C8-60-00-12-34-56 (Ok, i changed the serialized number, but it is a Realtek) 

If we follow the rules of Windows XP, this MAC address will be “locally administered” and UuidCreateSequential will return RPC_S_UUID_LOCAL_ONLY

When I run UuidCreateSequential on Windows 7, it works fine:

 {FBE65AFC-2588-11E5-9F09-C86000123456} {FBE65AFD-2588-11E5-9F09-C86000123456} {FBE65AFE-2588-11E5-9F09-C86000123456} {FBE65AFF-2588-11E5-9F09-C86000123456} 

But if I ran it on a computer running Windows XP with the same (or similar) MAC address:

enter image description here

The function does not work:

0x720 A UUID is allocated that is valid only on this computer.

Fix

This error checking an invalid MAC address bit has been documented in:

This has also been described in UuidCreateSequential as well:

There was a related fix, but I do not believe that it was fixed outside of this (i.e. no official fix in the service pack).

You have three options:

  • change your MAC address in Windows XP settings so as not to have a high bit
  • upgrade to Windows Vista or later
  • if the function returns RPC_S_UUID_LOCAL_ONLY , and you are in front of Windows Vista ( dwMajor < 6 ), then suppose it really succeeded ( Danger! )
+3
source

Perhaps this is a security issue, is the user calling the call an administrator? Otherwise, the NIC driver may not indicate the MAC address.

If the UUID is used for something local on this computer, then accepting this error as a valid result may be OK.

If a UUID needs to be guaranteed globally unique (for example, registering an asset), then requesting another field (for example, a registration server) might be a better idea.

+1
source

Source: https://habr.com/ru/post/1316305/


All Articles