Implemented DllCanUnloadNow.

oldstable
Jacek Caban 2005-01-03 14:39:51 +00:00 committed by Alexandre Julliard
parent 76d4edf1f0
commit a8d9c87c41
3 changed files with 47 additions and 24 deletions

View File

@ -53,6 +53,8 @@ DEFINE_GUID(IID_IITStorage, 0x88cc31de, 0x27ab, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0
static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
ULONG dll_count = 0;
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
switch(fdwReason) {
@ -117,8 +119,10 @@ static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref;
}
@ -193,6 +197,7 @@ HRESULT WINAPI ITSS_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
*ppv = &(factory->ITF_IClassFactory);
InterlockedIncrement(&dll_count);
TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
@ -239,8 +244,10 @@ ULONG WINAPI ITStorageImpl_Release(
ITStorageImpl *This = (ITStorageImpl *)iface;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref;
}
@ -393,6 +400,7 @@ static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
TRACE("-> %p\n", its);
*ppObj = (LPVOID) its;
InterlockedIncrement(&dll_count);
return S_OK;
}
@ -405,9 +413,8 @@ HRESULT WINAPI ITSS_DllRegisterServer(void)
return S_OK;
}
BOOL WINAPI ITSS_DllCanUnloadNow(void)
HRESULT WINAPI ITSS_DllCanUnloadNow(void)
{
FIXME("\n");
return FALSE;
TRACE("dll_count = %lu\n", dll_count);
return dll_count ? S_FALSE : S_OK;
}

View File

@ -44,6 +44,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(itss);
extern ULONG dll_count;
/*****************************************************************************/
typedef struct {
@ -78,17 +80,19 @@ static ULONG WINAPI ITS_IMonikerImpl_AddRef(
{
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
TRACE("%p\n", This);
return ++(This->ref);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI ITS_IMonikerImpl_Release(
IMoniker* iface)
{
ITS_IMonikerImpl *This = (ITS_IMonikerImpl *)iface;
ULONG ref = --This->ref;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref;
}
@ -365,6 +369,7 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPWSTR name, DWORD n )
TRACE("-> %p %s %s\n", itsmon,
debugstr_w(itsmon->szFile), debugstr_w(itsmon->szHtml) );
*ppObj = (IMoniker*) itsmon;
InterlockedIncrement(&dll_count);
return S_OK;
}
@ -400,17 +405,19 @@ static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef(
{
ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface;
TRACE("%p\n", This);
return ++(This->ref);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI ITS_IParseDisplayNameImpl_Release(
IParseDisplayName* iface)
{
ITS_IParseDisplayNameImpl *This = (ITS_IParseDisplayNameImpl *)iface;
ULONG ref = --This->ref;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
HeapFree(GetProcessHeap(), 0, This);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref;
}
@ -470,6 +477,7 @@ HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj)
TRACE("-> %p\n", its);
*ppObj = (LPVOID) its;
InterlockedIncrement(&dll_count);
return S_OK;
}

View File

@ -45,6 +45,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(itss);
extern ULONG dll_count;
/************************************************************************/
typedef struct _ITSS_IStorageImpl
@ -107,7 +109,7 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_AddRef(
IEnumSTATSTG* iface)
{
IEnumSTATSTG_Impl *This = (IEnumSTATSTG_Impl *)iface;
return ++(This->ref);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI ITSS_IEnumSTATSTG_Release(
@ -115,7 +117,7 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_Release(
{
IEnumSTATSTG_Impl *This = (IEnumSTATSTG_Impl *)iface;
ULONG ref = --This->ref;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
{
@ -125,7 +127,8 @@ static ULONG WINAPI ITSS_IEnumSTATSTG_Release(
HeapFree( GetProcessHeap(), 0, This->first );
This->first = t;
}
HeapFree(GetProcessHeap(), 0, This);
HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref;
@ -251,6 +254,7 @@ static IEnumSTATSTG_Impl *ITSS_create_enum( void )
stgenum->first = NULL;
stgenum->last = NULL;
stgenum->current = NULL;
InterlockedIncrement(&dll_count);
TRACE(" -> %p\n", stgenum );
@ -282,7 +286,7 @@ ULONG WINAPI ITSS_IStorageImpl_AddRef(
IStorage* iface)
{
ITSS_IStorageImpl *This = (ITSS_IStorageImpl *)iface;
return ++(This->ref);
return InterlockedIncrement(&This->ref);
}
ULONG WINAPI ITSS_IStorageImpl_Release(
@ -290,11 +294,12 @@ ULONG WINAPI ITSS_IStorageImpl_Release(
{
ITSS_IStorageImpl *This = (ITSS_IStorageImpl *)iface;
ULONG ref = --This->ref;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
{
HeapFree(GetProcessHeap(), 0, This);
HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref;
@ -569,6 +574,7 @@ static HRESULT ITSS_create_chm_storage(
strcpyW( stg->dir, dir );
*ppstgOpen = (IStorage*) stg;
InterlockedIncrement(&dll_count);
return S_OK;
}
@ -619,7 +625,7 @@ static ULONG WINAPI ITSS_IStream_AddRef(
IStream* iface)
{
IStream_Impl *This = (IStream_Impl *)iface;
return ++(This->ref);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI ITSS_IStream_Release(
@ -627,12 +633,13 @@ static ULONG WINAPI ITSS_IStream_Release(
{
IStream_Impl *This = (IStream_Impl *)iface;
ULONG ref = --This->ref;
ULONG ref = InterlockedDecrement(&This->ref);
if (ref == 0)
{
IStorage_Release( (IStorage*) This->stg );
HeapFree(GetProcessHeap(), 0, This);
InterlockedDecrement(&dll_count);
}
return ref;
@ -818,6 +825,7 @@ static IStream_Impl *ITSS_create_stream(
memcpy( &stm->ui, ui, sizeof stm->ui );
stm->stg = stg;
IStorage_AddRef( (IStorage*) stg );
InterlockedIncrement(&dll_count);
TRACE(" -> %p\n", stm );