Added DllCanUnloadNow implementation.

This commit is contained in:
Jacek Caban 2005-08-02 09:49:06 +00:00 committed by Alexandre Julliard
parent 7840becd3f
commit 2f93763e24
4 changed files with 50 additions and 15 deletions

View File

@ -140,6 +140,8 @@ static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
if(This->nscontainer) if(This->nscontainer)
HTMLDocument_NSContainer_Destroy(This); HTMLDocument_NSContainer_Destroy(This);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
UNLOCK_MODULE();
} }
return ref; return ref;
@ -974,8 +976,12 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
ret->ref = 0; ret->ref = 0;
hres = IHTMLDocument_QueryInterface(HTMLDOC(ret), riid, ppvObject); hres = IHTMLDocument_QueryInterface(HTMLDOC(ret), riid, ppvObject);
if(FAILED(hres)) if(FAILED(hres)) {
HeapFree(GetProcessHeap(), 0, ret); HeapFree(GetProcessHeap(), 0, ret);
return hres;
}
LOCK_MODULE();
HTMLDocument_Persist_Init(ret); HTMLDocument_Persist_Init(ret);
HTMLDocument_OleObj_Init(ret); HTMLDocument_OleObj_Init(ret);

View File

@ -48,6 +48,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml); WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
HINSTANCE hInst; HINSTANCE hInst;
LONG module_ref = 0;
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{ {
@ -100,8 +101,10 @@ static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
TRACE("(%p) ref = %lu\n", This, ref); TRACE("(%p) ref = %lu\n", This, ref);
if(!ref) if(!ref) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
UNLOCK_MODULE();
}
return ref; return ref;
} }
@ -115,7 +118,13 @@ static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock) static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
{ {
FIXME("(%p)->(%x) stub\n", iface, dolock); TRACE("(%p)->(%x)\n", iface, dolock);
if(dolock)
LOCK_MODULE();
else
UNLOCK_MODULE();
return S_OK; return S_OK;
} }
@ -137,7 +146,9 @@ static HRESULT ClassFactory_Create(REFIID riid, void **ppv, CreateInstanceFunc f
ret->fnCreateInstance = fnCreateInstance; ret->fnCreateInstance = fnCreateInstance;
hres = IClassFactory_QueryInterface((IClassFactory*)ret, riid, ppv); hres = IClassFactory_QueryInterface((IClassFactory*)ret, riid, ppv);
if(FAILED(hres)) { if(SUCCEEDED(hres)) {
LOCK_MODULE();
}else {
HeapFree(GetProcessHeap(), 0, ret); HeapFree(GetProcessHeap(), 0, ret);
*ppv = NULL; *ppv = NULL;
} }
@ -172,8 +183,8 @@ HRESULT WINAPI MSHTML_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *pp
HRESULT WINAPI MSHTML_DllCanUnloadNow(void) HRESULT WINAPI MSHTML_DllCanUnloadNow(void)
{ {
FIXME("()\n"); TRACE("() ref=%ld\n", module_ref);
return S_FALSE; return module_ref ? S_FALSE : S_OK;
} }
/*********************************************************************** /***********************************************************************

View File

@ -108,4 +108,8 @@ DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0x
DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B); DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82); DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
extern LONG module_ref;
#define LOCK_MODULE() InterlockedIncrement(&module_ref)
#define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
extern HINSTANCE hInst; extern HINSTANCE hInst;

View File

@ -51,8 +51,7 @@ typedef struct {
const IClassFactoryVtbl *lpClassFactoryVtbl; const IClassFactoryVtbl *lpClassFactoryVtbl;
} ProtocolFactory; } ProtocolFactory;
#define PROTOCOLINFO_THIS(iface) \ #define PROTOCOLINFO_THIS(iface) DEFINE_THIS(ProtocolFactory, InternetProtocolInfo, iface)
(ProtocolFactory*)((char*)(iface)-offsetof(ProtocolFactory,lpInternetProtocolInfoVtbl))
static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv) static HRESULT WINAPI InternetProtocolInfo_QueryInterface(IInternetProtocolInfo *iface, REFIID riid, void **ppv)
{ {
@ -83,6 +82,7 @@ static ULONG WINAPI InternetProtocolInfo_AddRef(IInternetProtocolInfo *iface)
{ {
ProtocolFactory *This = PROTOCOLINFO_THIS(iface); ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
LOCK_MODULE();
return 2; return 2;
} }
@ -90,13 +90,13 @@ static ULONG WINAPI InternetProtocolInfo_Release(IInternetProtocolInfo *iface)
{ {
ProtocolFactory *This = PROTOCOLINFO_THIS(iface); ProtocolFactory *This = PROTOCOLINFO_THIS(iface);
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
UNLOCK_MODULE();
return 1; return 1;
} }
#undef PROTOCOLINFO_THIS #undef PROTOCOLINFO_THIS
#define CLASSFACTORY_THIS(iface) \ #define CLASSFACTORY_THIS(iface) DEFINE_THIS(ProtocolFactory, ClassFactory, iface)
(ProtocolFactory*)((char*)(iface)-offsetof(ProtocolFactory,lpClassFactoryVtbl))
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv) static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppv)
{ {
@ -119,7 +119,14 @@ static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock) static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
{ {
ProtocolFactory *This = CLASSFACTORY_THIS(iface); ProtocolFactory *This = CLASSFACTORY_THIS(iface);
FIXME("(%p)->(%x)\n", This, dolock);
TRACE("(%p)->(%x)\n", This, dolock);
if(dolock)
LOCK_MODULE();
else
UNLOCK_MODULE();
return S_OK; return S_OK;
} }
@ -176,8 +183,10 @@ static ULONG WINAPI AboutProtocol_Release(IInternetProtocol *iface)
TRACE("(%p) ref=%lx\n", iface, ref); TRACE("(%p) ref=%lx\n", iface, ref);
if(!ref) if(!ref) {
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
UNLOCK_MODULE();
}
return ref; return ref;
} }
@ -287,7 +296,9 @@ static HRESULT WINAPI AboutProtocolFactory_CreateInstance(IClassFactory *iface,
hres = IUnknown_QueryInterface((IUnknown*)ret, riid, ppv); hres = IUnknown_QueryInterface((IUnknown*)ret, riid, ppv);
if(FAILED(hres)) if(SUCCEEDED(hres))
LOCK_MODULE();
else
HeapFree(GetProcessHeap(), 0, ret); HeapFree(GetProcessHeap(), 0, ret);
return hres; return hres;
@ -408,6 +419,7 @@ static ULONG WINAPI ResProtocol_Release(IInternetProtocol *iface)
if(!ref) { if(!ref) {
HeapFree(GetProcessHeap(), 0, This->data); HeapFree(GetProcessHeap(), 0, This->data);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
UNLOCK_MODULE();
} }
return ref; return ref;
@ -612,7 +624,9 @@ static HRESULT WINAPI ResProtocolFactory_CreateInstance(IClassFactory *iface, IU
hres = IUnknown_QueryInterface((IUnknown*)ret, riid, ppv); hres = IUnknown_QueryInterface((IUnknown*)ret, riid, ppv);
if(FAILED(hres)) if(SUCCEEDED(hres))
LOCK_MODULE();
else
HeapFree(GetProcessHeap(), 0, ret); HeapFree(GetProcessHeap(), 0, ret);
return hres; return hres;
@ -688,6 +702,6 @@ HRESULT ProtocolFactory_Create(REFCLSID rclsid, REFIID riid, void **ppv)
FIXME("not implemented protocol %s\n", debugstr_guid(rclsid)); FIXME("not implemented protocol %s\n", debugstr_guid(rclsid));
return CLASS_E_CLASSNOTAVAILABLE; return CLASS_E_CLASSNOTAVAILABLE;
} }
return IUnknown_QueryInterface((IUnknown*)cf, riid, ppv); return IUnknown_QueryInterface((IUnknown*)cf, riid, ppv);
} }