ReactOS  0.4.14-dev-50-g13bb5e2
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 #include "config.h"
25 
26 #include <stdarg.h>
27 #include <stdio.h>
28 
29 #define COBJMACROS
30 
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "winreg.h"
35 #include "ole2.h"
36 #include "rpcproxy.h"
37 #include "advpub.h"
38 
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
41 
42 #include "itsstor.h"
43 
44 #include "initguid.h"
45 #include "wine/itss.h"
46 
48 
49 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
50 
53 
54 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
55 {
56  switch(fdwReason) {
57  case DLL_PROCESS_ATTACH:
58  DisableThreadLibraryCalls(hInstDLL);
59  hInst = hInstDLL;
60  break;
61  }
62  return TRUE;
63 }
64 
65 /******************************************************************************
66  * ITSS ClassFactory
67  */
68 typedef struct {
69  IClassFactory IClassFactory_iface;
70  HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
72 
74 {
75  return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
76 }
77 
78 static HRESULT WINAPI
79 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
80 {
82 
83  if (IsEqualGUID(riid, &IID_IUnknown) ||
85  {
86  IClassFactory_AddRef(iface);
87  *ppobj = &This->IClassFactory_iface;
88  return S_OK;
89  }
90 
91  WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
92  return E_NOINTERFACE;
93 }
94 
95 static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
96 {
98  return 2;
99 }
100 
101 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
102 {
104  return 1;
105 }
106 
107 
109  REFIID riid, void **ppv)
110 {
112  IUnknown *unk;
113  HRESULT hres;
114 
115  TRACE("(%p)->(%p %s %p)\n", This, outer, debugstr_guid(riid), ppv);
116 
117  if(outer && !IsEqualGUID(riid, &IID_IUnknown)) {
118  *ppv = NULL;
119  return CLASS_E_NOAGGREGATION;
120  }
121 
122  hres = This->pfnCreateInstance(outer, (void**)&unk);
123  if(FAILED(hres)) {
124  *ppv = NULL;
125  return hres;
126  }
127 
128  if(!IsEqualGUID(riid, &IID_IUnknown)) {
129  hres = IUnknown_QueryInterface(unk, riid, ppv);
130  IUnknown_Release(unk);
131  }else {
132  *ppv = unk;
133  }
134  return hres;
135 }
136 
137 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
138 {
139  TRACE("(%p)->(%d)\n", iface, dolock);
140 
141  if (dolock)
142  ITSS_LockModule();
143  else
145 
146  return S_OK;
147 }
148 
149 static const IClassFactoryVtbl ITSSCF_Vtbl =
150 {
156 };
157 
161 
162 /***********************************************************************
163  * DllGetClassObject (ITSS.@)
164  */
166 {
167  const IClassFactoryImpl *factory;
168 
169  TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
170 
171  if (IsEqualGUID(&CLSID_ITStorage, rclsid))
173  else if (IsEqualGUID(&CLSID_MSITStore, rclsid))
175  else if (IsEqualGUID(&CLSID_ITSProtocol, rclsid))
177  else
178  {
179  FIXME("%s: no class found.\n", debugstr_guid(rclsid));
181  }
182 
183  return IUnknown_QueryInterface( (IUnknown*) factory, iid, ppv );
184 }
185 
186 /*****************************************************************************/
187 
188 typedef struct {
191 } ITStorageImpl;
192 
194 {
195  return CONTAINING_RECORD(iface, ITStorageImpl, IITStorage_iface);
196 }
197 
198 
200  IITStorage* iface,
201  REFIID riid,
202  void** ppvObject)
203 {
206  || IsEqualGUID(riid, &IID_IITStorage))
207  {
208  IITStorage_AddRef(iface);
209  *ppvObject = iface;
210  return S_OK;
211  }
212 
213  WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
214  return E_NOINTERFACE;
215 }
216 
218  IITStorage* iface)
219 {
221  TRACE("%p\n", This);
222  return InterlockedIncrement(&This->ref);
223 }
224 
226  IITStorage* iface)
227 {
230 
231  if (ref == 0) {
234  }
235 
236  return ref;
237 }
238 
240  IITStorage* iface,
241  const WCHAR* pwcsName,
242  DWORD grfMode,
243  DWORD reserved,
244  IStorage** ppstgOpen)
245 {
247 
248  TRACE("%p %s %u %u %p\n", This,
249  debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
250 
251  return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
252  0, reserved, ppstgOpen);
253 }
254 
256  IITStorage* iface,
257  ILockBytes* plkbyt,
258  DWORD grfMode,
259  DWORD reserved,
260  IStorage** ppstgOpen)
261 {
263  FIXME("%p\n", This);
264  return E_NOTIMPL;
265 }
266 
268  IITStorage* iface,
269  const WCHAR* pwcsName)
270 {
272  FIXME("%p\n", This);
273  return E_NOTIMPL;
274 }
275 
277  IITStorage* iface,
278  ILockBytes* plkbyt)
279 {
281  FIXME("%p\n", This);
282  return E_NOTIMPL;
283 }
284 
286  IITStorage* iface,
287  const WCHAR* pwcsName,
288  IStorage* pstgPriority,
289  DWORD grfMode,
290  SNB snbExclude,
291  DWORD reserved,
292  IStorage** ppstgOpen)
293 {
295 
296  TRACE("%p %s %p %d %p\n", This, debugstr_w( pwcsName ),
297  pstgPriority, grfMode, snbExclude );
298 
299  return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
300  snbExclude, reserved, ppstgOpen);
301 }
302 
304  IITStorage* iface,
305  ILockBytes* plkbyt,
306  IStorage* pStgPriority,
307  DWORD grfMode,
308  SNB snbExclude,
309  DWORD reserved,
310  IStorage** ppstgOpen)
311 {
313  FIXME("%p\n", This);
314  return E_NOTIMPL;
315 }
316 
318  IITStorage* iface,
319  const WCHAR* lpszName,
320  const FILETIME* pctime,
321  const FILETIME* patime,
322  const FILETIME* pmtime)
323 {
325  FIXME("%p\n", This);
326  return E_NOTIMPL;
327 }
328 
330  IITStorage* iface,
331  PITS_Control_Data pControlData)
332 {
334  FIXME("%p\n", This);
335  return E_NOTIMPL;
336 }
337 
339  IITStorage* iface,
340  PITS_Control_Data* ppControlData)
341 {
343  FIXME("%p\n", This);
344  return E_NOTIMPL;
345 }
346 
348  IITStorage* iface,
349  const WCHAR* pwcsName,
350  ECompactionLev iLev)
351 {
353  FIXME("%p\n", This);
354  return E_NOTIMPL;
355 }
356 
357 static const IITStorageVtbl ITStorageImpl_Vtbl =
358 {
372 };
373 
374 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
375 {
376  ITStorageImpl *its;
377 
378  if( pUnkOuter )
379  return CLASS_E_NOAGGREGATION;
380 
381  its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
382  its->IITStorage_iface.lpVtbl = &ITStorageImpl_Vtbl;
383  its->ref = 1;
384 
385  TRACE("-> %p\n", its);
386  *ppObj = its;
387 
388  ITSS_LockModule();
389  return S_OK;
390 }
391 
392 /*****************************************************************************/
393 
395 {
396  TRACE("dll_count = %u\n", dll_count);
397  return dll_count ? S_FALSE : S_OK;
398 }
399 
400 /***********************************************************************
401  * DllRegisterServer (ITSS.@)
402  */
404 {
406 }
407 
408 /***********************************************************************
409  * DllUnregisterServer (ITSS.@)
410  */
412 {
414 }
static HINSTANCE hInst
Definition: itss.c:52
#define HRESULT
Definition: msvc.h:9
HRESULT WINAPI DllUnregisterServer(void)
Definition: itss.c:411
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
#define E_NOINTERFACE
Definition: winerror.h:2364
static ULONG WINAPI ITStorageImpl_Release(IITStorage *iface)
Definition: itss.c:225
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
static void ITSS_LockModule(void)
Definition: itsstor.h:41
static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
Definition: itss.c:95
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:54
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
Definition: itss.c:165
#define WARN(fmt,...)
Definition: debug.h:111
static HRESULT WINAPI ITStorageImpl_DefaultControlData(IITStorage *iface, PITS_Control_Data *ppControlData)
Definition: itss.c:338
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:120
static const IClassFactoryImpl ITStorage_factory
Definition: itss.c:158
static void ITSS_UnlockModule(void)
Definition: itsstor.h:42
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
Definition: send.c:47
HRESULT WINAPI DllCanUnloadNow(void)
Definition: itss.c:394
static HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(IITStorage *iface, ILockBytes *plkbyt)
Definition: itss.c:276
struct tagIClassFactoryImpl IClassFactoryImpl
static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
Definition: itss.c:101
HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj) DECLSPEC_HIDDEN
Definition: moniker.c:474
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: itss.c:73
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
Definition: main.c:440
#define debugstr_w
Definition: kernel32.h:32
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
r reserved
Definition: btrfs.c:2893
#define S_FALSE
Definition: winerror.h:2357
static const IClassFactoryVtbl ITSSCF_Vtbl
Definition: itss.c:149
smooth NULL
Definition: ftsmooth.c:416
#define debugstr_guid
Definition: kernel32.h:35
IITStorage IITStorage_iface
Definition: itss.c:189
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:255
static HRESULT WINAPI ITStorageImpl_QueryInterface(IITStorage *iface, REFIID riid, void **ppvObject)
Definition: itss.c:199
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT WINAPI ITSSCF_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
Definition: itss.c:108
HRESULT hres
Definition: protocol.c:465
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
Definition: itss.c:137
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
static HRESULT WINAPI ITStorageImpl_Compact(IITStorage *iface, const WCHAR *pwcsName, ECompactionLev iLev)
Definition: itss.c:347
const GUID IID_IUnknown
#define WINAPI
Definition: msvc.h:8
LONG ref
Definition: itss.c:190
unsigned long DWORD
Definition: ntddk_ex.h:95
static const IITStorageVtbl ITStorageImpl_Vtbl
Definition: itss.c:357
HRESULT ITSS_StgOpenStorage(const WCHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen) DECLSPEC_HIDDEN
Definition: storage.c:635
static HRESULT WINAPI ITStorageImpl_StgSetTimes(IITStorage *iface, const WCHAR *lpszName, const FILETIME *pctime, const FILETIME *patime, const FILETIME *pmtime)
Definition: itss.c:317
HRESULT WINAPI DllRegisterServer(void)
Definition: itss.c:403
static ULONG WINAPI ITStorageImpl_AddRef(IITStorage *iface)
Definition: itss.c:217
#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:239
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:329
#define S_OK
Definition: intsafe.h:59
#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:285
static HRESULT WINAPI ITStorageImpl_StgIsStorageFile(IITStorage *iface, const WCHAR *pwcsName)
Definition: itss.c:267
static HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(IITStorage *iface, ILockBytes *plkbyt, IStorage *pStgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: itss.c:303
#define E_NOTIMPL
Definition: ddrawi.h:99
static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: itss.c:374
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
LONG dll_count
Definition: itss.c:51
unsigned int ULONG
Definition: retypes.h:1
static ClassFactoryImpl factory
Definition: ole_server.c:234
static const IClassFactoryImpl ITSProtocol_factory
Definition: itss.c:160
static const IClassFactoryImpl MSITStore_factory
Definition: itss.c:159
static HRESULT WINAPI ITSSCF_QueryInterface(LPCLASSFACTORY iface, REFIID riid, LPVOID *ppobj)
Definition: itss.c:79
const GUID IID_IClassFactory
static ITStorageImpl * impl_from_IITStorage(IITStorage *iface)
Definition: itss.c:193
#define HeapFree(x, y, z)
Definition: compat.h:394