This patch fixes two problems with current UUID support, and adds a new function from Windows 2000. 1) UuidCreate() determines the machine's ethernet hardware (MAC) address, and saves it in an array. It then sets a static local variable stating that the address has been found. However, since the array wasn't also declared static, it contained garbage on all subsequent calls. Thus, the final part of the UUID (which some programs use to get HW ID) was changing every call while it should be constant. That array's now static. 2) UuidToStringA() was adding {}'s around the UUID. That does not match its behaviour on Windows, and confuses programs which try to parse it. The braces have been removed. 3) Windows 2000 added a new function called UuidCreateSequential(), which behaves exactly like UuidCreate() on earlier OS's. This is because on Windows 2000 (and later?), UuidCreate() is no longer supposed to use the MAC address. Since ours does, UuidCreateSequential() just calls UuidCreate(). //Mark ChangeLog: * dlls/rpcrt4/rpcrt4.spec, dlls/rpcrt4/rpcrt4_main.c: Mark G. Adams <mgadams@sympatico.ca> Fix UuidCreate() to not forget MAC address. Remove {}'s from UuidToStringA() output. Add UuidCreateSequential() function from Windows 2000.
Index: rpcrt4.spec =================================================================== RCS file: /home/wine/wine/dlls/rpcrt4/rpcrt4.spec,v retrieving revision 1.9 diff -u -u -r1.9 rpcrt4.spec --- rpcrt4.spec 2001/09/17 20:26:38 1.9 +++ rpcrt4.spec 2002/01/05 19:17:53 @@ -179,6 +179,7 @@ @ stub UuidCompare @ stdcall UuidCreate(ptr) UuidCreate +@ stdcall UuidCreateSequential(ptr) UuidCreateSequential # win 2000 @ stub UuidCreateNil @ stub UuidEqual @ stub UuidFromStringA Index: rpcrt4_main.c =================================================================== RCS file: /home/wine/wine/dlls/rpcrt4/rpcrt4_main.c,v retrieving revision 1.17 diff -u -u -r1.17 rpcrt4_main.c --- rpcrt4_main.c 2001/09/07 15:25:51 1.17 +++ rpcrt4_main.c 2002/01/05 19:17:54 @@ -81,7 +81,7 @@ RPC_STATUS WINAPI UuidCreate(UUID *Uuid) { static char has_init = 0; - unsigned char a[6]; + static unsigned char a[6]; static int adjustment = 0; static struct timeval last = {0, 0}; static UINT16 clock_seq; @@ -96,7 +96,7 @@ char buf[1024]; int n, i; #endif - + /* Have we already tried to get the MAC address? */ if (!has_init) { #ifdef HAVE_NET_IF_H @@ -264,6 +264,20 @@ return RPC_S_OK; } + +/************************************************************************* + * UuidCreateSequential [RPCRT4.@] + * + * Creates a 128bit UUID by calling UuidCreate. + * New API in Win 2000 + */ + +RPC_STATUS WINAPI UuidCreateSequential(UUID *Uuid) +{ + return UuidCreate (Uuid); +} + + /************************************************************************* * RpcStringFreeA [RPCRT4.@] * @@ -314,7 +328,7 @@ if(!(*StringUuid)) return RPC_S_OUT_OF_MEMORY; - sprintf(*StringUuid, "{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", + sprintf(*StringUuid, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", Uuid->Data1, Uuid->Data2, Uuid->Data3, Uuid->Data4[0], Uuid->Data4[1], Uuid->Data4[2], Uuid->Data4[3], Uuid->Data4[4], Uuid->Data4[5],