2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2006 Mike McCormack for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define NONAMELESSUNION
33 #include "msiserver.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
39 static LONG dll_count
;
42 INSTALLUILEVEL gUILevel
= INSTALLUILEVEL_BASIC
;
44 INSTALLUI_HANDLERA gUIHandlerA
= NULL
;
45 INSTALLUI_HANDLERW gUIHandlerW
= NULL
;
46 INSTALLUI_HANDLER_RECORD gUIHandlerRecord
= NULL
;
48 LPVOID gUIContext
= NULL
;
49 WCHAR
*gszLogFile
= NULL
;
50 HINSTANCE msi_hInstance
;
54 * Dll lifetime tracking declaration
56 static void LockModule(void)
58 InterlockedIncrement(&dll_count
);
61 static void UnlockModule(void)
63 InterlockedDecrement(&dll_count
);
66 /******************************************************************
69 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
73 case DLL_PROCESS_ATTACH
:
74 msi_hInstance
= hinstDLL
;
75 DisableThreadLibraryCalls(hinstDLL
);
77 case DLL_PROCESS_DETACH
:
78 msi_dialog_unregister_class();
79 msi_free_handle_table();
80 msi_free( gszLogFile
);
86 typedef struct tagIClassFactoryImpl
{
87 IClassFactory IClassFactory_iface
;
88 HRESULT (*create_object
)( IUnknown
*, LPVOID
* );
91 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
93 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
96 static HRESULT WINAPI
MsiCF_QueryInterface(LPCLASSFACTORY iface
,
97 REFIID riid
,LPVOID
*ppobj
)
99 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
101 TRACE("%p %s %p\n",This
,debugstr_guid(riid
),ppobj
);
103 if( IsEqualCLSID( riid
, &IID_IUnknown
) ||
104 IsEqualCLSID( riid
, &IID_IClassFactory
) )
106 IClassFactory_AddRef( iface
);
110 return E_NOINTERFACE
;
113 static ULONG WINAPI
MsiCF_AddRef(LPCLASSFACTORY iface
)
119 static ULONG WINAPI
MsiCF_Release(LPCLASSFACTORY iface
)
125 static HRESULT WINAPI
MsiCF_CreateInstance(LPCLASSFACTORY iface
,
126 LPUNKNOWN pOuter
, REFIID riid
, LPVOID
*ppobj
)
128 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
129 IUnknown
*unk
= NULL
;
132 TRACE("%p %p %s %p\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
134 r
= This
->create_object( pOuter
, (LPVOID
*) &unk
);
137 r
= IUnknown_QueryInterface( unk
, riid
, ppobj
);
138 IUnknown_Release( unk
);
143 static HRESULT WINAPI
MsiCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
145 TRACE("%p %d\n", iface
, dolock
);
155 static const IClassFactoryVtbl MsiCF_Vtbl
=
157 MsiCF_QueryInterface
,
160 MsiCF_CreateInstance
,
164 static IClassFactoryImpl MsiServer_CF
= { { &MsiCF_Vtbl
}, create_msiserver
};
165 static IClassFactoryImpl WineMsiCustomRemote_CF
= { { &MsiCF_Vtbl
}, create_msi_custom_remote
};
166 static IClassFactoryImpl WineMsiRemotePackage_CF
= { { &MsiCF_Vtbl
}, create_msi_remote_package
};
168 /******************************************************************
169 * DllGetClassObject [MSI.@]
171 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
173 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
175 if ( IsEqualCLSID (rclsid
, &CLSID_MsiInstaller
) )
177 *ppv
= &MsiServer_CF
;
181 if ( IsEqualCLSID (rclsid
, &CLSID_WineMsiRemoteCustomAction
) )
183 *ppv
= &WineMsiCustomRemote_CF
;
187 if ( IsEqualCLSID (rclsid
, &CLSID_WineMsiRemotePackage
) )
189 *ppv
= &WineMsiRemotePackage_CF
;
193 if( IsEqualCLSID (rclsid
, &CLSID_MsiServerMessage
) ||
194 IsEqualCLSID (rclsid
, &CLSID_MsiServer
) ||
195 IsEqualCLSID (rclsid
, &CLSID_PSFactoryBuffer
) ||
196 IsEqualCLSID (rclsid
, &CLSID_MsiServerX3
) )
198 FIXME("create %s object\n", debugstr_guid( rclsid
));
201 return CLASS_E_CLASSNOTAVAILABLE
;
204 /******************************************************************
205 * DllGetVersion [MSI.@]
207 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*pdvi
)
211 if (pdvi
->cbSize
< sizeof(DLLVERSIONINFO
))
214 pdvi
->dwMajorVersion
= MSI_MAJORVERSION
;
215 pdvi
->dwMinorVersion
= MSI_MINORVERSION
;
216 pdvi
->dwBuildNumber
= MSI_BUILDNUMBER
;
217 pdvi
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
222 /******************************************************************
223 * DllCanUnloadNow [MSI.@]
225 HRESULT WINAPI
DllCanUnloadNow(void)
227 return dll_count
== 0 ? S_OK
: S_FALSE
;
230 /***********************************************************************
231 * DllRegisterServer (MSI.@)
233 HRESULT WINAPI
DllRegisterServer(void)
235 return __wine_register_resources( msi_hInstance
);
238 /***********************************************************************
239 * DllUnregisterServer (MSI.@)
241 HRESULT WINAPI
DllUnregisterServer(void)
243 return __wine_unregister_resources( msi_hInstance
);