diff --git a/dlls/urlmon/sec_mgr.c b/dlls/urlmon/sec_mgr.c index 949cdeaddaf..3ea30e7725e 100644 --- a/dlls/urlmon/sec_mgr.c +++ b/dlls/urlmon/sec_mgr.c @@ -82,6 +82,8 @@ static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface) TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1); + URLMON_LockModule(); + return refCount; } @@ -96,6 +98,9 @@ static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface) if (!refCount){ HeapFree(GetProcessHeap(),0,This); } + + URLMON_UnlockModule(); + return refCount; } @@ -242,6 +247,8 @@ static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManager* iface) TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1); + URLMON_LockModule(); + return refCount; } @@ -257,6 +264,9 @@ static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManager* iface) if(!refCount) HeapFree(GetProcessHeap(), 0, This); + + URLMON_UnlockModule(); + return refCount; } diff --git a/dlls/urlmon/umon.c b/dlls/urlmon/umon.c index 7a82812dd59..284d9e99d92 100644 --- a/dlls/urlmon/umon.c +++ b/dlls/urlmon/umon.c @@ -107,6 +107,8 @@ static ULONG WINAPI URLMonikerImpl_AddRef(IMoniker* iface) TRACE("(%p)->(ref before=%lu)\n",This, refCount - 1); + URLMON_LockModule(); + return refCount; } @@ -126,6 +128,8 @@ static ULONG WINAPI URLMonikerImpl_Release(IMoniker* iface) HeapFree(GetProcessHeap(),0,This); } + URLMON_UnlockModule(); + return refCount; } diff --git a/dlls/urlmon/urlmon_main.c b/dlls/urlmon/urlmon_main.c index 03f0ed9d4e9..1a1ffd1b251 100644 --- a/dlls/urlmon/urlmon_main.c +++ b/dlls/urlmon/urlmon_main.c @@ -37,6 +37,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(urlmon); +LONG URLMON_refCount = 0; + HINSTANCE URLMON_hInstance = 0; /*********************************************************************** @@ -76,9 +78,7 @@ HRESULT WINAPI URLMON_DllInstall(BOOL bInstall, LPCWSTR cmdline) */ HRESULT WINAPI URLMON_DllCanUnloadNow(void) { - FIXME("(void): stub\n"); - - return S_FALSE; + return URLMON_refCount != 0 ? S_FALSE : S_OK; } @@ -125,6 +125,8 @@ CF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) static ULONG WINAPI CF_AddRef(LPCLASSFACTORY iface) { IClassFactoryImpl *This = (IClassFactoryImpl *)iface; + URLMON_LockModule(); + return InterlockedIncrement(&This->ref); } @@ -137,6 +139,8 @@ static ULONG WINAPI CF_Release(LPCLASSFACTORY iface) if (ref == 0) HeapFree(GetProcessHeap(), 0, This); + URLMON_UnlockModule(); + return ref; } @@ -160,8 +164,13 @@ static HRESULT WINAPI CF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, static HRESULT WINAPI CF_LockServer(LPCLASSFACTORY iface,BOOL dolock) { - IClassFactoryImpl *This = (IClassFactoryImpl *)iface; - FIXME("(%p)->(%d),stub!\n",This,dolock); + TRACE("(%d)\n", dolock); + + if (dolock) + URLMON_LockModule(); + else + URLMON_UnlockModule(); + return S_OK; } diff --git a/dlls/urlmon/urlmon_main.h b/dlls/urlmon/urlmon_main.h index 45fb593ead7..212dddc5ab9 100644 --- a/dlls/urlmon/urlmon_main.h +++ b/dlls/urlmon/urlmon_main.h @@ -28,6 +28,13 @@ extern HINSTANCE URLMON_hInstance; extern HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); extern HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj); +/********************************************************************** + * Dll lifetime tracking declaration for urlmon.dll + */ +extern LONG URLMON_refCount; +static inline void URLMON_LockModule() { InterlockedIncrement( &URLMON_refCount ); } +static inline void URLMON_UnlockModule() { InterlockedDecrement( &URLMON_refCount ); } + #define ICOM_THIS_MULTI(impl,field,iface) impl* const This=(impl*)((char*)(iface) - offsetof(impl,field)) #endif /* __WINE_URLMON_MAIN_H */