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
28 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
31 static HINSTANCE hInst
;
33 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
36 case DLL_PROCESS_ATTACH
:
37 DisableThreadLibraryCalls(hInstDLL
);
44 /******************************************************************************
48 IClassFactory IClassFactory_iface
;
49 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
52 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
54 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
58 ITSSCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
60 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
62 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
63 IsEqualGUID(riid
, &IID_IClassFactory
))
65 IClassFactory_AddRef(iface
);
70 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
74 static ULONG WINAPI
ITSSCF_AddRef(LPCLASSFACTORY iface
)
80 static ULONG WINAPI
ITSSCF_Release(LPCLASSFACTORY iface
)
87 static HRESULT WINAPI
ITSSCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
88 REFIID riid
, LPVOID
*ppobj
)
90 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
94 TRACE("(%p)->(%p,%s,%p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
97 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
98 if (SUCCEEDED(hres
)) {
99 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
100 IUnknown_Release(punk
);
105 static HRESULT WINAPI
ITSSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
107 TRACE("(%p)->(%d)\n", iface
, dolock
);
117 static const IClassFactoryVtbl ITSSCF_Vtbl
=
119 ITSSCF_QueryInterface
,
122 ITSSCF_CreateInstance
,
126 static const IClassFactoryImpl ITStorage_factory
= { { &ITSSCF_Vtbl
}, ITSS_create
};
127 static const IClassFactoryImpl MSITStore_factory
= { { &ITSSCF_Vtbl
}, ITS_IParseDisplayName_create
};
128 static const IClassFactoryImpl ITSProtocol_factory
= { { &ITSSCF_Vtbl
}, ITSProtocol_create
};
130 /***********************************************************************
131 * DllGetClassObject (ITSS.@)
133 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
135 const IClassFactoryImpl
*factory
;
137 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
139 if (IsEqualGUID(&CLSID_ITStorage
, rclsid
))
140 factory
= &ITStorage_factory
;
141 else if (IsEqualGUID(&CLSID_MSITStore
, rclsid
))
142 factory
= &MSITStore_factory
;
143 else if (IsEqualGUID(&CLSID_ITSProtocol
, rclsid
))
144 factory
= &ITSProtocol_factory
;
147 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
148 return CLASS_E_CLASSNOTAVAILABLE
;
151 return IUnknown_QueryInterface( (IUnknown
*) factory
, iid
, ppv
);
154 /*****************************************************************************/
157 IITStorage IITStorage_iface
;
161 static inline ITStorageImpl
*impl_from_IITStorage(IITStorage
*iface
)
163 return CONTAINING_RECORD(iface
, ITStorageImpl
, IITStorage_iface
);
167 static HRESULT WINAPI
ITStorageImpl_QueryInterface(
172 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
173 if (IsEqualGUID(riid
, &IID_IUnknown
)
174 || IsEqualGUID(riid
, &IID_IITStorage
))
176 IITStorage_AddRef(iface
);
181 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
182 return E_NOINTERFACE
;
185 static ULONG WINAPI
ITStorageImpl_AddRef(
188 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
190 return InterlockedIncrement(&This
->ref
);
193 static ULONG WINAPI
ITStorageImpl_Release(
196 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
197 ULONG ref
= InterlockedDecrement(&This
->ref
);
200 HeapFree(GetProcessHeap(), 0, This
);
207 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfile(
209 const WCHAR
* pwcsName
,
212 IStorage
** ppstgOpen
)
214 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
216 TRACE("%p %s %u %u %p\n", This
,
217 debugstr_w(pwcsName
), grfMode
, reserved
, ppstgOpen
);
219 return ITSS_StgOpenStorage( pwcsName
, NULL
, grfMode
,
220 0, reserved
, ppstgOpen
);
223 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfileOnILockBytes(
228 IStorage
** ppstgOpen
)
230 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
235 static HRESULT WINAPI
ITStorageImpl_StgIsStorageFile(
237 const WCHAR
* pwcsName
)
239 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
244 static HRESULT WINAPI
ITStorageImpl_StgIsStorageILockBytes(
248 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
253 static HRESULT WINAPI
ITStorageImpl_StgOpenStorage(
255 const WCHAR
* pwcsName
,
256 IStorage
* pstgPriority
,
260 IStorage
** ppstgOpen
)
262 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
264 TRACE("%p %s %p %d %p\n", This
, debugstr_w( pwcsName
),
265 pstgPriority
, grfMode
, snbExclude
);
267 return ITSS_StgOpenStorage( pwcsName
, pstgPriority
, grfMode
,
268 snbExclude
, reserved
, ppstgOpen
);
271 static HRESULT WINAPI
ITStorageImpl_StgOpenStorageOnILockBytes(
274 IStorage
* pStgPriority
,
278 IStorage
** ppstgOpen
)
280 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
285 static HRESULT WINAPI
ITStorageImpl_StgSetTimes(
287 const WCHAR
* lpszName
,
288 const FILETIME
* pctime
,
289 const FILETIME
* patime
,
290 const FILETIME
* pmtime
)
292 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
297 static HRESULT WINAPI
ITStorageImpl_SetControlData(
299 PITS_Control_Data pControlData
)
301 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
306 static HRESULT WINAPI
ITStorageImpl_DefaultControlData(
308 PITS_Control_Data
* ppControlData
)
310 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
315 static HRESULT WINAPI
ITStorageImpl_Compact(
317 const WCHAR
* pwcsName
,
320 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
325 static const IITStorageVtbl ITStorageImpl_Vtbl
=
327 ITStorageImpl_QueryInterface
,
328 ITStorageImpl_AddRef
,
329 ITStorageImpl_Release
,
330 ITStorageImpl_StgCreateDocfile
,
331 ITStorageImpl_StgCreateDocfileOnILockBytes
,
332 ITStorageImpl_StgIsStorageFile
,
333 ITStorageImpl_StgIsStorageILockBytes
,
334 ITStorageImpl_StgOpenStorage
,
335 ITStorageImpl_StgOpenStorageOnILockBytes
,
336 ITStorageImpl_StgSetTimes
,
337 ITStorageImpl_SetControlData
,
338 ITStorageImpl_DefaultControlData
,
339 ITStorageImpl_Compact
,
342 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
347 return CLASS_E_NOAGGREGATION
;
349 its
= HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl
) );
350 its
->IITStorage_iface
.lpVtbl
= &ITStorageImpl_Vtbl
;
353 TRACE("-> %p\n", its
);
360 /*****************************************************************************/
362 HRESULT WINAPI
DllCanUnloadNow(void)
364 TRACE("dll_count = %u\n", dll_count
);
365 return dll_count
? S_FALSE
: S_OK
;
368 /***********************************************************************
369 * DllRegisterServer (ITSS.@)
371 HRESULT WINAPI
DllRegisterServer(void)
373 return __wine_register_resources( hInst
);
376 /***********************************************************************
377 * DllUnregisterServer (ITSS.@)
379 HRESULT WINAPI
DllUnregisterServer(void)
381 return __wine_unregister_resources( hInst
);