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
25 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
27 static LONG dll_count
;
30 INSTALLUILEVEL gUILevel
= INSTALLUILEVEL_BASIC
;
32 INSTALLUI_HANDLERA gUIHandlerA
= NULL
;
33 INSTALLUI_HANDLERW gUIHandlerW
= NULL
;
34 INSTALLUI_HANDLER_RECORD gUIHandlerRecord
= NULL
;
36 LPVOID gUIContext
= NULL
;
37 WCHAR
*gszLogFile
= NULL
;
38 HINSTANCE msi_hInstance
;
42 * Dll lifetime tracking declaration
44 static void LockModule(void)
46 InterlockedIncrement(&dll_count
);
49 static void UnlockModule(void)
51 InterlockedDecrement(&dll_count
);
54 /******************************************************************
57 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
61 case DLL_PROCESS_ATTACH
:
62 msi_hInstance
= hinstDLL
;
63 DisableThreadLibraryCalls(hinstDLL
);
64 IsWow64Process( GetCurrentProcess(), &is_wow64
);
66 case DLL_PROCESS_DETACH
:
67 if (lpvReserved
) break;
68 msi_dialog_unregister_class();
69 msi_free_handle_table();
70 msi_free( gszLogFile
);
77 typedef struct tagIClassFactoryImpl
{
78 IClassFactory IClassFactory_iface
;
79 HRESULT (*create_object
)( IUnknown
*, LPVOID
* );
82 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
84 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
87 static HRESULT WINAPI
MsiCF_QueryInterface(LPCLASSFACTORY iface
,
88 REFIID riid
,LPVOID
*ppobj
)
90 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
92 TRACE("%p %s %p\n",This
,debugstr_guid(riid
),ppobj
);
94 if( IsEqualCLSID( riid
, &IID_IUnknown
) ||
95 IsEqualCLSID( riid
, &IID_IClassFactory
) )
97 IClassFactory_AddRef( iface
);
101 return E_NOINTERFACE
;
104 static ULONG WINAPI
MsiCF_AddRef(LPCLASSFACTORY iface
)
110 static ULONG WINAPI
MsiCF_Release(LPCLASSFACTORY iface
)
116 static HRESULT WINAPI
MsiCF_CreateInstance(LPCLASSFACTORY iface
,
117 LPUNKNOWN pOuter
, REFIID riid
, LPVOID
*ppobj
)
119 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
120 IUnknown
*unk
= NULL
;
123 TRACE("%p %p %s %p\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
125 r
= This
->create_object( pOuter
, (LPVOID
*) &unk
);
128 r
= IUnknown_QueryInterface( unk
, riid
, ppobj
);
129 IUnknown_Release( unk
);
134 static HRESULT WINAPI
MsiCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
136 TRACE("%p %d\n", iface
, dolock
);
146 static const IClassFactoryVtbl MsiCF_Vtbl
=
148 MsiCF_QueryInterface
,
151 MsiCF_CreateInstance
,
155 static IClassFactoryImpl MsiServer_CF
= { { &MsiCF_Vtbl
}, create_msiserver
};
156 static IClassFactoryImpl WineMsiCustomRemote_CF
= { { &MsiCF_Vtbl
}, create_msi_custom_remote
};
157 static IClassFactoryImpl WineMsiRemotePackage_CF
= { { &MsiCF_Vtbl
}, create_msi_remote_package
};
159 /******************************************************************
160 * DllGetClassObject [MSI.@]
162 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
164 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
166 if ( IsEqualCLSID (rclsid
, &CLSID_MsiInstaller
) )
168 *ppv
= &MsiServer_CF
;
172 if ( IsEqualCLSID (rclsid
, &CLSID_WineMsiRemoteCustomAction
) )
174 *ppv
= &WineMsiCustomRemote_CF
;
178 if ( IsEqualCLSID (rclsid
, &CLSID_WineMsiRemotePackage
) )
180 *ppv
= &WineMsiRemotePackage_CF
;
184 if( IsEqualCLSID (rclsid
, &CLSID_MsiServerMessage
) ||
185 IsEqualCLSID (rclsid
, &CLSID_MsiServer
) ||
186 IsEqualCLSID (rclsid
, &CLSID_PSFactoryBuffer
) ||
187 IsEqualCLSID (rclsid
, &CLSID_MsiServerX3
) )
189 FIXME("create %s object\n", debugstr_guid( rclsid
));
192 return CLASS_E_CLASSNOTAVAILABLE
;
195 /******************************************************************
196 * DllGetVersion [MSI.@]
198 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*pdvi
)
202 if (pdvi
->cbSize
< sizeof(DLLVERSIONINFO
))
205 pdvi
->dwMajorVersion
= MSI_MAJORVERSION
;
206 pdvi
->dwMinorVersion
= MSI_MINORVERSION
;
207 pdvi
->dwBuildNumber
= MSI_BUILDNUMBER
;
208 pdvi
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
213 /******************************************************************
214 * DllCanUnloadNow [MSI.@]
216 HRESULT WINAPI
DllCanUnloadNow(void)
218 return dll_count
== 0 ? S_OK
: S_FALSE
;
221 /***********************************************************************
222 * DllRegisterServer (MSI.@)
224 HRESULT WINAPI
DllRegisterServer(void)
226 return __wine_register_resources( msi_hInstance
);
229 /***********************************************************************
230 * DllUnregisterServer (MSI.@)
232 HRESULT WINAPI
DllUnregisterServer(void)
234 return __wine_unregister_resources( msi_hInstance
);