UuidCreateSequential 的奇怪行为

发布于 2024-09-10 11:46:12 字数 665 浏览 2 评论 0原文

我有一个软件可以在我公司的 2000 多台计算机上运行,​​没有出现任何问题。

该软件有时会使用 UuidCreateSequential() (MSDN 链接)。

该调用通常在每台计算机上返回RPC_S_OK。但在其中之一上,它总是返回 RPC_S_UUID_LOCAL_ONLY 。

该文档指出:

UuidCreateSequential 函数 返回 RPC_S_UUID_LOCAL_ONLY 当 原始计算机没有 以太网/令牌环 (IEEE 802.x) 地址。

但是,这台计算机似乎没有网络问题。它有一个具有有效且唯一的 MAC 地址和 IP 地址的网卡,并且工作正常。

还有什么可能导致 UuidCreateSequential() 始终返回 RPC_S_UUID_LOCAL_ONLY ?您是否经历过类似的情况?

我这可以提供帮助,有问题的计算机运行的是更新的 Windows XP,带有 Service Pack 3。

I have a software that runs over 2 000 computers on my company, without any issues.

This software, at some time, generate a GUID (or UUID) using UuidCreateSequential() (MSDN link).

The call usually returns RPC_S_OK on every computer. But on one of them, it always returns RPC_S_UUID_LOCAL_ONLY.

The documentation states that:

The UuidCreateSequential function
returns RPC_S_UUID_LOCAL_ONLY when the
originating computer does not have an
ethernet/token ring (IEEE 802.x)
address.

However, there seem to be no networking issues with this computer. It has a network card with both valid and unique MAC address and IP address, and it is working perfectly.

What else could cause UuidCreateSequential() to always return RPC_S_UUID_LOCAL_ONLY ? Have you ever experienced a similar situation ?

I this can help, the computer which has the issues runs an updated Windows XP, with Service Pack 3.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

神妖 2024-09-17 11:46:12

我联系了微软,似乎这个错误只发生在Windows XP上,当MAC地址的第一个字节大于或等于0x80时。

Windows Vista 和 Windows 7 已修复此问题。 Windows XP 不会修复此问题。

I contacted Microsoft and it seems that bug occurs only on Windows XP, when the first byte of the MAC address is superior or equal to 0x80.

This has been fixed for Windows Vista and Windows Seven. It won't be fixed for Windows XP.

骑趴 2024-09-17 11:46:12

这是 Windows XP 和 Windows Server 2003 中的一个错误。MAC

地址为 48 位,通常表示为:

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

前三个字节表示组织,其余三个字节是组织想要的任何编号方案使用。组织 ID 由 IEEE 颁发。

对于所有公共 MAC 地址,第一个字节的第二个最低位(第二个最低有效位)将为零。如果您想生成自己的本地 MAC 地址,您可以将该位设置为 1:

02-01-02-0A-0B-0C

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

或者从 Wikipedia 获取的图像:

在此处输入图像描述

Windows 检查了错误的位

Windows XP 和 Windows Server 2003 中的错误是它们检查了错误的位。他们错误地检查了位:

我讨厌把雷蒙德扔到公共汽车下,但是这是错误信息的示例

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

A MAC address is 48 bits, typically represented as:

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

The first three bytes represent an Organziation, the remaining three bytes are whatever numbering scheme that organization wants to use. Organization ID's are handed out by the IEEE.

For all public MAC addresses, the 2nd-lowest (2nd least significant bit) of the first byte will be zero. If you wanted to generate your own local MAC addresses, you could set the bit to 1:

02-01-02-0A-0B-0C

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

Or the image lifted from Wikipedia:

enter image description here

Windows checked the wrong bit

The bug in Windows XP and Windows Server 2003 is that they were were checking the wrong bit. They were mistakenly checking the high bit:

I hate to throw Raymond under the bus, but here's an example of the incorrect information????:

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

Emphasis mine. The correction would be to say that:

...set the 2nd least significant bit... No valid network card will have the 2nd least significant bit set.

Testing

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

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

If we were to follow the Windows XP rules, this MAC address would be "locally administered", and UuidCreateSequential would return RPC_S_UUID_LOCAL_ONLY

When i run UuidCreateSequential on Windows 7, it runs fine:

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

But if i run it on a Windows XP machine with the same (or similar) MAC address:

enter image description here

The function fails:

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

Fix

This bug of checking the wrong bit of the MAC address was documented in:

It was also documented in UuidCreateSequential, along with:

There was an associated hotfix, but i don't believe it was fixed beyond that (i.e. no formal fix in a service pack).

You have three choices:

  • change your MAC address in your Windows XP settings to not have the high-bit set
  • upgrade to Windows Vista or newer
  • if the function returns RPC_S_UUID_LOCAL_ONLY, and you are before Windows Vista (dwMajor < 6), then assume it actually succeeded (Dangerous!)
多像笑话 2024-09-17 11:46:12

也许这是一个安全问题,拨打电话的用户是管理员吗?如果不是,NIC 驱动程序可能无法提供 MAC 地址。

只要 UUID 用于该机器本地的内容,那么接受此错误作为有效结果就可以了。

如果必须保证 UUID 全局唯一(例如资产注册),那么询问另一个框(例如注册服务器)可能是一个更好的主意。

Perhaps its a security issue, is the user making the call an Administrator? If not, the NIC driver may be failing to supply the MAC address.

As long as the UUID is used for something local to that machine, then accepting this error as a valid result may be OK.

If the UUID must be guaranteed globally unique (e.g. asset registration) then asking another box (e.g. the registration server) might be a better idea.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文