ReactOS 0.4.16-dev-340-g0540c21
msi_main.c
Go to the documentation of this file.
1/*
2 * Implementation of the Microsoft Installer (msi.dll)
3 *
4 * Copyright 2006 Mike McCormack for CodeWeavers
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include <stdarg.h>
22
23#define COBJMACROS
24
25#include "windef.h"
26#include "winbase.h"
27#include "winreg.h"
28#include "shlwapi.h"
29#include "oleauto.h"
30#include "rpcproxy.h"
31#include "msipriv.h"
32#include "msiserver.h"
33
34#include "wine/debug.h"
35
37
39
40/* the UI level */
52
53
54/*
55 * Dll lifetime tracking declaration
56 */
57static void LockModule(void)
58{
60}
61
62static void UnlockModule(void)
63{
65}
66
67/******************************************************************
68 * DllMain
69 */
71{
72 switch (fdwReason)
73 {
75 msi_hInstance = hinstDLL;
78 break;
80 if (lpvReserved) break;
85 break;
86 }
87 return TRUE;
88}
89
90struct class_factory
91{
93 HRESULT (*create_object)( IUnknown *, void ** );
94};
95
97{
99}
100
101static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
102 REFIID riid,LPVOID *ppobj)
103{
105
106 TRACE("%p %s %p\n",This,debugstr_guid(riid),ppobj);
107
108 if( IsEqualCLSID( riid, &IID_IUnknown ) ||
110 {
111 IClassFactory_AddRef( iface );
112 *ppobj = iface;
113 return S_OK;
114 }
115 return E_NOINTERFACE;
116}
117
118static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
119{
120 LockModule();
121 return 2;
122}
123
124static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
125{
126 UnlockModule();
127 return 1;
128}
129
130static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface,
131 LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
132{
134 IUnknown *unk = NULL;
135 HRESULT r;
136
137 TRACE("%p %p %s %p\n", This, pOuter, debugstr_guid(riid), ppobj);
138
139 r = This->create_object( pOuter, (LPVOID*) &unk );
140 if (SUCCEEDED(r))
141 {
142 r = IUnknown_QueryInterface( unk, riid, ppobj );
143 IUnknown_Release( unk );
144 }
145 return r;
146}
147
148static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
149{
150 TRACE("%p %d\n", iface, dolock);
151
152 if (dolock)
153 LockModule();
154 else
155 UnlockModule();
156
157 return S_OK;
158}
159
160static const IClassFactoryVtbl MsiCF_Vtbl =
161{
167};
168
170
171/******************************************************************
172 * DllGetClassObject [MSI.@]
173 */
175{
176 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
177
178 if ( IsEqualCLSID (rclsid, &CLSID_MsiInstaller) )
179 {
180 *ppv = &MsiServer_CF;
181 return S_OK;
182 }
183
184 if( IsEqualCLSID (rclsid, &CLSID_MsiServerMessage) ||
185 IsEqualCLSID (rclsid, &CLSID_MsiServer) ||
186 IsEqualCLSID (rclsid, &CLSID_PSFactoryBuffer) ||
187 IsEqualCLSID (rclsid, &CLSID_MsiServerX3) )
188 {
189 FIXME("create %s object\n", debugstr_guid( rclsid ));
190 }
191
193}
194
195/******************************************************************
196 * DllGetVersion [MSI.@]
197 */
199{
200 TRACE("%p\n",pdvi);
201
202 if (pdvi->cbSize < sizeof(DLLVERSIONINFO))
203 return E_INVALIDARG;
204
209
210 return S_OK;
211}
212
213/******************************************************************
214 * DllCanUnloadNow [MSI.@]
215 */
217{
218 return dll_count == 0 ? S_OK : S_FALSE;
219}
void release_typelib(void)
Definition: apps.c:159
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_INVALIDARG
Definition: ddrawi.h:101
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define GetCurrentProcess()
Definition: compat.h:759
#define IsWow64Process
Definition: compat.h:760
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
HRESULT create_msiserver(IUnknown *outer, void **ppObj)
Definition: automation.c:2423
void msi_dialog_unregister_class(void)
Definition: dialog.c:4098
void msi_free_handle_table(void)
Definition: handle.c:71
BOOL is_wow64
Definition: msi.c:52
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_guid
Definition: kernel32.h:35
static IN DWORD IN LPVOID lpvReserved
INT(CALLBACK * INSTALLUI_HANDLERW)(LPVOID, UINT, LPCWSTR)
Definition: msi.h:421
INT(CALLBACK * INSTALLUI_HANDLERA)(LPVOID, UINT, LPCSTR)
Definition: msi.h:420
INT(CALLBACK * INSTALLUI_HANDLER_RECORD)(LPVOID, UINT, MSIHANDLE)
Definition: msi.h:422
enum tagINSTALLUILEVEL INSTALLUILEVEL
@ INSTALLUILEVEL_DEFAULT
Definition: msi.h:65
HINSTANCE msi_hInstance
Definition: msi_main.c:51
WCHAR * gszLogFile
Definition: msi_main.c:50
INSTALLUI_HANDLERA gUIHandlerA
Definition: msi_main.c:43
DWORD gUIFilter
Definition: msi_main.c:46
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: msi_main.c:70
static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
Definition: msi_main.c:118
LPVOID gUIContextRecord
Definition: msi_main.c:49
DWORD gUIFilterRecord
Definition: msi_main.c:47
static void UnlockModule(void)
Definition: msi_main.c:62
INSTALLUILEVEL gUILevel
Definition: msi_main.c:41
static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
Definition: msi_main.c:124
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: msi_main.c:174
static struct class_factory MsiServer_CF
Definition: msi_main.c:169
LPVOID gUIContext
Definition: msi_main.c:48
HWND gUIhwnd
Definition: msi_main.c:42
static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
Definition: msi_main.c:101
static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
Definition: msi_main.c:148
static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
Definition: msi_main.c:130
static const IClassFactoryVtbl MsiCF_Vtbl
Definition: msi_main.c:160
INSTALLUI_HANDLER_RECORD gUIHandlerRecord
Definition: msi_main.c:45
HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *pdvi)
Definition: msi_main.c:198
HRESULT WINAPI DllCanUnloadNow(void)
Definition: msi_main.c:216
static void LockModule(void)
Definition: msi_main.c:57
INSTALLUI_HANDLERW gUIHandlerW
Definition: msi_main.c:44
static LONG dll_count
Definition: msi_main.c:38
static struct class_factory * impl_from_IClassFactory(IClassFactory *iface)
Definition: msi_main.c:96
#define MSI_MINORVERSION
Definition: msipriv.h:730
#define MSI_BUILDNUMBER
Definition: msipriv.h:731
#define MSI_MAJORVERSION
Definition: msipriv.h:729
static LPUNKNOWN
Definition: ndr_ole.c:49
long LONG
Definition: pedump.c:60
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
#define DLLVER_PLATFORM_WINDOWS
Definition: shlwapi.h:1989
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwMajorVersion
Definition: shlwapi.h:1983
DWORD dwBuildNumber
Definition: shlwapi.h:1985
DWORD dwMinorVersion
Definition: shlwapi.h:1984
DWORD dwPlatformID
Definition: shlwapi.h:1986
HRESULT(* create_object)(IUnknown *, void **)
Definition: msi_main.c:93
IClassFactory IClassFactory_iface
Definition: devenum_main.c:53
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
__wchar_t WCHAR
Definition: xmlstorage.h:180