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
);
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(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
109 REFIID riid
, LPVOID
*ppobj
)
111 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
115 TRACE("(%p)->(%p,%s,%p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
118 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
119 if (SUCCEEDED(hres
)) {
120 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
121 IUnknown_Release(punk
);
126 static HRESULT WINAPI
ITSSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
128 TRACE("(%p)->(%d)\n", iface
, dolock
);
138 static const IClassFactoryVtbl ITSSCF_Vtbl
=
140 ITSSCF_QueryInterface
,
143 ITSSCF_CreateInstance
,
147 static const IClassFactoryImpl ITStorage_factory
= { { &ITSSCF_Vtbl
}, ITSS_create
};
148 static const IClassFactoryImpl MSITStore_factory
= { { &ITSSCF_Vtbl
}, ITS_IParseDisplayName_create
};
149 static const IClassFactoryImpl ITSProtocol_factory
= { { &ITSSCF_Vtbl
}, ITSProtocol_create
};
151 /***********************************************************************
152 * DllGetClassObject (ITSS.@)
154 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
156 const IClassFactoryImpl
*factory
;
158 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
160 if (IsEqualGUID(&CLSID_ITStorage
, rclsid
))
161 factory
= &ITStorage_factory
;
162 else if (IsEqualGUID(&CLSID_MSITStore
, rclsid
))
163 factory
= &MSITStore_factory
;
164 else if (IsEqualGUID(&CLSID_ITSProtocol
, rclsid
))
165 factory
= &ITSProtocol_factory
;
168 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
169 return CLASS_E_CLASSNOTAVAILABLE
;
172 return IUnknown_QueryInterface( (IUnknown
*) factory
, iid
, ppv
);
175 /*****************************************************************************/
178 IITStorage IITStorage_iface
;
182 static inline ITStorageImpl
*impl_from_IITStorage(IITStorage
*iface
)
184 return CONTAINING_RECORD(iface
, ITStorageImpl
, IITStorage_iface
);
188 static HRESULT WINAPI
ITStorageImpl_QueryInterface(
193 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
194 if (IsEqualGUID(riid
, &IID_IUnknown
)
195 || IsEqualGUID(riid
, &IID_IITStorage
))
197 IITStorage_AddRef(iface
);
202 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
203 return E_NOINTERFACE
;
206 static ULONG WINAPI
ITStorageImpl_AddRef(
209 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
211 return InterlockedIncrement(&This
->ref
);
214 static ULONG WINAPI
ITStorageImpl_Release(
217 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
218 ULONG ref
= InterlockedDecrement(&This
->ref
);
221 HeapFree(GetProcessHeap(), 0, This
);
228 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfile(
230 const WCHAR
* pwcsName
,
233 IStorage
** ppstgOpen
)
235 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
237 TRACE("%p %s %u %u %p\n", This
,
238 debugstr_w(pwcsName
), grfMode
, reserved
, ppstgOpen
);
240 return ITSS_StgOpenStorage( pwcsName
, NULL
, grfMode
,
241 0, reserved
, ppstgOpen
);
244 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfileOnILockBytes(
249 IStorage
** ppstgOpen
)
251 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
256 static HRESULT WINAPI
ITStorageImpl_StgIsStorageFile(
258 const WCHAR
* pwcsName
)
260 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
265 static HRESULT WINAPI
ITStorageImpl_StgIsStorageILockBytes(
269 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
274 static HRESULT WINAPI
ITStorageImpl_StgOpenStorage(
276 const WCHAR
* pwcsName
,
277 IStorage
* pstgPriority
,
281 IStorage
** ppstgOpen
)
283 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
285 TRACE("%p %s %p %d %p\n", This
, debugstr_w( pwcsName
),
286 pstgPriority
, grfMode
, snbExclude
);
288 return ITSS_StgOpenStorage( pwcsName
, pstgPriority
, grfMode
,
289 snbExclude
, reserved
, ppstgOpen
);
292 static HRESULT WINAPI
ITStorageImpl_StgOpenStorageOnILockBytes(
295 IStorage
* pStgPriority
,
299 IStorage
** ppstgOpen
)
301 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
306 static HRESULT WINAPI
ITStorageImpl_StgSetTimes(
308 const WCHAR
* lpszName
,
309 const FILETIME
* pctime
,
310 const FILETIME
* patime
,
311 const FILETIME
* pmtime
)
313 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
318 static HRESULT WINAPI
ITStorageImpl_SetControlData(
320 PITS_Control_Data pControlData
)
322 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
327 static HRESULT WINAPI
ITStorageImpl_DefaultControlData(
329 PITS_Control_Data
* ppControlData
)
331 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
336 static HRESULT WINAPI
ITStorageImpl_Compact(
338 const WCHAR
* pwcsName
,
341 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
346 static const IITStorageVtbl ITStorageImpl_Vtbl
=
348 ITStorageImpl_QueryInterface
,
349 ITStorageImpl_AddRef
,
350 ITStorageImpl_Release
,
351 ITStorageImpl_StgCreateDocfile
,
352 ITStorageImpl_StgCreateDocfileOnILockBytes
,
353 ITStorageImpl_StgIsStorageFile
,
354 ITStorageImpl_StgIsStorageILockBytes
,
355 ITStorageImpl_StgOpenStorage
,
356 ITStorageImpl_StgOpenStorageOnILockBytes
,
357 ITStorageImpl_StgSetTimes
,
358 ITStorageImpl_SetControlData
,
359 ITStorageImpl_DefaultControlData
,
360 ITStorageImpl_Compact
,
363 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
368 return CLASS_E_NOAGGREGATION
;
370 its
= HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl
) );
371 its
->IITStorage_iface
.lpVtbl
= &ITStorageImpl_Vtbl
;
374 TRACE("-> %p\n", its
);
381 /*****************************************************************************/
383 HRESULT WINAPI
DllCanUnloadNow(void)
385 TRACE("dll_count = %u\n", dll_count
);
386 return dll_count
? S_FALSE
: S_OK
;
389 /***********************************************************************
390 * DllRegisterServer (ITSS.@)
392 HRESULT WINAPI
DllRegisterServer(void)
394 return __wine_register_resources( hInst
);
397 /***********************************************************************
398 * DllUnregisterServer (ITSS.@)
400 HRESULT WINAPI
DllUnregisterServer(void)
402 return __wine_unregister_resources( hInst
);