From 16b5e6b9b5992781e788d7da3afded0e182005ef Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 2 Dec 2008 20:52:09 +0100 Subject: [PATCH] ole32: Register interfaces through dlldata.c as far as possible. --- dlls/ole32/Makefile.in | 2 +- dlls/ole32/compobj.c | 11 ++++----- dlls/ole32/compobj_private.h | 6 +++-- dlls/ole32/ole2.c | 8 +++---- dlls/ole32/regsvr.c | 45 ++++++++---------------------------- 5 files changed, 22 insertions(+), 50 deletions(-) diff --git a/dlls/ole32/Makefile.in b/dlls/ole32/Makefile.in index a38c965fe2f..f8d74818234 100644 --- a/dlls/ole32/Makefile.in +++ b/dlls/ole32/Makefile.in @@ -6,7 +6,7 @@ MODULE = ole32.dll IMPORTLIB = ole32 IMPORTS = uuid advapi32 user32 gdi32 rpcrt4 kernel32 ntdll EXTRADEFS = -D_OLE32_ -DCOM_NO_WINDOWS_H \ - -DENTRY_PREFIX=OLE32_ -DPROXY_CLSID=CLSID_PSFactoryBuffer + -DENTRY_PREFIX=OLE32_ -DPROXY_CLSID=CLSID_PSFactoryBuffer -DREGISTER_PROXY_DLL C_SRCS = \ antimoniker.c \ diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index a920b9c09c5..d77847853f5 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -63,8 +63,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); -HINSTANCE OLE32_hInstance = 0; - #define ARRAYSIZE(array) (sizeof(array)/sizeof((array)[0])) /**************************************************************************** @@ -209,14 +207,14 @@ static void COMPOBJ_InitProcess( void ) */ memset(&wclass, 0, sizeof(wclass)); wclass.lpfnWndProc = apartment_wndproc; - wclass.hInstance = OLE32_hInstance; + wclass.hInstance = hProxyDll; wclass.lpszClassName = wszAptWinClass; RegisterClassW(&wclass); } static void COMPOBJ_UninitProcess( void ) { - UnregisterClassW(wszAptWinClass, OLE32_hInstance); + UnregisterClassW(wszAptWinClass, hProxyDll); } static void COM_TlsDestroy(void) @@ -729,7 +727,7 @@ HRESULT apartment_createwindowifneeded(struct apartment *apt) { HWND hwnd = CreateWindowW(wszAptWinClass, NULL, 0, 0, 0, 0, 0, - HWND_MESSAGE, 0, OLE32_hInstance, NULL); + HWND_MESSAGE, 0, hProxyDll, NULL); if (!hwnd) { ERR("CreateWindow failed with error %d\n", GetLastError()); @@ -3861,7 +3859,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) switch(fdwReason) { case DLL_PROCESS_ATTACH: - OLE32_hInstance = hinstDLL; + hProxyDll = hinstDLL; COMPOBJ_InitProcess(); if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1); break; @@ -3872,7 +3870,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) COMPOBJ_UninitProcess(); RPC_UnregisterAllChannelHooks(); COMPOBJ_DllList_Free(); - OLE32_hInstance = 0; break; case DLL_THREAD_DETACH: diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h index 150c7c7f7f8..869cd845b2b 100644 --- a/dlls/ole32/compobj_private.h +++ b/dlls/ole32/compobj_private.h @@ -303,14 +303,16 @@ static inline GUID COM_CurrentCausalityId(void) # define DEBUG_SET_CRITSEC_NAME(cs, name) (cs)->DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": " name) # define DEBUG_CLEAR_CRITSEC_NAME(cs) (cs)->DebugInfo->Spare[0] = 0 -extern HINSTANCE OLE32_hInstance; /* FIXME: make static */ - #define CHARS_IN_GUID 39 /* including NULL */ #define WINE_CLSCTX_DONT_HOST 0x80000000 /* from dlldata.c */ +extern HINSTANCE hProxyDll DECLSPEC_HIDDEN; +extern BOOL WINAPI OLE32_DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) DECLSPEC_HIDDEN; extern HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv) DECLSPEC_HIDDEN; +extern HRESULT WINAPI OLE32_DllRegisterServer(void) DECLSPEC_HIDDEN; +extern HRESULT WINAPI OLE32_DllUnregisterServer(void) DECLSPEC_HIDDEN; /* Exported non-interface Data Advise Holder functions */ HRESULT DataAdviseHolder_OnConnect(IDataAdviseHolder *iface, IDataObject *pDelegate); diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c index 4be2eb8e3ca..a2ff9b791ba 100644 --- a/dlls/ole32/ole2.c +++ b/dlls/ole32/ole2.c @@ -2119,19 +2119,19 @@ static void OLEDD_TrackMouseMove(TrackerWindowInfo* trackerInfo) { if (*trackerInfo->pdwEffect & DROPEFFECT_MOVE) { - SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(1))); + SetCursor(LoadCursorA(hProxyDll, MAKEINTRESOURCEA(1))); } else if (*trackerInfo->pdwEffect & DROPEFFECT_COPY) { - SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(2))); + SetCursor(LoadCursorA(hProxyDll, MAKEINTRESOURCEA(2))); } else if (*trackerInfo->pdwEffect & DROPEFFECT_LINK) { - SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(3))); + SetCursor(LoadCursorA(hProxyDll, MAKEINTRESOURCEA(3))); } else { - SetCursor(LoadCursorA(OLE32_hInstance, MAKEINTRESOURCEA(0))); + SetCursor(LoadCursorA(hProxyDll, MAKEINTRESOURCEA(0))); } } } diff --git a/dlls/ole32/regsvr.c b/dlls/ole32/regsvr.c index 07ddde01661..2abd63671dc 100644 --- a/dlls/ole32/regsvr.c +++ b/dlls/ole32/regsvr.c @@ -509,69 +509,38 @@ static struct regsvr_coclass const coclass_list[] = { * interface list */ -#define INTERFACE_ENTRY(interface, base, clsid32, clsid16) { &IID_##interface, #interface, base, sizeof(interface##Vtbl)/sizeof(void*), clsid16, clsid32 } -#define BAS_INTERFACE_ENTRY(interface, base) INTERFACE_ENTRY(interface, &IID_##base, &CLSID_PSFactoryBuffer, NULL) -#define STD_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, &CLSID_PSFactoryBuffer, NULL) -#define ACTX_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, &CLSID_PSFactoryBuffer_actxprxy, NULL) -#define LCL_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, NULL, NULL) +#define INTERFACE_ENTRY(interface, base, clsid32) { &IID_##interface, #interface, base, sizeof(interface##Vtbl)/sizeof(void*), NULL, clsid32 } +#define BAS_INTERFACE_ENTRY(interface, base) INTERFACE_ENTRY(interface, &IID_##base, NULL) +#define ACTX_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, &CLSID_PSFactoryBuffer_actxprxy) +#define LCL_INTERFACE_ENTRY(interface) INTERFACE_ENTRY(interface, NULL, NULL) static const struct regsvr_interface interface_list[] = { LCL_INTERFACE_ENTRY(IUnknown), - STD_INTERFACE_ENTRY(IClassFactory), LCL_INTERFACE_ENTRY(IMalloc), LCL_INTERFACE_ENTRY(IMarshal), - STD_INTERFACE_ENTRY(ILockBytes), - STD_INTERFACE_ENTRY(IStorage), - STD_INTERFACE_ENTRY(IStream), - STD_INTERFACE_ENTRY(IEnumSTATSTG), - STD_INTERFACE_ENTRY(IBindCtx), BAS_INTERFACE_ENTRY(IMoniker, IPersistStream), - STD_INTERFACE_ENTRY(IRunningObjectTable), - STD_INTERFACE_ENTRY(IRootStorage), LCL_INTERFACE_ENTRY(IMessageFilter), LCL_INTERFACE_ENTRY(IStdMarshalInfo), LCL_INTERFACE_ENTRY(IExternalConnection), LCL_INTERFACE_ENTRY(IMallocSpy), LCL_INTERFACE_ENTRY(IMultiQI), - STD_INTERFACE_ENTRY(IEnumUnknown), - STD_INTERFACE_ENTRY(IEnumString), - STD_INTERFACE_ENTRY(IEnumMoniker), - STD_INTERFACE_ENTRY(IEnumFORMATETC), - STD_INTERFACE_ENTRY(IEnumOLEVERB), - STD_INTERFACE_ENTRY(IEnumSTATDATA), BAS_INTERFACE_ENTRY(IPersistStream, IPersist), BAS_INTERFACE_ENTRY(IPersistStorage, IPersist), BAS_INTERFACE_ENTRY(IPersistFile, IPersist), - STD_INTERFACE_ENTRY(IPersist), - STD_INTERFACE_ENTRY(IViewObject), - STD_INTERFACE_ENTRY(IDataObject), - STD_INTERFACE_ENTRY(IAdviseSink), LCL_INTERFACE_ENTRY(IDataAdviseHolder), LCL_INTERFACE_ENTRY(IOleAdviseHolder), - STD_INTERFACE_ENTRY(IOleObject), BAS_INTERFACE_ENTRY(IOleInPlaceObject, IOleWindow), - STD_INTERFACE_ENTRY(IOleWindow), BAS_INTERFACE_ENTRY(IOleInPlaceUIWindow, IOleWindow), - STD_INTERFACE_ENTRY(IOleInPlaceFrame), BAS_INTERFACE_ENTRY(IOleInPlaceActiveObject, IOleWindow), - STD_INTERFACE_ENTRY(IOleClientSite), BAS_INTERFACE_ENTRY(IOleInPlaceSite, IOleWindow), - STD_INTERFACE_ENTRY(IParseDisplayName), BAS_INTERFACE_ENTRY(IOleContainer, IParseDisplayName), BAS_INTERFACE_ENTRY(IOleItemContainer, IOleContainer), - STD_INTERFACE_ENTRY(IOleLink), - STD_INTERFACE_ENTRY(IOleCache), LCL_INTERFACE_ENTRY(IDropSource), - STD_INTERFACE_ENTRY(IDropTarget), BAS_INTERFACE_ENTRY(IAdviseSink2, IAdviseSink), - STD_INTERFACE_ENTRY(IRunnableObject), BAS_INTERFACE_ENTRY(IViewObject2, IViewObject), BAS_INTERFACE_ENTRY(IOleCache2, IOleCache), - STD_INTERFACE_ENTRY(IOleCacheControl), - STD_INTERFACE_ENTRY(IRemUnknown), LCL_INTERFACE_ENTRY(IClientSecurity), LCL_INTERFACE_ENTRY(IServerSecurity), - STD_INTERFACE_ENTRY(ISequentialStream), ACTX_INTERFACE_ENTRY(IEnumGUID), ACTX_INTERFACE_ENTRY(IEnumCATEGORYINFO), ACTX_INTERFACE_ENTRY(ICatRegister), @@ -588,7 +557,9 @@ HRESULT WINAPI DllRegisterServer(void) TRACE("\n"); - hr = register_coclasses(coclass_list); + hr = OLE32_DllRegisterServer(); + if (SUCCEEDED(hr)) + hr = register_coclasses(coclass_list); if (SUCCEEDED(hr)) hr = register_interfaces(interface_list); return hr; @@ -606,5 +577,7 @@ HRESULT WINAPI DllUnregisterServer(void) hr = unregister_coclasses(coclass_list); if (SUCCEEDED(hr)) hr = unregister_interfaces(interface_list); + if (SUCCEEDED(hr)) + hr = OLE32_DllUnregisterServer(); return hr; }