ReactOS  0.4.13-dev-73-gcfe54aa
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 
38 static LONG dll_count;
39 
40 /* the UI level */
52 
53 
54 /*
55  * Dll lifetime tracking declaration
56  */
57 static void LockModule(void)
58 {
60 }
61 
62 static void UnlockModule(void)
63 {
65 }
66 
67 /******************************************************************
68  * DllMain
69  */
71 {
72  switch (fdwReason)
73  {
74  case DLL_PROCESS_ATTACH:
75  msi_hInstance = hinstDLL;
76  DisableThreadLibraryCalls(hinstDLL);
78  break;
79  case DLL_PROCESS_DETACH:
80  if (lpvReserved) break;
85  break;
86  }
87  return TRUE;
88 }
89 
90 typedef struct tagIClassFactoryImpl {
94 
96 {
97  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
98 }
99 
100 static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
101  REFIID riid,LPVOID *ppobj)
102 {
104 
105  TRACE("%p %s %p\n",This,debugstr_guid(riid),ppobj);
106 
107  if( IsEqualCLSID( riid, &IID_IUnknown ) ||
109  {
110  IClassFactory_AddRef( iface );
111  *ppobj = iface;
112  return S_OK;
113  }
114  return E_NOINTERFACE;
115 }
116 
117 static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
118 {
119  LockModule();
120  return 2;
121 }
122 
123 static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
124 {
125  UnlockModule();
126  return 1;
127 }
128 
129 static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface,
130  LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
131 {
133  IUnknown *unk = NULL;
134  HRESULT r;
135 
136  TRACE("%p %p %s %p\n", This, pOuter, debugstr_guid(riid), ppobj);
137 
138  r = This->create_object( pOuter, (LPVOID*) &unk );
139  if (SUCCEEDED(r))
140  {
141  r = IUnknown_QueryInterface( unk, riid, ppobj );
142  IUnknown_Release( unk );
143  }
144  return r;
145 }
146 
147 static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
148 {
149  TRACE("%p %d\n", iface, dolock);
150 
151  if (dolock)
152  LockModule();
153  else
154  UnlockModule();
155 
156  return S_OK;
157 }
158 
159 static const IClassFactoryVtbl MsiCF_Vtbl =
160 {
162  MsiCF_AddRef,
166 };
167 
171 
172 /******************************************************************
173  * DllGetClassObject [MSI.@]
174  */
176 {
177  TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
178 
179  if ( IsEqualCLSID (rclsid, &CLSID_MsiInstaller) )
180  {
181  *ppv = &MsiServer_CF;
182  return S_OK;
183  }
184 
185  if ( IsEqualCLSID (rclsid, &CLSID_WineMsiRemoteCustomAction) )
186  {
188  return S_OK;
189  }
190 
191  if ( IsEqualCLSID (rclsid, &CLSID_WineMsiRemotePackage) )
192  {
194  return S_OK;
195  }
196 
197  if( IsEqualCLSID (rclsid, &CLSID_MsiServerMessage) ||
198  IsEqualCLSID (rclsid, &CLSID_MsiServer) ||
199  IsEqualCLSID (rclsid, &CLSID_PSFactoryBuffer) ||
200  IsEqualCLSID (rclsid, &CLSID_MsiServerX3) )
201  {
202  FIXME("create %s object\n", debugstr_guid( rclsid ));
203  }
204 
206 }
207 
208 /******************************************************************
209  * DllGetVersion [MSI.@]
210  */
212 {
213  TRACE("%p\n",pdvi);
214 
215  if (pdvi->cbSize < sizeof(DLLVERSIONINFO))
216  return E_INVALIDARG;
217 
222 
223  return S_OK;
224 }
225 
226 /******************************************************************
227  * DllCanUnloadNow [MSI.@]
228  */
230 {
231  return dll_count == 0 ? S_OK : S_FALSE;
232 }
233 
234 /***********************************************************************
235  * DllRegisterServer (MSI.@)
236  */
238 {
240 }
241 
242 /***********************************************************************
243  * DllUnregisterServer (MSI.@)
244  */
246 {
248 }
#define HRESULT
Definition: msvc.h:9
static ULONG WINAPI MsiCF_AddRef(LPCLASSFACTORY iface)
Definition: msi_main.c:117
DWORD dwMinorVersion
Definition: shlwapi.h:1956
#define REFIID
Definition: guiddef.h:113
#define TRUE
Definition: types.h:120
static IClassFactoryImpl MsiServer_CF
Definition: msi_main.c:168
static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
Definition: msi_main.c:100
#define E_NOINTERFACE
Definition: winerror.h:2364
HRESULT create_msi_remote_package(IUnknown *pOuter, LPVOID *ppObj) DECLSPEC_HIDDEN
Definition: package.c:2783
static HRESULT WINAPI MsiCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
Definition: msi_main.c:147
HRESULT WINAPI DllCanUnloadNow(void)
Definition: msi_main.c:229
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
enum tagINSTALLUILEVEL INSTALLUILEVEL
REFIID riid
Definition: precomp.h:44
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define REFCLSID
Definition: guiddef.h:112
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
Definition: msi_main.c:175
static void UnlockModule(void)
Definition: msi_main.c:62
HRESULT WINAPI DllGetVersion(DLLVERSIONINFO *pdvi)
Definition: msi_main.c:211
REFIID LPVOID * ppv
Definition: atlbase.h:39
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
INSTALLUI_HANDLERW gUIHandlerW
Definition: msi_main.c:44
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
#define MSI_BUILDNUMBER
Definition: msipriv.h:708
INSTALLUILEVEL gUILevel
Definition: msi_main.c:41
INT(CALLBACK * INSTALLUI_HANDLER_RECORD)(LPVOID, UINT, MSIHANDLE)
Definition: msi.h:422
static HRESULT WINAPI MsiCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter, REFIID riid, LPVOID *ppobj)
Definition: msi_main.c:129
static IClassFactoryImpl WineMsiRemotePackage_CF
Definition: msi_main.c:170
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
static IN DWORD IN LPVOID lpvReserved
struct tagIClassFactoryImpl IClassFactoryImpl
static const IClassFactoryVtbl MsiCF_Vtbl
Definition: msi_main.c:159
HRESULT create_msiserver(IUnknown *outer, void **ppObj)
Definition: automation.c:2443
DWORD dwBuildNumber
Definition: shlwapi.h:1957
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
static LPUNKNOWN
Definition: ndr_ole.c:49
void msi_free_handle_table(void)
Definition: handle.c:69
#define FIXME(fmt,...)
Definition: debug.h:110
HRESULT WINAPI DllUnregisterServer(void)
Definition: msi_main.c:245
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
INSTALLUI_HANDLER_RECORD gUIHandlerRecord
Definition: msi_main.c:45
DWORD dwMajorVersion
Definition: shlwapi.h:1955
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define DLL_PROCESS_DETACH
Definition: compat.h:119
static ULONG WINAPI MsiCF_Release(LPCLASSFACTORY iface)
Definition: msi_main.c:123
void msi_dialog_unregister_class(void)
Definition: dialog.c:4091
BOOL WINAPI IsWow64Process(IN HANDLE hProcess, OUT PBOOL Wow64Process)
Definition: proc.c:2004
HRESULT create_msi_custom_remote(IUnknown *pOuter, LPVOID *ppObj)
Definition: custom.c:1460
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
LPVOID gUIContext
Definition: msi_main.c:48
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
HANDLE WINAPI GetCurrentProcess(VOID)
Definition: proc.c:1168
static BOOL is_wow64
Definition: loader.c:55
#define WINAPI
Definition: msvc.h:8
HINSTANCE msi_hInstance
Definition: msi_main.c:51
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR * gszLogFile
Definition: msi_main.c:50
HWND gUIhwnd
Definition: msi_main.c:42
INSTALLUI_HANDLERA gUIHandlerA
Definition: msi_main.c:43
void release_typelib(void)
Definition: apps.c:155
LPVOID gUIContextRecord
Definition: msi_main.c:49
WINE_DEFAULT_DEBUG_CHANNEL(msi)
#define InterlockedDecrement
Definition: armddk.h:52
HRESULT WINAPI DllRegisterServer(void)
Definition: msi_main.c:237
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
DWORD dwPlatformID
Definition: shlwapi.h:1958
static void LockModule(void)
Definition: msi_main.c:57
#define MSI_MAJORVERSION
Definition: msipriv.h:706
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: msi_main.c:95
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Definition: msi_main.c:70
INT(CALLBACK * INSTALLUI_HANDLERA)(LPVOID, UINT, LPCSTR)
Definition: msi.h:420
#define S_OK
Definition: intsafe.h:59
#define InterlockedIncrement
Definition: armddk.h:53
HRESULT(* create_object)(IUnknown *, LPVOID *)
Definition: msi_main.c:92
static LONG dll_count
Definition: msi_main.c:38
DWORD gUIFilterRecord
Definition: msi_main.c:47
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
#define MSI_MINORVERSION
Definition: msipriv.h:707
unsigned int ULONG
Definition: retypes.h:1
INT(CALLBACK * INSTALLUI_HANDLERW)(LPVOID, UINT, LPCWSTR)
Definition: msi.h:421
IClassFactory IClassFactory_iface
Definition: msi_main.c:91
const GUID IID_IClassFactory
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:91
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static IClassFactoryImpl WineMsiCustomRemote_CF
Definition: msi_main.c:169
#define DLLVER_PLATFORM_WINDOWS
Definition: shlwapi.h:1961
DWORD gUIFilter
Definition: msi_main.c:46