ReactOS 0.4.15-dev-8116-gf69e256
moniker.c
Go to the documentation of this file.
1/*
2 * ITSS Moniker implementation
3 *
4 * Copyright 2004 Mike McCormack
5 *
6 * Implementation of the infamous mk:@MSITStore moniker
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 */
22
23
24#include <stdarg.h>
25#include <stdio.h>
26
27#define COBJMACROS
28
29#include "windef.h"
30#include "winbase.h"
31#include "winuser.h"
32#include "ole2.h"
33
34#include "wine/itss.h"
35#include "wine/debug.h"
36
37#include "itsstor.h"
38
40
41/*****************************************************************************/
42
43typedef struct {
47 WCHAR szFile[1];
49
51{
52 return CONTAINING_RECORD(iface, ITS_IMonikerImpl, IMoniker_iface);
53}
54
55/*** IUnknown methods ***/
57 IMoniker* iface,
59 void** ppvObject)
60{
62
65 {
66 IMoniker_AddRef(iface);
67 *ppvObject = iface;
68 return S_OK;
69 }
70
71 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
72 return E_NOINTERFACE;
73}
74
76 IMoniker* iface)
77{
79 TRACE("%p\n", This);
80 return InterlockedIncrement(&This->ref);
81}
82
84 IMoniker* iface)
85{
88
89 if (ref == 0) {
92 }
93
94 return ref;
95}
96
97/*** IPersist methods ***/
99 IMoniker* iface,
100 CLSID* pClassID)
101{
103
104 TRACE("%p %p\n", This, pClassID);
105 *pClassID = CLSID_ITStorage;
106 return S_OK;
107}
108
109/*** IPersistStream methods ***/
111 IMoniker* iface)
112{
113 FIXME("\n");
114 return E_NOTIMPL;
115}
116
118 IMoniker* iface,
119 IStream* pStm)
120{
121 FIXME("\n");
122 return E_NOTIMPL;
123}
124
126 IMoniker* iface,
127 IStream* pStm,
128 BOOL fClearDirty)
129{
130 FIXME("\n");
131 return E_NOTIMPL;
132}
133
135 IMoniker* iface,
136 ULARGE_INTEGER* pcbSize)
137{
138 FIXME("\n");
139 return E_NOTIMPL;
140}
141
142/*** IMoniker methods ***/
144 IMoniker* iface,
145 IBindCtx* pbc,
146 IMoniker* pmkToLeft,
147 REFIID riidResult,
148 void** ppvResult)
149{
150 FIXME("\n");
151 return E_NOTIMPL;
152}
153
155 IMoniker* iface,
156 IBindCtx* pbc,
157 IMoniker* pmkToLeft,
158 REFIID riid,
159 void** ppvObj)
160{
163 HRESULT r;
164 IStorage *stg = NULL;
165
166 TRACE("%p %p %p %s %p\n", This,
167 pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
168
169 r = ITSS_StgOpenStorage( This->szFile, NULL, grfMode, 0, 0, &stg );
170 if( r == S_OK )
171 {
172 TRACE("Opened storage %s\n", debugstr_w( This->szFile ) );
173 if (IsEqualGUID(riid, &IID_IStream))
174 r = IStorage_OpenStream( stg, This->szHtml,
175 NULL, grfMode, 0, (IStream**)ppvObj );
176 else if (IsEqualGUID(riid, &IID_IStorage))
177 r = IStorage_OpenStorage( stg, This->szHtml,
178 NULL, grfMode, NULL, 0, (IStorage**)ppvObj );
179 else
181 IStorage_Release( stg );
182 }
183
184 return r;
185}
186
188 IMoniker* iface,
189 IBindCtx* pbc,
190 DWORD dwReduceHowFar,
191 IMoniker** ppmkToLeft,
192 IMoniker** ppmkReduced)
193{
194 FIXME("\n");
195 return E_NOTIMPL;
196}
197
199 IMoniker* iface,
200 IMoniker* pmkRight,
201 BOOL fOnlyIfNotGeneric,
202 IMoniker** ppmkComposite)
203{
204 FIXME("\n");
205 return E_NOTIMPL;
206}
207
209 IMoniker* iface,
210 BOOL fForward,
211 IEnumMoniker** ppenumMoniker)
212{
213 FIXME("\n");
214 return E_NOTIMPL;
215}
216
218 IMoniker* iface,
219 IMoniker* pmkOtherMoniker)
220{
221 FIXME("\n");
222 return E_NOTIMPL;
223}
224
226 IMoniker* iface,
227 DWORD* pdwHash)
228{
229 FIXME("\n");
230 return E_NOTIMPL;
231}
232
234 IMoniker* iface,
235 IBindCtx* pbc,
236 IMoniker* pmkToLeft,
237 IMoniker* pmkNewlyRunning)
238{
239 FIXME("\n");
240 return E_NOTIMPL;
241}
242
244 IMoniker* iface,
245 IBindCtx* pbc,
246 IMoniker* pmkToLeft,
247 FILETIME* pFileTime)
248{
249 FIXME("\n");
250 return E_NOTIMPL;
251}
252
254 IMoniker* iface,
255 IMoniker** ppmk)
256{
257 FIXME("\n");
258 return E_NOTIMPL;
259}
260
262 IMoniker* iface,
263 IMoniker* pmkOther,
264 IMoniker** ppmkPrefix)
265{
266 FIXME("\n");
267 return E_NOTIMPL;
268}
269
271 IMoniker* iface,
272 IMoniker* pmkOther,
273 IMoniker** ppmkRelPath)
274{
275 FIXME("\n");
276 return E_NOTIMPL;
277}
278
280 IMoniker* iface,
281 IBindCtx* pbc,
282 IMoniker* pmkToLeft,
283 LPOLESTR* ppszDisplayName)
284{
286 static const WCHAR szFormat[] = {
287 'm','s','-','i','t','s',':','%','s',':',':','%','s',0 };
288 DWORD len;
289 LPWSTR str;
290
291 TRACE("%p %p %p %p\n", iface, pbc, pmkToLeft, ppszDisplayName);
292
293 len = lstrlenW( This->szFile ) + lstrlenW( This->szHtml );
294 str = CoTaskMemAlloc( len*sizeof(WCHAR) );
295 swprintf( str, szFormat, This->szFile, This->szHtml );
296
297 *ppszDisplayName = str;
298
299 return S_OK;
300}
301
303 IMoniker* iface,
304 IBindCtx* pbc,
305 IMoniker* pmkToLeft,
306 LPOLESTR pszDisplayName,
307 ULONG* pchEaten,
308 IMoniker** ppmkOut)
309{
310 FIXME("\n");
311 return E_NOTIMPL;
312}
313
315 IMoniker* iface,
316 DWORD* pdwMksys)
317{
318 FIXME("\n");
319 return E_NOTIMPL;
320}
321
322static const IMonikerVtbl ITS_IMonikerImpl_Vtbl =
323{
347};
348
350{
351 ITS_IMonikerImpl *itsmon;
352 DWORD sz;
353
354 /* szFile[1] has space for one character already */
355 sz = FIELD_OFFSET( ITS_IMonikerImpl, szFile[lstrlenW( name ) + 1] );
356
357 itsmon = HeapAlloc( GetProcessHeap(), 0, sz );
358 itsmon->IMoniker_iface.lpVtbl = &ITS_IMonikerImpl_Vtbl;
359 itsmon->ref = 1;
360 lstrcpyW( itsmon->szFile, name );
361 itsmon->szHtml = &itsmon->szFile[n];
362
363 while( *itsmon->szHtml == ':' )
364 *itsmon->szHtml++ = 0;
365
366 TRACE("-> %p %s %s\n", itsmon,
367 debugstr_w(itsmon->szFile), debugstr_w(itsmon->szHtml) );
368 *ppObj = &itsmon->IMoniker_iface;
369
371 return S_OK;
372}
373
374/*****************************************************************************/
375
376typedef struct {
380
382{
383 return CONTAINING_RECORD(iface, ITS_IParseDisplayNameImpl, IParseDisplayName_iface);
384}
385
387 IParseDisplayName* iface,
388 REFIID riid,
389 void** ppvObject)
390{
392
395 {
396 IParseDisplayName_AddRef(iface);
397 *ppvObject = iface;
398 return S_OK;
399 }
400
401 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
402 return E_NOINTERFACE;
403}
404
406 IParseDisplayName* iface)
407{
409 TRACE("%p\n", This);
410 return InterlockedIncrement(&This->ref);
411}
412
414 IParseDisplayName* iface)
415{
418
419 if (ref == 0) {
422 }
423
424 return ref;
425}
426
428 IParseDisplayName *iface,
429 IBindCtx * pbc,
430 LPOLESTR pszDisplayName,
431 ULONG * pchEaten,
432 IMoniker ** ppmkOut)
433{
434 static const WCHAR szPrefix[] = {
435 '@','M','S','I','T','S','t','o','r','e',':',0 };
436 const DWORD prefix_len = ARRAY_SIZE(szPrefix)-1;
437 DWORD n;
438
440
441 TRACE("%p %s %p %p\n", This,
442 debugstr_w( pszDisplayName ), pchEaten, ppmkOut );
443
444 if( _wcsnicmp( pszDisplayName, szPrefix, prefix_len ) )
445 return MK_E_SYNTAX;
446
447 /* search backwards for a double colon */
448 for( n = lstrlenW( pszDisplayName ) - 3; prefix_len <= n; n-- )
449 if( ( pszDisplayName[n] == ':' ) && ( pszDisplayName[n+1] == ':' ) )
450 break;
451
452 if( n < prefix_len )
453 return MK_E_SYNTAX;
454
455 if( !pszDisplayName[n+2] )
456 return MK_E_SYNTAX;
457
458 *pchEaten = lstrlenW( pszDisplayName ) - n - 3;
459
460 return ITS_IMoniker_create( ppmkOut,
461 &pszDisplayName[prefix_len], n-prefix_len );
462}
463
464static const IParseDisplayNameVtbl ITS_IParseDisplayNameImpl_Vtbl =
465{
470};
471
473{
475
476 if( pUnkOuter )
478
481 its->ref = 1;
482
483 TRACE("-> %p\n", its);
484 *ppObj = its;
485
487 return S_OK;
488}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define ARRAY_SIZE(A)
Definition: main.h:33
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:114
#define WARN(fmt,...)
Definition: debug.h:115
#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
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750
static HRESULT WINAPI ITS_IMonikerImpl_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
Definition: moniker.c:134
static HRESULT WINAPI ITS_IMonikerImpl_GetClassID(IMoniker *iface, CLSID *pClassID)
Definition: moniker.c:98
static ITS_IMonikerImpl * impl_from_IMoniker(IMoniker *iface)
Definition: moniker.c:50
static HRESULT WINAPI ITS_IMonikerImpl_Enum(IMoniker *iface, BOOL fForward, IEnumMoniker **ppenumMoniker)
Definition: moniker.c:208
static HRESULT WINAPI ITS_IMonikerImpl_BindToObject(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riidResult, void **ppvResult)
Definition: moniker.c:143
static HRESULT WINAPI ITS_IMonikerImpl_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, FILETIME *pFileTime)
Definition: moniker.c:243
static HRESULT WINAPI ITS_IParseDisplayNameImpl_QueryInterface(IParseDisplayName *iface, REFIID riid, void **ppvObject)
Definition: moniker.c:386
static const IMonikerVtbl ITS_IMonikerImpl_Vtbl
Definition: moniker.c:322
static const IParseDisplayNameVtbl ITS_IParseDisplayNameImpl_Vtbl
Definition: moniker.c:464
static HRESULT WINAPI ITS_IMonikerImpl_GetDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
Definition: moniker.c:279
static HRESULT WINAPI ITS_IMonikerImpl_IsDirty(IMoniker *iface)
Definition: moniker.c:110
static HRESULT WINAPI ITS_IMonikerImpl_Hash(IMoniker *iface, DWORD *pdwHash)
Definition: moniker.c:225
static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef(IParseDisplayName *iface)
Definition: moniker.c:405
static HRESULT WINAPI ITS_IMonikerImpl_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
Definition: moniker.c:314
static ULONG WINAPI ITS_IMonikerImpl_AddRef(IMoniker *iface)
Definition: moniker.c:75
static HRESULT WINAPI ITS_IMonikerImpl_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, IMoniker *pmkNewlyRunning)
Definition: moniker.c:233
static ULONG WINAPI ITS_IParseDisplayNameImpl_Release(IParseDisplayName *iface)
Definition: moniker.c:413
static HRESULT WINAPI ITS_IMonikerImpl_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
Definition: moniker.c:217
static HRESULT WINAPI ITS_IMonikerImpl_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar, IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
Definition: moniker.c:187
static HRESULT WINAPI ITS_IMonikerImpl_ComposeWith(IMoniker *iface, IMoniker *pmkRight, BOOL fOnlyIfNotGeneric, IMoniker **ppmkComposite)
Definition: moniker.c:198
static HRESULT WINAPI ITS_IMonikerImpl_ParseDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
Definition: moniker.c:302
static ITS_IParseDisplayNameImpl * impl_from_IParseDisplayName(IParseDisplayName *iface)
Definition: moniker.c:381
static HRESULT WINAPI ITS_IParseDisplayNameImpl_ParseDisplayName(IParseDisplayName *iface, IBindCtx *pbc, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
Definition: moniker.c:427
static HRESULT WINAPI ITS_IMonikerImpl_Load(IMoniker *iface, IStream *pStm)
Definition: moniker.c:117
static HRESULT WINAPI ITS_IMonikerImpl_QueryInterface(IMoniker *iface, REFIID riid, void **ppvObject)
Definition: moniker.c:56
static HRESULT WINAPI ITS_IMonikerImpl_Inverse(IMoniker *iface, IMoniker **ppmk)
Definition: moniker.c:253
static HRESULT WINAPI ITS_IMonikerImpl_RelativePathTo(IMoniker *iface, IMoniker *pmkOther, IMoniker **ppmkRelPath)
Definition: moniker.c:270
static HRESULT WINAPI ITS_IMonikerImpl_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
Definition: moniker.c:125
static HRESULT WINAPI ITS_IMonikerImpl_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riid, void **ppvObj)
Definition: moniker.c:154
static ULONG WINAPI ITS_IMonikerImpl_Release(IMoniker *iface)
Definition: moniker.c:83
static HRESULT ITS_IMoniker_create(IMoniker **ppObj, LPCWSTR name, DWORD n)
Definition: moniker.c:349
static HRESULT WINAPI ITS_IMonikerImpl_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther, IMoniker **ppmkPrefix)
Definition: moniker.c:261
HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj)
Definition: moniker.c:472
#define swprintf
Definition: precomp.h:40
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble n
Definition: glext.h:7729
GLenum GLsizei len
Definition: glext.h:6722
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
static void ITSS_LockModule(void)
Definition: itsstor.h:41
static void ITSS_UnlockModule(void)
Definition: itsstor.h:42
HRESULT ITSS_StgOpenStorage(const WCHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen) DECLSPEC_HIDDEN
Definition: storage.c:633
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
static LPOLESTR
Definition: stg_prop.c:27
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:923
#define STGM_SIMPLE
Definition: objbase.h:916
#define STGM_READ
Definition: objbase.h:917
const GUID IID_IParseDisplayName
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
const WCHAR * str
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define TRACE(s)
Definition: solgame.cpp:4
IMoniker IMoniker_iface
Definition: moniker.c:44
WCHAR szFile[1]
Definition: moniker.c:47
LPWSTR szHtml
Definition: moniker.c:46
IParseDisplayName IParseDisplayName_iface
Definition: moniker.c:377
Definition: name.c:39
Definition: send.c:48
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define MK_E_SYNTAX
Definition: winerror.h:2785
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
#define STG_E_ACCESSDENIED
Definition: winerror.h:2568
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185