ReactOS 0.4.17-dev-966-gf06eace
itss.c
Go to the documentation of this file.
1/*
2 * ITSS Class Factory
3 *
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2004 Mike McCormack
6 *
7 * see http://bonedaddy.net/pabs3/hhm/#chmspec
8 *
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.
13 *
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.
18 *
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
22 */
23
24
25#include <stdarg.h>
26#include <stdio.h>
27
28#define COBJMACROS
29
30#include "windef.h"
31#include "winbase.h"
32#include "winuser.h"
33#include "winreg.h"
34#include "ole2.h"
35#include "rpcproxy.h"
36#include "advpub.h"
37
38#include "wine/debug.h"
39
40#include "itsstor.h"
41
42#include "initguid.h"
43#include "wine/itss.h"
44
46
47static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
48
50
51/******************************************************************************
52 * ITSS ClassFactory
53 */
54typedef struct {
55 IClassFactory IClassFactory_iface;
56 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
58
60{
61 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
62}
63
64static HRESULT WINAPI
65ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
66{
68
71 {
72 IClassFactory_AddRef(iface);
73 *ppobj = &This->IClassFactory_iface;
74 return S_OK;
75 }
76
77 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
78 return E_NOINTERFACE;
79}
80
81static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
82{
84 return 2;
85}
86
87static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
88{
90 return 1;
91}
92
93
95 REFIID riid, void **ppv)
96{
98 IUnknown *unk;
100
101 TRACE("(%p)->(%p %s %p)\n", This, outer, debugstr_guid(riid), ppv);
102
104 *ppv = NULL;
106 }
107
108 hres = This->pfnCreateInstance(outer, (void**)&unk);
109 if(FAILED(hres)) {
110 *ppv = NULL;
111 return hres;
112 }
113
115 hres = IUnknown_QueryInterface(unk, riid, ppv);
116 IUnknown_Release(unk);
117 }else {
118 *ppv = unk;
119 }
120 return hres;
121}
122
123static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
124{
125 TRACE("(%p)->(%d)\n", iface, dolock);
126
127 if (dolock)
129 else
131
132 return S_OK;
133}
134
135static const IClassFactoryVtbl ITSSCF_Vtbl =
136{
142};
143
147
148/***********************************************************************
149 * DllGetClassObject (ITSS.@)
150 */
152{
154
155 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
156
157 if (IsEqualGUID(&CLSID_ITStorage, rclsid))
159 else if (IsEqualGUID(&CLSID_MSITStore, rclsid))
161 else if (IsEqualGUID(&CLSID_ITSProtocol, rclsid))
163 else
164 {
165 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
167 }
168
169 return IUnknown_QueryInterface( (IUnknown*) factory, iid, ppv );
170}
171
172/*****************************************************************************/
173
174typedef struct {
178
180{
181 return CONTAINING_RECORD(iface, ITStorageImpl, IITStorage_iface);
182}
183
184
186 IITStorage* iface,
187 REFIID riid,
188 void** ppvObject)
189{
192 || IsEqualGUID(riid, &IID_IITStorage))
193 {
194 IITStorage_AddRef(iface);
195 *ppvObject = iface;
196 return S_OK;
197 }
198
199 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
200 return E_NOINTERFACE;
201}
202
204 IITStorage* iface)
205{
207 TRACE("%p\n", This);
208 return InterlockedIncrement(&This->ref);
209}
210
212 IITStorage* iface)
213{
216
217 if (ref == 0) {
220 }
221
222 return ref;
223}
224
226 IITStorage* iface,
227 const WCHAR* pwcsName,
228 DWORD grfMode,
230 IStorage** ppstgOpen)
231{
233
234 TRACE("%p %s %lu %lu %p\n", This,
235 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
236
237 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
238 0, reserved, ppstgOpen);
239}
240
242 IITStorage* iface,
243 ILockBytes* plkbyt,
244 DWORD grfMode,
246 IStorage** ppstgOpen)
247{
249 FIXME("%p\n", This);
250 return E_NOTIMPL;
251}
252
254 IITStorage* iface,
255 const WCHAR* pwcsName)
256{
258 FIXME("%p\n", This);
259 return E_NOTIMPL;
260}
261
263 IITStorage* iface,
264 ILockBytes* plkbyt)
265{
267 FIXME("%p\n", This);
268 return E_NOTIMPL;
269}
270
272 IITStorage* iface,
273 const WCHAR* pwcsName,
274 IStorage* pstgPriority,
275 DWORD grfMode,
276 SNB snbExclude,
278 IStorage** ppstgOpen)
279{
281
282 TRACE("%p %s %p %ld %p\n", This, debugstr_w( pwcsName ),
283 pstgPriority, grfMode, snbExclude );
284
285 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
286 snbExclude, reserved, ppstgOpen);
287}
288
290 IITStorage* iface,
291 ILockBytes* plkbyt,
292 IStorage* pStgPriority,
293 DWORD grfMode,
294 SNB snbExclude,
296 IStorage** ppstgOpen)
297{
299 FIXME("%p\n", This);
300 return E_NOTIMPL;
301}
302
304 IITStorage* iface,
305 const WCHAR* lpszName,
306 const FILETIME* pctime,
307 const FILETIME* patime,
308 const FILETIME* pmtime)
309{
311 FIXME("%p\n", This);
312 return E_NOTIMPL;
313}
314
316 IITStorage* iface,
317 PITS_Control_Data pControlData)
318{
320 FIXME("%p\n", This);
321 return E_NOTIMPL;
322}
323
325 IITStorage* iface,
326 PITS_Control_Data* ppControlData)
327{
329 FIXME("%p\n", This);
330 return E_NOTIMPL;
331}
332
334 IITStorage* iface,
335 const WCHAR* pwcsName,
336 ECompactionLev iLev)
337{
339 FIXME("%p\n", This);
340 return E_NOTIMPL;
341}
342
343static const IITStorageVtbl ITStorageImpl_Vtbl =
344{
358};
359
360static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
361{
362 ITStorageImpl *its;
363
364 if( pUnkOuter )
366
367 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
369 its->ref = 1;
370
371 TRACE("-> %p\n", its);
372 *ppObj = its;
373
375 return S_OK;
376}
377
378/*****************************************************************************/
379
381{
382 TRACE("dll_count = %lu\n", dll_count);
383 return dll_count ? S_FALSE : S_OK;
384}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
r reserved
Definition: btrfs.c:3006
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
Definition: itss.c:123
static HRESULT WINAPI ITStorageImpl_StgOpenStorage(IITStorage *iface, const WCHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: itss.c:271
static HRESULT WINAPI ITStorageImpl_StgIsStorageFile(IITStorage *iface, const WCHAR *pwcsName)
Definition: itss.c:253
static HRESULT WINAPI ITStorageImpl_Compact(IITStorage *iface, const WCHAR *pwcsName, ECompactionLev iLev)
Definition: itss.c:333
static ITStorageImpl * impl_from_IITStorage(IITStorage *iface)
Definition: itss.c:179
static const IClassFactoryImpl MSITStore_factory
Definition: itss.c:145
static HRESULT WINAPI ITSSCF_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: itss.c:94
static HRESULT WINAPI ITStorageImpl_StgSetTimes(IITStorage *iface, const WCHAR *lpszName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
Definition: itss.c:303
static HRESULT WINAPI ITSSCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
Definition: itss.c:65
static HRESULT WINAPI ITStorageImpl_QueryInterface(IITStorage *iface, REFIID riid, void **ppvObject)
Definition: itss.c:185
static HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(IITStorage *iface, ILockBytes *plkbyt, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: itss.c:241
static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
Definition: itss.c:87
static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: itss.c:360
static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
Definition: itss.c:81
static HRESULT WINAPI ITStorageImpl_DefaultControlData(IITStorage *iface, PITS_Control_Data *ppControlData)
Definition: itss.c:324
static ULONG WINAPI ITStorageImpl_AddRef(IITStorage *iface)
Definition: itss.c:203
static const IITStorageVtbl ITStorageImpl_Vtbl
Definition: itss.c:343
static HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(IITStorage *iface, ILockBytes *plkbyt)
Definition: itss.c:262
static HRESULT WINAPI ITStorageImpl_StgCreateDocfile(IITStorage *iface, const WCHAR *pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: itss.c:225
static const IClassFactoryImpl ITSProtocol_factory
Definition: itss.c:146
static ULONG WINAPI ITStorageImpl_Release(IITStorage *iface)
Definition: itss.c:211
HRESULT WINAPI DllCanUnloadNow(void)
Definition: itss.c:380
static HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(IITStorage *iface, ILockBytes *plkbyt, IStorage *pStgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: itss.c:289
static HRESULT WINAPI ITStorageImpl_SetControlData(IITStorage *iface, PITS_Control_Data pControlData)
Definition: itss.c:315
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: itss.c:59
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
Definition: itss.c:151
static const IClassFactoryImpl ITStorage_factory
Definition: itss.c:144
static const IClassFactoryVtbl ITSSCF_Vtbl
Definition: itss.c:135
LONG dll_count
Definition: itss.c:49
HRESULT ITSProtocol_create(IUnknown *pUnkOuter, LPVOID *ppobj)
static void ITSS_LockModule(void)
Definition: itsstor.h:39
static void ITSS_UnlockModule(void)
Definition: itsstor.h:40
HRESULT ITSS_StgOpenStorage(const WCHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: storage.c:633
HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: moniker.c:469
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
HRESULT hres
Definition: protocol.c:432
static IUnknown * outer
Definition: compobj.c:82
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
ECompactionLev
Definition: itss.idl:28
#define TRACE(s)
Definition: solgame.cpp:4
IITStorage IITStorage_iface
Definition: itss.c:175
LONG ref
Definition: itss.c:176
Definition: main.c:439
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451
#define E_NOINTERFACE
Definition: winerror.h:3479
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772