[MSI] DllCanUnloadNow try3
Christian Gmeiner
christian.gmeiner at students.fh-vorarlberg.ac.at
Mon Dec 5 03:20:14 CST 2005
Next try:
+ using now static for LockModule and UnlockModule
Greets,
Christian
--
Christian Gmeiner - student of computer science
http://dxr3plugin.sf.net
http://itb04.ath.cx
-------------- next part --------------
Index: dlls/msi/msi.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msi.c,v
retrieving revision 1.117
diff -u -b -r1.117 msi.c
--- dlls/msi/msi.c 11 Nov 2005 10:52:53 -0000 1.117
+++ dlls/msi/msi.c 5 Dec 2005 07:50:42 -0000
@@ -2,6 +2,7 @@
* Implementation of the Microsoft Installer (msi.dll)
*
* Copyright 2002,2003,2004,2005 Mike McCormack for CodeWeavers
+ * Copyright 2005 Christian Gmeiner
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -53,8 +54,24 @@
WCHAR gszLogFile[MAX_PATH];
HINSTANCE msi_hInstance;
+LONG dll_count = 0;
+
static const WCHAR installerW[] = {'\\','I','n','s','t','a','l','l','e','r',0};
+/**********************************************************************
+ * Dll lifetime tracking declaration
+ */
+static void LockModule(void)
+{
+ InterlockedIncrement(&dll_count);
+}
+
+static void UnlockModule(void)
+{
+ InterlockedDecrement(&dll_count);
+}
+
+
UINT WINAPI MsiOpenProductA(LPCSTR szProduct, MSIHANDLE *phProduct)
{
UINT r;
@@ -1285,11 +1302,17 @@
static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
{
+ IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ TRACE("(%p): AddRef\n", This);
+ LockModule();
return 2;
}
static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
{
+ IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ TRACE("(%p): ReleaseRef\n", This);
+ UnlockModule();
return 1;
}
@@ -1304,9 +1327,13 @@
static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
{
- IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
+ TRACE("(%p)->(%d)\n", iface, dolock);
+
+ if(dolock)
+ LockModule();
+ else
+ UnlockModule();
- FIXME("%p %d\n", This, dolock);
return S_OK;
}
@@ -1363,7 +1390,7 @@
*/
HRESULT WINAPI DllCanUnloadNow(void)
{
- return S_FALSE;
+ return dll_count == 0 ? S_OK : S_FALSE;
}
/***********************************************************************
More information about the wine-patches
mailing list