UuidCreateSequential 的奇怪行为
我有一个软件可以在我公司的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我联系了微软,似乎这个错误只发生在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.
这是 Windows XP 和 Windows Server 2003 中的一个错误。MAC
地址为 48 位,通常表示为:
前三个字节表示组织,其余三个字节是组织想要的任何编号方案使用。组织 ID 由 IEEE 颁发。
对于所有公共 MAC 地址,第一个字节的第二个最低位(第二个最低有效位)将为零。如果您想生成自己的本地 MAC 地址,您可以将该位设置为 1:
或者从 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:
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:
Or the image lifted from Wikipedia:
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????:
Emphasis mine. The correction would be to say that:
Testing
I tested this on my computer. My computer has a MAC address of:
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:But if i run it on a Windows XP machine with the same (or similar) MAC address:
The function fails:
Fix
This bug of checking the wrong bit of the MAC address was documented in:
KB2569646: UuidCreateSequential API may return RPC_S_UUID_LOCAL_ONLY(1824) Error. (June 22, 2011)
It was also documented in
UuidCreateSequential
, along with:KB981080: You receive a warning when you use the UUIDGEN.exe command or the UuidCreateSequential function on a computer that has a valid network adapter address6????:
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:
dwMajor < 6
), then assume it actually succeeded (Dangerous!)也许这是一个安全问题,拨打电话的用户是管理员吗?如果不是,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.