2 * INSENG Implementation
4 * Copyright 2006 Mike McCormack
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
33 //#include "winuser.h"
39 #include <wine/debug.h>
41 WINE_DEFAULT_DEBUG_CHANNEL(inseng
);
43 static inline void *heap_alloc(size_t len
)
45 return HeapAlloc(GetProcessHeap(), 0, len
);
48 static inline BOOL
heap_free(void *mem
)
50 return HeapFree(GetProcessHeap(), 0, mem
);
53 static HINSTANCE instance
;
55 struct InstallEngine
{
56 IInstallEngine2 IInstallEngine2_iface
;
60 static inline InstallEngine
*impl_from_IInstallEngine2(IInstallEngine2
*iface
)
62 return CONTAINING_RECORD(iface
, InstallEngine
, IInstallEngine2_iface
);
65 static HRESULT WINAPI
InstallEngine_QueryInterface(IInstallEngine2
*iface
, REFIID riid
, void **ppv
)
67 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
69 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
70 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
71 *ppv
= &This
->IInstallEngine2_iface
;
72 }else if(IsEqualGUID(&IID_IInstallEngine
, riid
)) {
73 TRACE("(%p)->(IID_IInstallEngine %p)\n", This
, ppv
);
74 *ppv
= &This
->IInstallEngine2_iface
;
75 }else if(IsEqualGUID(&IID_IInstallEngine2
, riid
)) {
76 TRACE("(%p)->(IID_IInstallEngine2 %p)\n", This
, ppv
);
77 *ppv
= &This
->IInstallEngine2_iface
;
79 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
84 IUnknown_AddRef((IUnknown
*)*ppv
);
88 static ULONG WINAPI
InstallEngine_AddRef(IInstallEngine2
*iface
)
90 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
91 LONG ref
= InterlockedIncrement(&This
->ref
);
93 TRACE("(%p) ref=%d\n", This
, ref
);
98 static ULONG WINAPI
InstallEngine_Release(IInstallEngine2
*iface
)
100 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
101 LONG ref
= InterlockedDecrement(&This
->ref
);
103 TRACE("(%p) ref=%d\n", This
, ref
);
111 static HRESULT WINAPI
InstallEngine_GetEngineStatus(IInstallEngine2
*iface
, DWORD
*status
)
113 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
114 FIXME("(%p)->(%p)\n", This
, status
);
118 static HRESULT WINAPI
InstallEngine_SetCifFile(IInstallEngine2
*iface
, const char *cab_name
, const char *cif_name
)
120 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
121 FIXME("(%p)->(%s %s)\n", This
, debugstr_a(cab_name
), debugstr_a(cif_name
));
125 static HRESULT WINAPI
InstallEngine_DownloadComponents(IInstallEngine2
*iface
, DWORD flags
)
127 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
128 FIXME("(%p)->(%x)\n", This
, flags
);
132 static HRESULT WINAPI
InstallEngine_InstallComponents(IInstallEngine2
*iface
, DWORD flags
)
134 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
135 FIXME("(%p)->(%x)\n", This
, flags
);
139 static HRESULT WINAPI
InstallEngine_EnumInstallIDs(IInstallEngine2
*iface
, UINT index
, char **id
)
141 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
142 FIXME("(%p)->(%d %p)\n", This
, index
, id
);
146 static HRESULT WINAPI
InstallEngine_EnumDownloadIDs(IInstallEngine2
*iface
, UINT index
, char **id
)
148 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
149 FIXME("(%p)->(%d %p)\n", This
, index
, id
);
153 static HRESULT WINAPI
InstallEngine_IsComponentInstalled(IInstallEngine2
*iface
, const char *id
, DWORD
*status
)
155 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
156 FIXME("(%p)->(%s %p)\n", This
, debugstr_a(id
), status
);
160 static HRESULT WINAPI
InstallEngine_RegisterInstallEngineCallback(IInstallEngine2
*iface
, IInstallEngineCallback
*callback
)
162 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
163 FIXME("(%p)->(%p)\n", This
, callback
);
167 static HRESULT WINAPI
InstallEngine_UnregisterInstallEngineCallback(IInstallEngine2
*iface
)
169 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
170 FIXME("(%p)\n", This
);
174 static HRESULT WINAPI
InstallEngine_SetAction(IInstallEngine2
*iface
, const char *id
, DWORD action
, DWORD priority
)
176 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
177 FIXME("(%p)->(%s %d %d)\n", This
, debugstr_a(id
), action
, priority
);
181 static HRESULT WINAPI
InstallEngine_GetSizes(IInstallEngine2
*iface
, const char *id
, COMPONENT_SIZES
*sizes
)
183 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
184 FIXME("(%p)->(%s %p)\n", This
, debugstr_a(id
), sizes
);
188 static HRESULT WINAPI
InstallEngine_LaunchExtraCommand(IInstallEngine2
*iface
, const char *inf_name
, const char *section
)
190 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
191 FIXME("(%p)->(%s %s)\n", This
, debugstr_a(inf_name
), debugstr_a(section
));
195 static HRESULT WINAPI
InstallEngine_GetDisplayName(IInstallEngine2
*iface
, const char *id
, const char *name
)
197 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
198 FIXME("(%p)->(%s %s)\n", This
, debugstr_a(id
), debugstr_a(name
));
202 static HRESULT WINAPI
InstallEngine_SetBaseUrl(IInstallEngine2
*iface
, const char *base_name
)
204 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
205 FIXME("(%p)->(%s)\n", This
, debugstr_a(base_name
));
209 static HRESULT WINAPI
InstallEngine_SetDownloadDir(IInstallEngine2
*iface
, const char *download_dir
)
211 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
212 FIXME("(%p)->(%s)\n", This
, debugstr_a(download_dir
));
216 static HRESULT WINAPI
InstallEngine_SetInstallDrive(IInstallEngine2
*iface
, char drive
)
218 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
219 FIXME("(%p)->(%c)\n", This
, drive
);
223 static HRESULT WINAPI
InstallEngine_SetInstallOptions(IInstallEngine2
*iface
, DWORD flags
)
225 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
226 FIXME("(%p)->(%x)\n", This
, flags
);
230 static HRESULT WINAPI
InstallEngine_SetHWND(IInstallEngine2
*iface
, HWND hwnd
)
232 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
233 FIXME("(%p)->(%p)\n", This
, hwnd
);
237 static HRESULT WINAPI
InstallEngine_SetIStream(IInstallEngine2
*iface
, IStream
*stream
)
239 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
240 FIXME("(%p)->(%p)\n", This
, stream
);
244 static HRESULT WINAPI
InstallEngine_Abort(IInstallEngine2
*iface
, DWORD flags
)
246 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
247 FIXME("(%p)->(%x)\n", This
, flags
);
251 static HRESULT WINAPI
InstallEngine_Suspend(IInstallEngine2
*iface
)
253 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
254 FIXME("(%p)\n", This
);
258 static HRESULT WINAPI
InstallEngine_Resume(IInstallEngine2
*iface
)
260 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
261 FIXME("(%p)\n", This
);
265 static HRESULT WINAPI
InstallEngine2_SetLocalCif(IInstallEngine2
*iface
, const char *cif
)
267 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
268 FIXME("(%p)->(%s)\n", This
, debugstr_a(cif
));
272 static HRESULT WINAPI
InstallEngine2_GetICifFile(IInstallEngine2
*iface
, ICifFile
**cif_file
)
274 InstallEngine
*This
= impl_from_IInstallEngine2(iface
);
275 FIXME("(%p)->(%p)\n", This
, cif_file
);
279 static const IInstallEngine2Vtbl InstallEngine2Vtbl
= {
280 InstallEngine_QueryInterface
,
281 InstallEngine_AddRef
,
282 InstallEngine_Release
,
283 InstallEngine_GetEngineStatus
,
284 InstallEngine_SetCifFile
,
285 InstallEngine_DownloadComponents
,
286 InstallEngine_InstallComponents
,
287 InstallEngine_EnumInstallIDs
,
288 InstallEngine_EnumDownloadIDs
,
289 InstallEngine_IsComponentInstalled
,
290 InstallEngine_RegisterInstallEngineCallback
,
291 InstallEngine_UnregisterInstallEngineCallback
,
292 InstallEngine_SetAction
,
293 InstallEngine_GetSizes
,
294 InstallEngine_LaunchExtraCommand
,
295 InstallEngine_GetDisplayName
,
296 InstallEngine_SetBaseUrl
,
297 InstallEngine_SetDownloadDir
,
298 InstallEngine_SetInstallDrive
,
299 InstallEngine_SetInstallOptions
,
300 InstallEngine_SetHWND
,
301 InstallEngine_SetIStream
,
303 InstallEngine_Suspend
,
304 InstallEngine_Resume
,
305 InstallEngine2_SetLocalCif
,
306 InstallEngine2_GetICifFile
309 static HRESULT WINAPI
ClassFactory_QueryInterface(IClassFactory
*iface
, REFIID riid
, void **ppv
)
313 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
314 TRACE("(%p)->(IID_IUnknown %p)\n", iface
, ppv
);
316 }else if(IsEqualGUID(&IID_IClassFactory
, riid
)) {
317 TRACE("(%p)->(IID_IClassFactory %p)\n", iface
, ppv
);
322 IUnknown_AddRef((IUnknown
*)*ppv
);
326 FIXME("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
327 return E_NOINTERFACE
;
330 static ULONG WINAPI
ClassFactory_AddRef(IClassFactory
*iface
)
335 static ULONG WINAPI
ClassFactory_Release(IClassFactory
*iface
)
340 static HRESULT WINAPI
ClassFactory_LockServer(IClassFactory
*iface
, BOOL fLock
)
345 static HRESULT WINAPI
InstallEngineCF_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
,
346 REFIID riid
, void **ppv
)
348 InstallEngine
*engine
;
351 TRACE("(%p %s %p)\n", outer
, debugstr_guid(riid
), ppv
);
353 engine
= heap_alloc(sizeof(*engine
));
355 return E_OUTOFMEMORY
;
357 engine
->IInstallEngine2_iface
.lpVtbl
= &InstallEngine2Vtbl
;
360 hres
= IInstallEngine2_QueryInterface(&engine
->IInstallEngine2_iface
, riid
, ppv
);
361 IInstallEngine2_Release(&engine
->IInstallEngine2_iface
);
365 static const IClassFactoryVtbl InstallEngineCFVtbl
= {
366 ClassFactory_QueryInterface
,
368 ClassFactory_Release
,
369 InstallEngineCF_CreateInstance
,
370 ClassFactory_LockServer
373 static IClassFactory InstallEngineCF
= { &InstallEngineCFVtbl
};
375 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
379 case DLL_WINE_PREATTACH
:
380 return FALSE
; /* prefer native version */
381 case DLL_PROCESS_ATTACH
:
383 DisableThreadLibraryCalls(hInstDLL
);
389 /***********************************************************************
390 * DllGetClassObject (INSENG.@)
392 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
394 if(IsEqualGUID(rclsid
, &CLSID_InstallEngine
)) {
395 TRACE("(CLSID_InstallEngine %s %p)\n", debugstr_guid(iid
), ppv
);
396 return IClassFactory_QueryInterface(&InstallEngineCF
, iid
, ppv
);
399 FIXME("(%s %s %p)\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
400 return CLASS_E_CLASSNOTAVAILABLE
;
403 /***********************************************************************
404 * DllCanUnloadNow (INSENG.@)
406 HRESULT WINAPI
DllCanUnloadNow(void)
411 /***********************************************************************
412 * DllRegisterServer (INSENG.@)
414 HRESULT WINAPI
DllRegisterServer(void)
416 return __wine_register_resources( instance
);
419 /***********************************************************************
420 * DllUnregisterServer (INSENG.@)
422 HRESULT WINAPI
DllUnregisterServer(void)
424 return __wine_unregister_resources( instance
);
427 BOOL WINAPI
CheckTrustEx( LPVOID a
, LPVOID b
, LPVOID c
, LPVOID d
, LPVOID e
)
429 FIXME("%p %p %p %p %p\n", a
, b
, c
, d
, e
);
433 /***********************************************************************
434 * DllInstall (INSENG.@)
436 HRESULT WINAPI
DllInstall(BOOL bInstall
, LPCWSTR cmdline
)
438 FIXME("(%s, %s): stub\n", bInstall
? "TRUE" : "FALSE", debugstr_w(cmdline
));