Move the Dll init function to compobj.c to avoid having global variables. Remove need of ole32_main.h.
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 6152039..0120122 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c
@@ -66,7 +66,6 @@ #include "wownt32.h" #include "wine/unicode.h" #include "objbase.h" -#include "ole32_main.h" #include "compobj_private.h" #include "wine/debug.h" @@ -75,6 +74,8 @@ typedef LPCSTR LPCOLESTR16; +HINSTANCE OLE32_hInstance = 0; /* FIXME: make static ... */ + /**************************************************************************** * This section defines variables internal to the COM module. * @@ -169,7 +170,7 @@ static void COMPOBJ_DLLList_Add(HANDLE hLibrary); static void COMPOBJ_DllList_FreeUnused(int Timeout); -void COMPOBJ_InitProcess( void ) +static void COMPOBJ_InitProcess( void ) { WNDCLASSW wclass; @@ -189,12 +190,12 @@ RegisterClassW(&wclass); } -void COMPOBJ_UninitProcess( void ) +static void COMPOBJ_UninitProcess( void ) { UnregisterClassW(wszAptWinClass, OLE32_hInstance); } -void COM_TlsDestroy() +static void COM_TlsDestroy() { struct oletls *info = NtCurrentTeb()->ReservedForOle; if (info) @@ -624,7 +625,7 @@ /* On COM finalization for a STA thread, the message queue is flushed to ensure no pending RPCs are ignored. Non-COM messages are discarded at this point. */ -void COM_FlushMessageQueue(void) +static void COM_FlushMessageQueue(void) { MSG message; APARTMENT *apt = COM_CurrentApt(); @@ -1531,7 +1532,8 @@ * * Reads a registry value and expands it when necessary */ -HRESULT compobj_RegReadPath(char * keyname, char * valuename, char * dst, DWORD dstlen) +static HRESULT +compobj_RegReadPath(char * keyname, char * valuename, char * dst, DWORD dstlen) { HRESULT hres; HKEY key; @@ -2654,3 +2656,32 @@ TRACE("-- 0x%08lx\n", hr); return hr; } + +/*********************************************************************** + * DllMain (OLE32.@) + */ +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) +{ + TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad); + + switch(fdwReason) { + case DLL_PROCESS_ATTACH: + OLE32_hInstance = hinstDLL; + COMPOBJ_InitProcess(); + if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1); + break; + + case DLL_PROCESS_DETACH: + if (TRACE_ON(ole)) CoRevokeMallocSpy(); + COMPOBJ_UninitProcess(); + OLE32_hInstance = 0; + break; + + case DLL_THREAD_DETACH: + COM_TlsDestroy(); + break; + } + return TRUE; +} + +/* NOTE: DllRegisterServer and DllUnregisterServer are in regsvr.c */
diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h index 5e3df82..7e5ddbb 100644 --- a/dlls/ole32/compobj_private.h +++ b/dlls/ole32/compobj_private.h
@@ -254,4 +254,6 @@ # define DEBUG_CLEAR_CRITSEC_NAME(cs) #endif +extern HINSTANCE OLE32_hInstance; /* FIXME: make static */ + #endif /* __WINE_OLE_COMPOBJ_H */
diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c index 7f497e1..ed569bb 100644 --- a/dlls/ole32/ole2.c +++ b/dlls/ole32/ole2.c
@@ -48,7 +48,6 @@ #include "wine/winbase16.h" #include "wine/wingdi16.h" #include "wine/winuser16.h" -#include "ole32_main.h" #include "compobj_private.h" #include "wine/debug.h"
diff --git a/dlls/ole32/ole2_16.c b/dlls/ole32/ole2_16.c index 908d133..a61fb60 100644 --- a/dlls/ole32/ole2_16.c +++ b/dlls/ole32/ole2_16.c
@@ -45,7 +45,6 @@ #include "wine/winbase16.h" #include "wine/wingdi16.h" #include "wine/winuser16.h" -#include "ole32_main.h" #include "ifs.h" #include "wine/debug.h"
diff --git a/dlls/ole32/ole32_main.c b/dlls/ole32/ole32_main.c index 017a716..4a13382 100644 --- a/dlls/ole32/ole32_main.c +++ b/dlls/ole32/ole32_main.c
@@ -27,13 +27,11 @@ #include "wingdi.h" #include "winuser.h" #include "winnls.h" -#include "ole32_main.h" +#include "objbase.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(ole); -HINSTANCE OLE32_hInstance = 0; - /*********************************************************************** * OleMetafilePictFromIconAndLabel (OLE32.@) */ @@ -110,33 +108,3 @@ return hmem; } - - -/*********************************************************************** - * DllMain (OLE32.@) - */ -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad) -{ - TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad); - - switch(fdwReason) { - case DLL_PROCESS_ATTACH: - OLE32_hInstance = hinstDLL; - COMPOBJ_InitProcess(); - if (TRACE_ON(ole)) CoRegisterMallocSpy((LPVOID)-1); - break; - - case DLL_PROCESS_DETACH: - if (TRACE_ON(ole)) CoRevokeMallocSpy(); - COMPOBJ_UninitProcess(); - OLE32_hInstance = 0; - break; - - case DLL_THREAD_DETACH: - COM_TlsDestroy(); - break; - } - return TRUE; -} - -/* NOTE: DllRegisterServer and DllUnregisterServer are in regsvr.c */
diff --git a/dlls/ole32/ole32_main.h b/dlls/ole32/ole32_main.h deleted file mode 100644 index 0471974..0000000 --- a/dlls/ole32/ole32_main.h +++ /dev/null
@@ -1,34 +0,0 @@ -/* - * Copyright 2000 Huw D M Davies for CodeWeavers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __WINE_OLE32_MAIN_H -#define __WINE_OLE32_MAIN_H - -#include <stdarg.h> - -#include "windef.h" -#include "winbase.h" -#include "objbase.h" - -extern HINSTANCE OLE32_hInstance; - -void COMPOBJ_InitProcess( void ); -void COMPOBJ_UninitProcess( void ); -void COM_TlsDestroy( void ); - -#endif /* __WINE_OLE32_MAIN_H */