Commit 1331a8ea authored by Alexandre Julliard's avatar Alexandre Julliard

winecrt0: Determine the registration module handle directly in __wine_register_resources().

parent 5d82baf9
......@@ -26,23 +26,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
DECLSPEC_HIDDEN LONG dll_refs;
static HINSTANCE devenum_instance;
/***********************************************************************
* DllEntryPoint
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
{
TRACE("%p 0x%x %p\n", hinstDLL, fdwReason, fImpLoad);
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
devenum_instance = hinstDLL;
DisableThreadLibraryCalls(hinstDLL);
break;
}
return TRUE;
}
struct class_factory
{
......@@ -154,7 +137,7 @@ HRESULT WINAPI DllRegisterServer(void)
TRACE("\n");
res = __wine_register_resources( devenum_instance );
res = __wine_register_resources();
if (FAILED(res))
return res;
......@@ -186,5 +169,5 @@ HRESULT WINAPI DllRegisterServer(void)
HRESULT WINAPI DllUnregisterServer(void)
{
FIXME("stub!\n");
return __wine_unregister_resources( devenum_instance );
return __wine_unregister_resources();
}
......@@ -48,7 +48,6 @@ static HRESULT MultiLanguage_create(IUnknown *pUnkOuter, LPVOID *ppObj);
static HRESULT MLangConvertCharset_create(IUnknown *outer, void **obj);
static HRESULT EnumRfc1766_create(LANGID LangId, IEnumRfc1766 **ppEnum);
static HINSTANCE instance;
static DWORD MLANG_tls_index; /* to store various per thead data */
/* FIXME:
......@@ -935,7 +934,6 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
instance = hInstDLL;
MLANG_tls_index = TlsAlloc();
DisableThreadLibraryCalls(hInstDLL);
break;
......@@ -3976,7 +3974,7 @@ HRESULT WINAPI DllRegisterServer(void)
{
if(!register_codepages())
return E_FAIL;
return __wine_register_resources( instance );
return __wine_register_resources();
}
/***********************************************************************
......@@ -3984,7 +3982,7 @@ HRESULT WINAPI DllRegisterServer(void)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
return __wine_unregister_resources( instance );
return __wine_unregister_resources();
}
HRESULT WINAPI GetGlobalFontLinkObject(void **unknown)
......
......@@ -41,8 +41,6 @@ DEFINE_GUID(WMFORMAT_WaveFormatEx, 0x05589f81,0xc356,0x11ce,0xbf,0x01,0x00,0xaa
WINE_DEFAULT_DEBUG_CHANNEL(mp3dmod);
static HINSTANCE mp3dmod_instance;
struct mp3_decoder
{
IUnknown IUnknown_inner;
......@@ -651,19 +649,6 @@ static const IClassFactoryVtbl classfactory_vtbl = {
static IClassFactory mp3_decoder_cf = { &classfactory_vtbl };
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
TRACE("%p, %d, %p\n", instance, reason, reserved);
switch (reason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(instance);
mp3dmod_instance = instance;
break;
}
return TRUE;
}
/*************************************************************************
* DllGetClassObject (DSDMO.@)
*/
......@@ -695,7 +680,7 @@ HRESULT WINAPI DllRegisterServer(void)
0, 1, &in, 1, &out);
if (FAILED(hr)) return hr;
return __wine_register_resources( mp3dmod_instance );
return __wine_register_resources();
}
/***********************************************************************
......@@ -708,5 +693,5 @@ HRESULT WINAPI DllUnregisterServer(void)
hr = DMOUnregister(&CLSID_CMP3DecMediaObject, &DMOCATEGORY_AUDIO_DECODER);
if (FAILED(hr)) return hr;
return __wine_unregister_resources( mp3dmod_instance );
return __wine_unregister_resources();
}
......@@ -50,8 +50,6 @@
WINE_DEFAULT_DEBUG_CHANNEL( mscoree );
WINE_DECLARE_DEBUG_CHANNEL(winediag);
static HINSTANCE MSCOREE_hInstance;
typedef HRESULT (*fnCreateInstance)(REFIID riid, LPVOID *ppObj);
char *WtoA(LPCWSTR wstr)
......@@ -220,8 +218,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
MSCOREE_hInstance = hinstDLL;
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
......@@ -883,12 +879,12 @@ HRESULT WINAPI DllRegisterServer(void)
{
install_wine_mono();
return __wine_register_resources( MSCOREE_hInstance );
return __wine_register_resources();
}
HRESULT WINAPI DllUnregisterServer(void)
{
return __wine_unregister_resources( MSCOREE_hInstance );
return __wine_unregister_resources();
}
void WINAPI CoEEShutDownCOM(void)
......
......@@ -662,7 +662,7 @@ HRESULT WINAPI DllRegisterServer(void)
{
HRESULT hres;
hres = __wine_register_resources( hInst );
hres = __wine_register_resources();
if(SUCCEEDED(hres))
hres = register_server(TRUE);
return hres;
......@@ -673,7 +673,7 @@ HRESULT WINAPI DllRegisterServer(void)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
HRESULT hres = __wine_unregister_resources( hInst );
HRESULT hres = __wine_unregister_resources();
if(SUCCEEDED(hres)) hres = register_server(FALSE);
return hres;
}
......
......@@ -234,7 +234,7 @@ HRESULT WINAPI DllRegisterServer(void)
IFilterMapper2 *mapper;
HRESULT hr;
if (FAILED(hr = __wine_register_resources( qcap_instance )))
if (FAILED(hr = __wine_register_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
......@@ -260,7 +260,7 @@ HRESULT WINAPI DllUnregisterServer(void)
IFilterMapper2 *mapper;
HRESULT hr;
if (FAILED(hr = __wine_unregister_resources( qcap_instance )))
if (FAILED(hr = __wine_unregister_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
......
......@@ -25,13 +25,10 @@
WINE_DEFAULT_DEBUG_CHANNEL(qedit);
static HINSTANCE qedit_instance;
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
qedit_instance = instance;
DisableThreadLibraryCalls(instance);
}
else if (reason == DLL_PROCESS_DETACH && !reserved)
......@@ -240,7 +237,7 @@ HRESULT WINAPI DllRegisterServer(void)
IFilterMapper2 *mapper;
HRESULT hr;
if (FAILED(hr = __wine_register_resources(qedit_instance)))
if (FAILED(hr = __wine_register_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
......@@ -264,7 +261,7 @@ HRESULT WINAPI DllUnregisterServer(void)
IFilterMapper2 *mapper;
HRESULT hr;
if (FAILED(hr = __wine_unregister_resources(qedit_instance)))
if (FAILED(hr = __wine_unregister_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
......
......@@ -1174,7 +1174,7 @@ HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
*/
HRESULT WINAPI DllRegisterServer(void)
{
HRESULT hr = __wine_register_resources( shell32_hInstance );
HRESULT hr = __wine_register_resources();
if (SUCCEEDED(hr)) hr = SHELL_RegisterShellFolders();
return hr;
}
......@@ -1184,7 +1184,7 @@ HRESULT WINAPI DllRegisterServer(void)
*/
HRESULT WINAPI DllUnregisterServer(void)
{
return __wine_unregister_resources( shell32_hInstance );
return __wine_unregister_resources();
}
/***********************************************************************
......
......@@ -25,23 +25,12 @@
#include "olectl.h"
#include "rpcproxy.h"
static inline void *image_base(void)
{
#if defined(__MINGW32__) || defined(_MSC_VER)
extern IMAGE_DOS_HEADER __ImageBase;
return (void *)&__ImageBase;
#else
extern IMAGE_NT_HEADERS __wine_spec_nt_header;
return (void *)((__wine_spec_nt_header.OptionalHeader.ImageBase + 0xffff) & ~0xffff);
#endif
}
HRESULT WINAPI DllRegisterServer(void)
{
return __wine_register_resources( image_base() );
return __wine_register_resources();
}
HRESULT WINAPI DllUnregisterServer(void)
{
return __wine_unregister_resources( image_base() );
return __wine_unregister_resources();
}
......@@ -29,6 +29,17 @@
#include "rpcproxy.h"
#include "atliface.h"
static inline void *image_base(void)
{
#if defined(__MINGW32__) || defined(_MSC_VER)
extern IMAGE_DOS_HEADER __ImageBase;
return (void *)&__ImageBase;
#else
extern IMAGE_NT_HEADERS __wine_spec_nt_header;
return (void *)((__wine_spec_nt_header.OptionalHeader.ImageBase + 0xffff) & ~0xffff);
#endif
}
static const WCHAR atl100W[] = {'a','t','l','1','0','0','.','d','l','l',0};
static const WCHAR regtypeW[] = {'W','I','N','E','_','R','E','G','I','S','T','R','Y',0};
static const WCHAR moduleW[] = {'M','O','D','U','L','E',0};
......@@ -97,26 +108,26 @@ static BOOL CALLBACK register_resource( HMODULE module, LPCWSTR type, LPWSTR nam
return SUCCEEDED(info->result);
}
HRESULT __cdecl __wine_register_resources( HMODULE module )
HRESULT __cdecl __wine_register_resources(void)
{
struct reg_info info;
info.registrar = NULL;
info.do_register = TRUE;
info.result = S_OK;
EnumResourceNamesW( module, regtypeW, register_resource, (LONG_PTR)&info );
EnumResourceNamesW( image_base(), regtypeW, register_resource, (LONG_PTR)&info );
if (info.registrar) IRegistrar_Release( info.registrar );
return info.result;
}
HRESULT __cdecl __wine_unregister_resources( HMODULE module )
HRESULT __cdecl __wine_unregister_resources(void)
{
struct reg_info info;
info.registrar = NULL;
info.do_register = FALSE;
info.result = S_OK;
EnumResourceNamesW( module, regtypeW, register_resource, (LONG_PTR)&info );
EnumResourceNamesW( image_base(), regtypeW, register_resource, (LONG_PTR)&info );
if (info.registrar) IRegistrar_Release( info.registrar );
return info.result;
}
......@@ -27,7 +27,6 @@
#include "initguid.h"
#include "gst_guids.h"
static HINSTANCE winegstreamer_instance;
LONG object_locks;
WINE_DEFAULT_DEBUG_CHANNEL(gstreamer);
......@@ -38,7 +37,6 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
winegstreamer_instance = instance;
DisableThreadLibraryCalls(instance);
__wine_init_unix_lib(instance, reason, NULL, &unix_funcs);
}
......@@ -171,9 +169,9 @@ static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ct
/* Unloading glib is a bad idea.. it installs atexit handlers,
* so never unload the dll after loading */
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN,
(LPCWSTR)winegstreamer_instance, &handle);
(LPCWSTR)init_gstreamer_proc, &handle);
if (!handle)
ERR("Failed to pin module %p.\n", winegstreamer_instance);
ERR("Failed to pin module.\n");
return TRUE;
}
......@@ -321,7 +319,7 @@ HRESULT WINAPI DllRegisterServer(void)
TRACE(".\n");
if (FAILED(hr = __wine_register_resources(winegstreamer_instance)))
if (FAILED(hr = __wine_register_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
......@@ -347,7 +345,7 @@ HRESULT WINAPI DllUnregisterServer(void)
TRACE(".\n");
if (FAILED(hr = __wine_unregister_resources(winegstreamer_instance)))
if (FAILED(hr = __wine_unregister_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
......
......@@ -57,18 +57,6 @@ static const WCHAR wQTVName[] =
static const WCHAR wQTDName[] =
{'Q','T',' ','V','i','d','e','o',' ','D','e','m','u','x',0};
static HINSTANCE wineqtdecoder_instance;
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
wineqtdecoder_instance = instance;
DisableThreadLibraryCalls(instance);
}
return TRUE;
}
struct class_factory
{
IClassFactory IClassFactory_iface;
......@@ -221,7 +209,7 @@ HRESULT WINAPI DllRegisterServer(void)
TRACE(".\n");
if (FAILED(hr = __wine_register_resources(wineqtdecoder_instance)))
if (FAILED(hr = __wine_register_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
......@@ -242,7 +230,7 @@ HRESULT WINAPI DllUnregisterServer(void)
TRACE(".\n");
if (FAILED(hr = __wine_unregister_resources(wineqtdecoder_instance)))
if (FAILED(hr = __wine_unregister_resources()))
return hr;
if (FAILED(hr = CoCreateInstance(&CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
......
......@@ -203,8 +203,8 @@ RPCRTAPI HRESULT RPC_ENTRY
RPCRTAPI HRESULT RPC_ENTRY
NdrDllUnregisterProxy( HMODULE hDll, const ProxyFileInfo **pProxyFileList, const CLSID *pclsid );
HRESULT __cdecl __wine_register_resources( HMODULE module ) DECLSPEC_HIDDEN;
HRESULT __cdecl __wine_unregister_resources( HMODULE module ) DECLSPEC_HIDDEN;
HRESULT __cdecl __wine_register_resources(void) DECLSPEC_HIDDEN;
HRESULT __cdecl __wine_unregister_resources(void) DECLSPEC_HIDDEN;
#define CSTDSTUBBUFFERRELEASE(pFactory) \
ULONG WINAPI CStdStubBuffer_Release(IRpcStubBuffer *This) \
......@@ -289,8 +289,8 @@ ULONG WINAPI CStdStubBuffer2_Release(IRpcStubBuffer *This) \
#endif
#ifdef WINE_REGISTER_DLL
# define WINE_DO_REGISTER_DLL(pfl, clsid) return __wine_register_resources( hProxyDll )
# define WINE_DO_UNREGISTER_DLL(pfl, clsid) return __wine_unregister_resources( hProxyDll )
# define WINE_DO_REGISTER_DLL(pfl, clsid) return __wine_register_resources()
# define WINE_DO_UNREGISTER_DLL(pfl, clsid) return __wine_unregister_resources()
#else
# define WINE_DO_REGISTER_DLL(pfl, clsid) return NdrDllRegisterProxy( hProxyDll, (pfl), (clsid) )
# define WINE_DO_UNREGISTER_DLL(pfl, clsid) return NdrDllUnregisterProxy( hProxyDll, (pfl), (clsid) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment