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
32 #include "msiserver.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
38 static LONG dll_count
;
41 INSTALLUILEVEL gUILevel
= INSTALLUILEVEL_DEFAULT
;
43 INSTALLUI_HANDLERA gUIHandlerA
= NULL
;
44 INSTALLUI_HANDLERW gUIHandlerW
= NULL
;
45 INSTALLUI_HANDLER_RECORD gUIHandlerRecord
= NULL
;
47 DWORD gUIFilterRecord
= 0;
48 LPVOID gUIContext
= NULL
;
49 LPVOID gUIContextRecord
= NULL
;
50 WCHAR
*gszLogFile
= NULL
;
51 HINSTANCE msi_hInstance
;
55 * Dll lifetime tracking declaration
57 static void LockModule(void)
59 InterlockedIncrement(&dll_count
);
62 static void UnlockModule(void)
64 InterlockedDecrement(&dll_count
);
67 /******************************************************************
70 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
74 case DLL_PROCESS_ATTACH
:
75 msi_hInstance
= hinstDLL
;
76 DisableThreadLibraryCalls(hinstDLL
);
77 IsWow64Process( GetCurrentProcess(), &is_wow64
);
79 case DLL_PROCESS_DETACH
:
80 if (lpvReserved
) break;
81 msi_dialog_unregister_class();
82 msi_free_handle_table();
83 msi_free( gszLogFile
);
90 typedef struct tagIClassFactoryImpl
{
91 IClassFactory IClassFactory_iface
;
92 HRESULT (*create_object
)( IUnknown
*, LPVOID
* );
95 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
97 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
100 static HRESULT WINAPI
MsiCF_QueryInterface(LPCLASSFACTORY iface
,
101 REFIID riid
,LPVOID
*ppobj
)
103 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
105 TRACE("%p %s %p\n",This
,debugstr_guid(riid
),ppobj
);
107 if( IsEqualCLSID( riid
, &IID_IUnknown
) ||
108 IsEqualCLSID( riid
, &IID_IClassFactory
) )
110 IClassFactory_AddRef( iface
);
114 return E_NOINTERFACE
;
117 static ULONG WINAPI
MsiCF_AddRef(LPCLASSFACTORY iface
)
123 static ULONG WINAPI
MsiCF_Release(LPCLASSFACTORY iface
)
129 static HRESULT WINAPI
MsiCF_CreateInstance(LPCLASSFACTORY iface
,
130 LPUNKNOWN pOuter
, REFIID riid
, LPVOID
*ppobj
)
132 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
133 IUnknown
*unk
= NULL
;
136 TRACE("%p %p %s %p\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
138 r
= This
->create_object( pOuter
, (LPVOID
*) &unk
);
141 r
= IUnknown_QueryInterface( unk
, riid
, ppobj
);
142 IUnknown_Release( unk
);
147 static HRESULT WINAPI
MsiCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
149 TRACE("%p %d\n", iface
, dolock
);
159 static const IClassFactoryVtbl MsiCF_Vtbl
=
161 MsiCF_QueryInterface
,
164 MsiCF_CreateInstance
,
168 static IClassFactoryImpl MsiServer_CF
= { { &MsiCF_Vtbl
}, create_msiserver
};
170 /******************************************************************
171 * DllGetClassObject [MSI.@]
173 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
175 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
177 if ( IsEqualCLSID (rclsid
, &CLSID_MsiInstaller
) )
179 *ppv
= &MsiServer_CF
;
183 if( IsEqualCLSID (rclsid
, &CLSID_MsiServerMessage
) ||
184 IsEqualCLSID (rclsid
, &CLSID_MsiServer
) ||
185 IsEqualCLSID (rclsid
, &CLSID_PSFactoryBuffer
) ||
186 IsEqualCLSID (rclsid
, &CLSID_MsiServerX3
) )
188 FIXME("create %s object\n", debugstr_guid( rclsid
));
191 return CLASS_E_CLASSNOTAVAILABLE
;
194 /******************************************************************
195 * DllGetVersion [MSI.@]
197 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*pdvi
)
201 if (pdvi
->cbSize
< sizeof(DLLVERSIONINFO
))
204 pdvi
->dwMajorVersion
= MSI_MAJORVERSION
;
205 pdvi
->dwMinorVersion
= MSI_MINORVERSION
;
206 pdvi
->dwBuildNumber
= MSI_BUILDNUMBER
;
207 pdvi
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
212 /******************************************************************
213 * DllCanUnloadNow [MSI.@]
215 HRESULT WINAPI
DllCanUnloadNow(void)
217 return dll_count
== 0 ? S_OK
: S_FALSE
;
220 /***********************************************************************
221 * DllRegisterServer (MSI.@)
223 HRESULT WINAPI
DllRegisterServer(void)
225 return __wine_register_resources( msi_hInstance
);
228 /***********************************************************************
229 * DllUnregisterServer (MSI.@)
231 HRESULT WINAPI
DllUnregisterServer(void)
233 return __wine_unregister_resources( msi_hInstance
);