Alexandre Julliard : advapi32: Make rpcrt4 a delayed import to work around circular dependencies with native .

Alexandre Julliard julliard at winehq.org
Mon Jun 21 11:07:11 CDT 2010


Module: wine
Branch: master
Commit: 58a698882d7f048e642bfccba65edcac98bd3a40
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=58a698882d7f048e642bfccba65edcac98bd3a40

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Jun 21 16:56:12 2010 +0200

advapi32: Make rpcrt4 a delayed import to work around circular dependencies with native.

---

 dlls/advapi32/Makefile.in |    3 +-
 dlls/advapi32/crypt.c     |   56 ++++++++++++++++++--------------------------
 2 files changed, 25 insertions(+), 34 deletions(-)

diff --git a/dlls/advapi32/Makefile.in b/dlls/advapi32/Makefile.in
index a3d0efc..d880360 100644
--- a/dlls/advapi32/Makefile.in
+++ b/dlls/advapi32/Makefile.in
@@ -5,7 +5,8 @@ SRCDIR    = @srcdir@
 VPATH     = @srcdir@
 MODULE    = advapi32.dll
 IMPORTLIB = advapi32
-IMPORTS   = rpcrt4 kernel32 ntdll
+IMPORTS   = kernel32 ntdll
+DELAYIMPORTS = rpcrt4
 EXTRALIBS = @SECURITYLIB@
 
 C_SRCS = \
diff --git a/dlls/advapi32/crypt.c b/dlls/advapi32/crypt.c
index bb019d0..4235e83 100644
--- a/dlls/advapi32/crypt.c
+++ b/dlls/advapi32/crypt.c
@@ -284,40 +284,30 @@ static void CRYPT_CreateMachineGuid(void)
 		r = RegQueryValueExW(key, machineGuidW, NULL, NULL, NULL, &size);
 		if (r == ERROR_FILE_NOT_FOUND)
 		{
-			static const WCHAR rpcrt4[] = {
-				'r','p','c','r','t','4',0 };
-			HMODULE lib = LoadLibraryW(rpcrt4);
-
-			if (lib)
-			{
-				RPC_STATUS (RPC_ENTRY *pUuidCreate)(UUID *);
-				UUID uuid;
-                                WCHAR buf[37];
-                                RPC_STATUS rs;
-                                static const WCHAR uuidFmt[] = {
-                                    '%','0','8','x','-','%','0','4','x','-',
-                                    '%','0','4','x','-','%','0','2','x',
-                                    '%','0','2','x','-','%','0','2','x',
-                                    '%','0','2','x','%','0','2','x',
-                                    '%','0','2','x','%','0','2','x',
-                                    '%','0','2','x',0 };
-
-                                pUuidCreate = (void *)GetProcAddress(lib, "UuidCreate");
-                                rs = pUuidCreate(&uuid);
-                                if (rs == S_OK)
-                                {
-                                    sprintfW(buf, uuidFmt,
-                                             uuid.Data1, uuid.Data2, uuid.Data3,
-                                             uuid.Data4[0], uuid.Data4[1],
-                                             uuid.Data4[2], uuid.Data4[3],
-                                             uuid.Data4[4], uuid.Data4[5],
-                                             uuid.Data4[6], uuid.Data4[7] );
-                                    RegSetValueExW(key, machineGuidW, 0, REG_SZ,
-                                                   (const BYTE *)buf,
-                                                   (lstrlenW(buf)+1)*sizeof(WCHAR));
-                                }
-				FreeLibrary(lib);
-			}
+                    UUID uuid;
+                    WCHAR buf[37];
+                    RPC_STATUS rs;
+                    static const WCHAR uuidFmt[] = {
+                        '%','0','8','x','-','%','0','4','x','-',
+                        '%','0','4','x','-','%','0','2','x',
+                        '%','0','2','x','-','%','0','2','x',
+                        '%','0','2','x','%','0','2','x',
+                        '%','0','2','x','%','0','2','x',
+                        '%','0','2','x',0 };
+
+                    rs = UuidCreate(&uuid);
+                    if (rs == S_OK)
+                    {
+                        sprintfW(buf, uuidFmt,
+                                 uuid.Data1, uuid.Data2, uuid.Data3,
+                                 uuid.Data4[0], uuid.Data4[1],
+                                 uuid.Data4[2], uuid.Data4[3],
+                                 uuid.Data4[4], uuid.Data4[5],
+                                 uuid.Data4[6], uuid.Data4[7] );
+                        RegSetValueExW(key, machineGuidW, 0, REG_SZ,
+                                       (const BYTE *)buf,
+                                       (lstrlenW(buf)+1)*sizeof(WCHAR));
+                    }
 		}
 		RegCloseKey(key);
 	}




More information about the wine-cvs mailing list