4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2004 Mike McCormack
7 * see http://bonedaddy.net/pabs3/hhm/#chmspec
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
45 #include "wine/itss.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(itss
);
49 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
52 static HINSTANCE hInst
;
54 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
57 case DLL_PROCESS_ATTACH
:
58 DisableThreadLibraryCalls(hInstDLL
);
65 /******************************************************************************
69 IClassFactory IClassFactory_iface
;
70 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
73 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
75 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
79 ITSSCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
81 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
83 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
84 IsEqualGUID(riid
, &IID_IClassFactory
))
86 IClassFactory_AddRef(iface
);
87 *ppobj
= &This
->IClassFactory_iface
;
91 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
95 static ULONG WINAPI
ITSSCF_AddRef(LPCLASSFACTORY iface
)
101 static ULONG WINAPI
ITSSCF_Release(LPCLASSFACTORY iface
)
108 static HRESULT WINAPI
ITSSCF_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
,
109 REFIID riid
, void **ppv
)
111 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
115 TRACE("(%p)->(%p %s %p)\n", This
, outer
, debugstr_guid(riid
), ppv
);
117 if(outer
&& !IsEqualGUID(riid
, &IID_IUnknown
)) {
119 return CLASS_E_NOAGGREGATION
;
122 hres
= This
->pfnCreateInstance(outer
, (void**)&unk
);
128 if(!IsEqualGUID(riid
, &IID_IUnknown
)) {
129 hres
= IUnknown_QueryInterface(unk
, riid
, ppv
);
130 IUnknown_Release(unk
);
137 static HRESULT WINAPI
ITSSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
139 TRACE("(%p)->(%d)\n", iface
, dolock
);
149 static const IClassFactoryVtbl ITSSCF_Vtbl
=
151 ITSSCF_QueryInterface
,
154 ITSSCF_CreateInstance
,
158 static const IClassFactoryImpl ITStorage_factory
= { { &ITSSCF_Vtbl
}, ITSS_create
};
159 static const IClassFactoryImpl MSITStore_factory
= { { &ITSSCF_Vtbl
}, ITS_IParseDisplayName_create
};
160 static const IClassFactoryImpl ITSProtocol_factory
= { { &ITSSCF_Vtbl
}, ITSProtocol_create
};
162 /***********************************************************************
163 * DllGetClassObject (ITSS.@)
165 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
167 const IClassFactoryImpl
*factory
;
169 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
171 if (IsEqualGUID(&CLSID_ITStorage
, rclsid
))
172 factory
= &ITStorage_factory
;
173 else if (IsEqualGUID(&CLSID_MSITStore
, rclsid
))
174 factory
= &MSITStore_factory
;
175 else if (IsEqualGUID(&CLSID_ITSProtocol
, rclsid
))
176 factory
= &ITSProtocol_factory
;
179 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
180 return CLASS_E_CLASSNOTAVAILABLE
;
183 return IUnknown_QueryInterface( (IUnknown
*) factory
, iid
, ppv
);
186 /*****************************************************************************/
189 IITStorage IITStorage_iface
;
193 static inline ITStorageImpl
*impl_from_IITStorage(IITStorage
*iface
)
195 return CONTAINING_RECORD(iface
, ITStorageImpl
, IITStorage_iface
);
199 static HRESULT WINAPI
ITStorageImpl_QueryInterface(
204 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
205 if (IsEqualGUID(riid
, &IID_IUnknown
)
206 || IsEqualGUID(riid
, &IID_IITStorage
))
208 IITStorage_AddRef(iface
);
213 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
214 return E_NOINTERFACE
;
217 static ULONG WINAPI
ITStorageImpl_AddRef(
220 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
222 return InterlockedIncrement(&This
->ref
);
225 static ULONG WINAPI
ITStorageImpl_Release(
228 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
229 ULONG ref
= InterlockedDecrement(&This
->ref
);
232 HeapFree(GetProcessHeap(), 0, This
);
239 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfile(
241 const WCHAR
* pwcsName
,
244 IStorage
** ppstgOpen
)
246 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
248 TRACE("%p %s %u %u %p\n", This
,
249 debugstr_w(pwcsName
), grfMode
, reserved
, ppstgOpen
);
251 return ITSS_StgOpenStorage( pwcsName
, NULL
, grfMode
,
252 0, reserved
, ppstgOpen
);
255 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfileOnILockBytes(
260 IStorage
** ppstgOpen
)
262 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
267 static HRESULT WINAPI
ITStorageImpl_StgIsStorageFile(
269 const WCHAR
* pwcsName
)
271 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
276 static HRESULT WINAPI
ITStorageImpl_StgIsStorageILockBytes(
280 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
285 static HRESULT WINAPI
ITStorageImpl_StgOpenStorage(
287 const WCHAR
* pwcsName
,
288 IStorage
* pstgPriority
,
292 IStorage
** ppstgOpen
)
294 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
296 TRACE("%p %s %p %d %p\n", This
, debugstr_w( pwcsName
),
297 pstgPriority
, grfMode
, snbExclude
);
299 return ITSS_StgOpenStorage( pwcsName
, pstgPriority
, grfMode
,
300 snbExclude
, reserved
, ppstgOpen
);
303 static HRESULT WINAPI
ITStorageImpl_StgOpenStorageOnILockBytes(
306 IStorage
* pStgPriority
,
310 IStorage
** ppstgOpen
)
312 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
317 static HRESULT WINAPI
ITStorageImpl_StgSetTimes(
319 const WCHAR
* lpszName
,
320 const FILETIME
* pctime
,
321 const FILETIME
* patime
,
322 const FILETIME
* pmtime
)
324 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
329 static HRESULT WINAPI
ITStorageImpl_SetControlData(
331 PITS_Control_Data pControlData
)
333 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
338 static HRESULT WINAPI
ITStorageImpl_DefaultControlData(
340 PITS_Control_Data
* ppControlData
)
342 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
347 static HRESULT WINAPI
ITStorageImpl_Compact(
349 const WCHAR
* pwcsName
,
352 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
357 static const IITStorageVtbl ITStorageImpl_Vtbl
=
359 ITStorageImpl_QueryInterface
,
360 ITStorageImpl_AddRef
,
361 ITStorageImpl_Release
,
362 ITStorageImpl_StgCreateDocfile
,
363 ITStorageImpl_StgCreateDocfileOnILockBytes
,
364 ITStorageImpl_StgIsStorageFile
,
365 ITStorageImpl_StgIsStorageILockBytes
,
366 ITStorageImpl_StgOpenStorage
,
367 ITStorageImpl_StgOpenStorageOnILockBytes
,
368 ITStorageImpl_StgSetTimes
,
369 ITStorageImpl_SetControlData
,
370 ITStorageImpl_DefaultControlData
,
371 ITStorageImpl_Compact
,
374 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
379 return CLASS_E_NOAGGREGATION
;
381 its
= HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl
) );
382 its
->IITStorage_iface
.lpVtbl
= &ITStorageImpl_Vtbl
;
385 TRACE("-> %p\n", its
);
392 /*****************************************************************************/
394 HRESULT WINAPI
DllCanUnloadNow(void)
396 TRACE("dll_count = %u\n", dll_count
);
397 return dll_count
? S_FALSE
: S_OK
;
400 /***********************************************************************
401 * DllRegisterServer (ITSS.@)
403 HRESULT WINAPI
DllRegisterServer(void)
405 return __wine_register_resources( hInst
);
408 /***********************************************************************
409 * DllUnregisterServer (ITSS.@)
411 HRESULT WINAPI
DllUnregisterServer(void)
413 return __wine_unregister_resources( hInst
);