Commit a8d9c87c authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

Implemented DllCanUnloadNow.

parent 76d4edf1
...@@ -53,6 +53,8 @@ DEFINE_GUID(IID_IITStorage, 0x88cc31de, 0x27ab, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0 ...@@ -53,6 +53,8 @@ DEFINE_GUID(IID_IITStorage, 0x88cc31de, 0x27ab, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0
static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj); static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
ULONG dll_count = 0;
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{ {
switch(fdwReason) { switch(fdwReason) {
...@@ -117,8 +119,10 @@ static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface) ...@@ -117,8 +119,10 @@ static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref; return ref;
} }
...@@ -193,6 +197,7 @@ HRESULT WINAPI ITSS_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv) ...@@ -193,6 +197,7 @@ HRESULT WINAPI ITSS_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
factory->pfnCreateInstance = object_creation[i].pfnCreateInstance; factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
*ppv = &(factory->ITF_IClassFactory); *ppv = &(factory->ITF_IClassFactory);
InterlockedIncrement(&dll_count);
TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) ); TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
...@@ -239,8 +244,10 @@ ULONG WINAPI ITStorageImpl_Release( ...@@ -239,8 +244,10 @@ ULONG WINAPI ITStorageImpl_Release(
ITStorageImpl *This = (ITStorageImpl *)iface; ITStorageImpl *This = (ITStorageImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref); ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref; return ref;
} }
...@@ -393,6 +400,7 @@ static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj) ...@@ -393,6 +400,7 @@ static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
TRACE("-> %p\n", its); TRACE("-> %p\n", its);
*ppObj = (LPVOID) its; *ppObj = (LPVOID) its;
InterlockedIncrement(&dll_count);
return S_OK; return S_OK;
} }
...@@ -405,9 +413,8 @@ HRESULT WINAPI ITSS_DllRegisterServer(void) ...@@ -405,9 +413,8 @@ HRESULT WINAPI ITSS_DllRegisterServer(void)
return S_OK; return S_OK;
} }
BOOL WINAPI ITSS_DllCanUnloadNow(void) HRESULT WINAPI ITSS_DllCanUnloadNow(void)
{ {
FIXME("\n"); TRACE("dll_count = %lu\n", dll_count);
return dll_count ? S_FALSE : S_OK;
return FALSE;
} }
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(itss); WINE_DEFAULT_DEBUG_CHANNEL(itss);
extern ULONG dll_count;
/*****************************************************************************/ /*****************************************************************************/
typedef struct { typedef struct {
...@@ -78,17 +80,19 @@ static ULONG WINAPI ITS_IMonikerImpl_AddRef( ...@@ -78,17 +80,19 @@ static ULONG WINAPI ITS_IMonikerImpl_AddRef(
{ {
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface; ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
TRACE("%p\n", This); TRACE("%p\n", This);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI ITS_IMonikerImpl_Release( static ULONG WINAPI ITS_IMonikerImpl_Release(
IMoniker* iface) IMoniker* iface)
{ {
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface; ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
ULONG ref = --This->ref; ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref; return ref;
} }
...@@ -365,6 +369,7 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPWSTR name, DWORD n ) ...@@ -365,6 +369,7 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPWSTR name, DWORD n )
TRACE("-> %p %s %s\n", itsmon, TRACE("-> %p %s %s\n", itsmon,
debugstr_w(itsmon->szFile), debugstr_w(itsmon->szHtml) ); debugstr_w(itsmon->szFile), debugstr_w(itsmon->szHtml) );
*ppObj = (IMoniker*) itsmon; *ppObj = (IMoniker*) itsmon;
InterlockedIncrement(&dll_count);
return S_OK; return S_OK;
} }
...@@ -400,17 +405,19 @@ static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef( ...@@ -400,17 +405,19 @@ static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef(
{ {
ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface; ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface;
TRACE("%p\n", This); TRACE("%p\n", This);
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI ITS_IParseDisplayNameImpl_Release( static ULONG WINAPI ITS_IParseDisplayNameImpl_Release(
IParseDisplayName* iface) IParseDisplayName* iface)
{ {
ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface; ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface;
ULONG ref = --This->ref; ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref; return ref;
} }
...@@ -470,6 +477,7 @@ HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj) ...@@ -470,6 +477,7 @@ HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj)
TRACE("-> %p\n", its); TRACE("-> %p\n", its);
*ppObj = (LPVOID) its; *ppObj = (LPVOID) its;
InterlockedIncrement(&dll_count);
return S_OK; return S_OK;
} }
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(itss); WINE_DEFAULT_DEBUG_CHANNEL(itss);
extern ULONG dll_count;
/************************************************************************/ /************************************************************************/
typedef struct _ITSS_IStorageImpl typedef struct _ITSS_IStorageImpl
...@@ -107,7 +109,7 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_AddRef( ...@@ -107,7 +109,7 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_AddRef(
IEnumSTATSTG* iface) IEnumSTATSTG* iface)
{ {
IEnumSTATSTG_Impl *This = (IEnumSTATSTG_Impl *)iface; IEnumSTATSTG_Impl *This = (IEnumSTATSTG_Impl *)iface;
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI ITSS_IEnumSTATSTG_Release( static ULONG WINAPI ITSS_IEnumSTATSTG_Release(
...@@ -115,7 +117,7 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_Release( ...@@ -115,7 +117,7 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_Release(
{ {
IEnumSTATSTG_Impl *This = (IEnumSTATSTG_Impl *)iface; IEnumSTATSTG_Impl *This = (IEnumSTATSTG_Impl *)iface;
ULONG ref = --This->ref; ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0)
{ {
...@@ -125,7 +127,8 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_Release( ...@@ -125,7 +127,8 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_Release(
HeapFree( GetProcessHeap(), 0, This->first ); HeapFree( GetProcessHeap(), 0, This->first );
This->first = t; This->first = t;
} }
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
} }
return ref; return ref;
...@@ -251,6 +254,7 @@ static IEnumSTATSTG_Impl *ITSS_create_enum( void ) ...@@ -251,6 +254,7 @@ static IEnumSTATSTG_Impl *ITSS_create_enum( void )
stgenum->first = NULL; stgenum->first = NULL;
stgenum->last = NULL; stgenum->last = NULL;
stgenum->current = NULL; stgenum->current = NULL;
InterlockedIncrement(&dll_count);
TRACE(" -> %p\n", stgenum ); TRACE(" -> %p\n", stgenum );
...@@ -282,7 +286,7 @@ ULONG WINAPI ITSS_IStorageImpl_AddRef( ...@@ -282,7 +286,7 @@ ULONG WINAPI ITSS_IStorageImpl_AddRef(
IStorage* iface) IStorage* iface)
{ {
ITSS_IStorageImpl *This = (ITSS_IStorageImpl *)iface; ITSS_IStorageImpl *This = (ITSS_IStorageImpl *)iface;
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
ULONG WINAPI ITSS_IStorageImpl_Release( ULONG WINAPI ITSS_IStorageImpl_Release(
...@@ -290,11 +294,12 @@ ULONG WINAPI ITSS_IStorageImpl_Release( ...@@ -290,11 +294,12 @@ ULONG WINAPI ITSS_IStorageImpl_Release(
{ {
ITSS_IStorageImpl *This = (ITSS_IStorageImpl *)iface; ITSS_IStorageImpl *This = (ITSS_IStorageImpl *)iface;
ULONG ref = --This->ref; ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0)
{ {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
} }
return ref; return ref;
...@@ -569,6 +574,7 @@ static HRESULT ITSS_create_chm_storage( ...@@ -569,6 +574,7 @@ static HRESULT ITSS_create_chm_storage(
strcpyW( stg->dir, dir ); strcpyW( stg->dir, dir );
*ppstgOpen = (IStorage*) stg; *ppstgOpen = (IStorage*) stg;
InterlockedIncrement(&dll_count);
return S_OK; return S_OK;
} }
...@@ -619,7 +625,7 @@ static ULONG WINAPI ITSS_IStream_AddRef( ...@@ -619,7 +625,7 @@ static ULONG WINAPI ITSS_IStream_AddRef(
IStream* iface) IStream* iface)
{ {
IStream_Impl *This = (IStream_Impl *)iface; IStream_Impl *This = (IStream_Impl *)iface;
return ++(This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI ITSS_IStream_Release( static ULONG WINAPI ITSS_IStream_Release(
...@@ -627,12 +633,13 @@ static ULONG WINAPI ITSS_IStream_Release( ...@@ -627,12 +633,13 @@ static ULONG WINAPI ITSS_IStream_Release(
{ {
IStream_Impl *This = (IStream_Impl *)iface; IStream_Impl *This = (IStream_Impl *)iface;
ULONG ref = --This->ref; ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0) if (ref == 0)
{ {
IStorage_Release( (IStorage*) This->stg ); IStorage_Release( (IStorage*) This->stg );
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
} }
return ref; return ref;
...@@ -818,6 +825,7 @@ static IStream_Impl *ITSS_create_stream( ...@@ -818,6 +825,7 @@ static IStream_Impl *ITSS_create_stream(
memcpy( &stm->ui, ui, sizeof stm->ui ); memcpy( &stm->ui, ui, sizeof stm->ui );
stm->stg = stg; stm->stg = stg;
IStorage_AddRef( (IStorage*) stg ); IStorage_AddRef( (IStorage*) stg );
InterlockedIncrement(&dll_count);
TRACE(" -> %p\n", stm ); TRACE(" -> %p\n", stm );
......
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