ReactOS  0.4.15-dev-1197-g8081ba9
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 
47 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
48 
51 
52 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
53 {
54  switch(fdwReason) {
55  case DLL_PROCESS_ATTACH:
56  DisableThreadLibraryCalls(hInstDLL);
57  hInst = hInstDLL;
58  break;
59  }
60  return TRUE;
61 }
62 
63 /******************************************************************************
64  * ITSS ClassFactory
65  */
66 typedef struct {
67  IClassFactory IClassFactory_iface;
68  HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
70 
72 {
73  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
74 }
75 
76 static HRESULT WINAPI
77 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
78 {
80 
81  if (IsEqualGUID(riid, &IID_IUnknown) ||
83  {
84  IClassFactory_AddRef(iface);
85  *ppobj = &This->IClassFactory_iface;
86  return S_OK;
87  }
88 
89  WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
90  return E_NOINTERFACE;
91 }
92 
93 static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
94 {
96  return 2;
97 }
98 
99 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
100 {
102  return 1;
103 }
104 
105 
107  REFIID riid, void **ppv)
108 {
110  IUnknown *unk;
111  HRESULT hres;
112 
113  TRACE("(%p)->(%p %s %p)\n", This, outer, debugstr_guid(riid), ppv);
114 
115  if(outer && !IsEqualGUID(riid, &IID_IUnknown)) {
116  *ppv = NULL;
117  return CLASS_E_NOAGGREGATION;
118  }
119 
120  hres = This->pfnCreateInstance(outer, (void**)&unk);
121  if(FAILED(hres)) {
122  *ppv = NULL;
123  return hres;
124  }
125 
126  if(!IsEqualGUID(riid, &IID_IUnknown)) {
127  hres = IUnknown_QueryInterface(unk, riid, ppv);
128  IUnknown_Release(unk);
129  }else {
130  *ppv = unk;
131  }
132  return hres;
133 }
134 
135 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
136 {
137  TRACE("(%p)->(%d)\n", iface, dolock);
138 
139  if (dolock)
140  ITSS_LockModule();
141  else
143 
144  return S_OK;
145 }
146 
147 static const IClassFactoryVtbl ITSSCF_Vtbl =
148 {
154 };
155 
159 
160 /***********************************************************************
161  * DllGetClassObject (ITSS.@)
162  */
164 {
165  const IClassFactoryImpl *factory;
166 
167  TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
168 
169  if (IsEqualGUID(&CLSID_ITStorage, rclsid))
171  else if (IsEqualGUID(&CLSID_MSITStore, rclsid))
173  else if (IsEqualGUID(&CLSID_ITSProtocol, rclsid))
175  else
176  {
177  FIXME("%s: no class found.\n", debugstr_guid(rclsid));
179  }
180 
181  return IUnknown_QueryInterface( (IUnknown*) factory, iid, ppv );
182 }
183 
184 /*****************************************************************************/
185 
186 typedef struct {
189 } ITStorageImpl;
190 
192 {
193  return CONTAINING_RECORD(iface, ITStorageImpl, IITStorage_iface);
194 }
195 
196 
198  IITStorage* iface,
199  REFIID riid,
200  void** ppvObject)
201 {
204  || IsEqualGUID(riid, &IID_IITStorage))
205  {
206  IITStorage_AddRef(iface);
207  *ppvObject = iface;
208  return S_OK;
209  }
210 
211  WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
212  return E_NOINTERFACE;
213 }
214 
216  IITStorage* iface)
217 {
219  TRACE("%p\n", This);
220  return InterlockedIncrement(&This->ref);
221 }
222 
224  IITStorage* iface)
225 {
228 
229  if (ref == 0) {
232  }
233 
234  return ref;
235 }
236 
238  IITStorage* iface,
239  const WCHAR* pwcsName,
240  DWORD grfMode,
241  DWORD reserved,
242  IStorage** ppstgOpen)
243 {
245 
246  TRACE("%p %s %u %u %p\n", This,
247  debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
248 
249  return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
250  0, reserved, ppstgOpen);
251 }
252 
254  IITStorage* iface,
255  ILockBytes* plkbyt,
256  DWORD grfMode,
257  DWORD reserved,
258  IStorage** ppstgOpen)
259 {
261  FIXME("%p\n", This);
262  return E_NOTIMPL;
263 }
264 
266  IITStorage* iface,
267  const WCHAR* pwcsName)
268 {
270  FIXME("%p\n", This);
271  return E_NOTIMPL;
272 }
273 
275  IITStorage* iface,
276  ILockBytes* plkbyt)
277 {
279  FIXME("%p\n", This);
280  return E_NOTIMPL;
281 }
282 
284  IITStorage* iface,
285  const WCHAR* pwcsName,
286  IStorage* pstgPriority,
287  DWORD grfMode,
288  SNB snbExclude,
289  DWORD reserved,
290  IStorage** ppstgOpen)
291 {
293 
294  TRACE("%p %s %p %d %p\n", This, debugstr_w( pwcsName ),
295  pstgPriority, grfMode, snbExclude );
296 
297  return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
298  snbExclude, reserved, ppstgOpen);
299 }
300 
302  IITStorage* iface,
303  ILockBytes* plkbyt,
304  IStorage* pStgPriority,
305  DWORD grfMode,
306  SNB snbExclude,
307  DWORD reserved,
308  IStorage** ppstgOpen)
309 {
311  FIXME("%p\n", This);
312  return E_NOTIMPL;
313 }
314 
316  IITStorage* iface,
317  const WCHAR* lpszName,
318  const FILETIME* pctime,
319  const FILETIME* patime,
320  const FILETIME* pmtime)
321 {
323  FIXME("%p\n", This);
324  return E_NOTIMPL;
325 }
326 
328  IITStorage* iface,
329  PITS_Control_Data pControlData)
330 {
332  FIXME("%p\n", This);
333  return E_NOTIMPL;
334 }
335 
337  IITStorage* iface,
338  PITS_Control_Data* ppControlData)
339 {
341  FIXME("%p\n", This);
342  return E_NOTIMPL;
343 }
344 
346  IITStorage* iface,
347  const WCHAR* pwcsName,
348  ECompactionLev iLev)
349 {
351  FIXME("%p\n", This);
352  return E_NOTIMPL;
353 }
354 
355 static const IITStorageVtbl ITStorageImpl_Vtbl =
356 {
370 };
371 
372 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
373 {
374  ITStorageImpl *its;
375 
376  if( pUnkOuter )
377  return CLASS_E_NOAGGREGATION;
378 
379  its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
380  its->IITStorage_iface.lpVtbl = &ITStorageImpl_Vtbl;
381  its->ref = 1;
382 
383  TRACE("-> %p\n", its);
384  *ppObj = its;
385 
386  ITSS_LockModule();
387  return S_OK;
388 }
389 
390 /*****************************************************************************/
391 
393 {
394  TRACE("dll_count = %u\n", dll_count);
395  return dll_count ? S_FALSE : S_OK;
396 }
397 
398 /***********************************************************************
399  * DllRegisterServer (ITSS.@)
400  */
402 {
404 }
405 
406 /***********************************************************************
407  * DllUnregisterServer (ITSS.@)
408  */
410 {
412 }
static HINSTANCE hInst
Definition: itss.c:50
#define HRESULT
Definition: msvc.h:7
HRESULT WINAPI DllUnregisterServer(void)
Definition: itss.c:409
#define REFIID
Definition: guiddef.h:118
#define E_NOINTERFACE
Definition: winerror.h:2364
static ULONG WINAPI ITStorageImpl_Release(IITStorage *iface)
Definition: itss.c:223
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
static void ITSS_LockModule(void)
Definition: itsstor.h:41
#define TRUE
Definition: types.h:120
static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
Definition: itss.c:93
REFIID riid
Definition: precomp.h:44
HRESULT ITSProtocol_create(IUnknown *pUnkOuter, LPVOID *ppobj) DECLSPEC_HIDDEN
#define REFCLSID
Definition: guiddef.h:117
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
Definition: itss.c:52
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
Definition: itss.c:163
#define WARN(fmt,...)
Definition: debug.h:112
static HRESULT WINAPI ITStorageImpl_DefaultControlData(IITStorage *iface, PITS_Control_Data *ppControlData)
Definition: itss.c:336
REFIID LPVOID * ppv
Definition: atlbase.h:39
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
WINE_DEFAULT_DEBUG_CHANNEL(itss)
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
static const IClassFactoryImpl ITStorage_factory
Definition: itss.c:156
static void ITSS_UnlockModule(void)
Definition: itsstor.h:42
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
Definition: send.c:48
HRESULT WINAPI DllCanUnloadNow(void)
Definition: itss.c:392
static HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(IITStorage *iface, ILockBytes *plkbyt)
Definition: itss.c:274
struct tagIClassFactoryImpl IClassFactoryImpl
static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
Definition: itss.c:99
HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN
Definition: moniker.c:472
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: itss.c:71
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: main.c:438
#define debugstr_w
Definition: kernel32.h:32
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:111
r reserved
Definition: btrfs.c:2940
#define S_FALSE
Definition: winerror.h:2357
static const IClassFactoryVtbl ITSSCF_Vtbl
Definition: itss.c:147
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
IITStorage IITStorage_iface
Definition: itss.c:187
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(IITStorage *iface, ILockBytes *plkbyt, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: itss.c:253
static HRESULT WINAPI ITStorageImpl_QueryInterface(IITStorage *iface, REFIID riid, void **ppvObject)
Definition: itss.c:197
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT WINAPI ITSSCF_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: itss.c:106
HRESULT hres
Definition: protocol.c:465
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
Definition: itss.c:135
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
static HRESULT WINAPI ITStorageImpl_Compact(IITStorage *iface, const WCHAR *pwcsName, ECompactionLev iLev)
Definition: itss.c:345
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:6
LONG ref
Definition: itss.c:188
unsigned long DWORD
Definition: ntddk_ex.h:95
static const IITStorageVtbl ITStorageImpl_Vtbl
Definition: itss.c:355
HRESULT ITSS_StgOpenStorage(const WCHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen) DECLSPEC_HIDDEN
Definition: storage.c:633
static HRESULT WINAPI ITStorageImpl_StgSetTimes(IITStorage *iface, const WCHAR *lpszName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
Definition: itss.c:315
HRESULT WINAPI DllRegisterServer(void)
Definition: itss.c:401
static ULONG WINAPI ITStorageImpl_AddRef(IITStorage *iface)
Definition: itss.c:215
#define InterlockedDecrement
Definition: armddk.h:52
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
static HRESULT WINAPI ITStorageImpl_StgCreateDocfile(IITStorage *iface, const WCHAR *pwcsName, DWORD grfMode, DWORD reserved, IStorage **ppstgOpen)
Definition: itss.c:237
REFIID LPVOID * ppvObject
Definition: precomp.h:44
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
ECompactionLev
Definition: itss.idl:28
static HRESULT WINAPI ITStorageImpl_SetControlData(IITStorage *iface, PITS_Control_Data pControlData)
Definition: itss.c:327
#define S_OK
Definition: intsafe.h:51
#define InterlockedIncrement
Definition: armddk.h:53
static HRESULT WINAPI ITStorageImpl_StgOpenStorage(IITStorage *iface, const WCHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: itss.c:283
static HRESULT WINAPI ITStorageImpl_StgIsStorageFile(IITStorage *iface, const WCHAR *pwcsName)
Definition: itss.c:265
static HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(IITStorage *iface, ILockBytes *plkbyt, IStorage *pStgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: itss.c:301
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: itss.c:372
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
LONG dll_count
Definition: itss.c:49
unsigned int ULONG
Definition: retypes.h:1
static ClassFactoryImpl factory
Definition: ole_server.c:234
static const IClassFactoryImpl ITSProtocol_factory
Definition: itss.c:158
static const IClassFactoryImpl MSITStore_factory
Definition: itss.c:157
static HRESULT WINAPI ITSSCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
Definition: itss.c:77
const GUID IID_IClassFactory
static ITStorageImpl * impl_from_IITStorage(IITStorage *iface)
Definition: itss.c:191
#define HeapFree(x, y, z)
Definition: compat.h:483