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
21 #define WIN32_NO_STATUS
23 #define COM_NO_WINDOWS_H
28 #define NONAMELESSUNION
34 //#include "oleauto.h"
37 #include <msiserver.h>
39 #include <wine/debug.h>
41 WINE_DEFAULT_DEBUG_CHANNEL(msi
);
43 static LONG dll_count
;
46 INSTALLUILEVEL gUILevel
= INSTALLUILEVEL_BASIC
;
48 INSTALLUI_HANDLERA gUIHandlerA
= NULL
;
49 INSTALLUI_HANDLERW gUIHandlerW
= NULL
;
50 INSTALLUI_HANDLER_RECORD gUIHandlerRecord
= NULL
;
52 LPVOID gUIContext
= NULL
;
53 WCHAR
*gszLogFile
= NULL
;
54 HINSTANCE msi_hInstance
;
58 * Dll lifetime tracking declaration
60 static void LockModule(void)
62 InterlockedIncrement(&dll_count
);
65 static void UnlockModule(void)
67 InterlockedDecrement(&dll_count
);
70 /******************************************************************
73 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
77 case DLL_PROCESS_ATTACH
:
78 msi_hInstance
= hinstDLL
;
79 DisableThreadLibraryCalls(hinstDLL
);
80 IsWow64Process( GetCurrentProcess(), &is_wow64
);
82 case DLL_PROCESS_DETACH
:
83 if (lpvReserved
) break;
84 msi_dialog_unregister_class();
85 msi_free_handle_table();
86 msi_free( gszLogFile
);
93 typedef struct tagIClassFactoryImpl
{
94 IClassFactory IClassFactory_iface
;
95 HRESULT (*create_object
)( IUnknown
*, LPVOID
* );
98 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
100 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
103 static HRESULT WINAPI
MsiCF_QueryInterface(LPCLASSFACTORY iface
,
104 REFIID riid
,LPVOID
*ppobj
)
106 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
108 TRACE("%p %s %p\n",This
,debugstr_guid(riid
),ppobj
);
110 if( IsEqualCLSID( riid
, &IID_IUnknown
) ||
111 IsEqualCLSID( riid
, &IID_IClassFactory
) )
113 IClassFactory_AddRef( iface
);
117 return E_NOINTERFACE
;
120 static ULONG WINAPI
MsiCF_AddRef(LPCLASSFACTORY iface
)
126 static ULONG WINAPI
MsiCF_Release(LPCLASSFACTORY iface
)
132 static HRESULT WINAPI
MsiCF_CreateInstance(LPCLASSFACTORY iface
,
133 LPUNKNOWN pOuter
, REFIID riid
, LPVOID
*ppobj
)
135 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
136 IUnknown
*unk
= NULL
;
139 TRACE("%p %p %s %p\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
141 r
= This
->create_object( pOuter
, (LPVOID
*) &unk
);
144 r
= IUnknown_QueryInterface( unk
, riid
, ppobj
);
145 IUnknown_Release( unk
);
150 static HRESULT WINAPI
MsiCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
152 TRACE("%p %d\n", iface
, dolock
);
162 static const IClassFactoryVtbl MsiCF_Vtbl
=
164 MsiCF_QueryInterface
,
167 MsiCF_CreateInstance
,
171 static IClassFactoryImpl MsiServer_CF
= { { &MsiCF_Vtbl
}, create_msiserver
};
172 static IClassFactoryImpl WineMsiCustomRemote_CF
= { { &MsiCF_Vtbl
}, create_msi_custom_remote
};
173 static IClassFactoryImpl WineMsiRemotePackage_CF
= { { &MsiCF_Vtbl
}, create_msi_remote_package
};
175 /******************************************************************
176 * DllGetClassObject [MSI.@]
178 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
180 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
182 if ( IsEqualCLSID (rclsid
, &CLSID_MsiInstaller
) )
184 *ppv
= &MsiServer_CF
;
188 if ( IsEqualCLSID (rclsid
, &CLSID_WineMsiRemoteCustomAction
) )
190 *ppv
= &WineMsiCustomRemote_CF
;
194 if ( IsEqualCLSID (rclsid
, &CLSID_WineMsiRemotePackage
) )
196 *ppv
= &WineMsiRemotePackage_CF
;
200 if( IsEqualCLSID (rclsid
, &CLSID_MsiServerMessage
) ||
201 IsEqualCLSID (rclsid
, &CLSID_MsiServer
) ||
202 IsEqualCLSID (rclsid
, &CLSID_PSFactoryBuffer
) ||
203 IsEqualCLSID (rclsid
, &CLSID_MsiServerX3
) )
205 FIXME("create %s object\n", debugstr_guid( rclsid
));
208 return CLASS_E_CLASSNOTAVAILABLE
;
211 /******************************************************************
212 * DllGetVersion [MSI.@]
214 HRESULT WINAPI
DllGetVersion(DLLVERSIONINFO
*pdvi
)
218 if (pdvi
->cbSize
< sizeof(DLLVERSIONINFO
))
221 pdvi
->dwMajorVersion
= MSI_MAJORVERSION
;
222 pdvi
->dwMinorVersion
= MSI_MINORVERSION
;
223 pdvi
->dwBuildNumber
= MSI_BUILDNUMBER
;
224 pdvi
->dwPlatformID
= DLLVER_PLATFORM_WINDOWS
;
229 /******************************************************************
230 * DllCanUnloadNow [MSI.@]
232 HRESULT WINAPI
DllCanUnloadNow(void)
234 return dll_count
== 0 ? S_OK
: S_FALSE
;
237 /***********************************************************************
238 * DllRegisterServer (MSI.@)
240 HRESULT WINAPI
DllRegisterServer(void)
242 return __wine_register_resources( msi_hInstance
);
245 /***********************************************************************
246 * DllUnregisterServer (MSI.@)
248 HRESULT WINAPI
DllUnregisterServer(void)
250 return __wine_unregister_resources( msi_hInstance
);