ReactOS 0.4.16-dev-2332-g4cba65d
filemoniker.c
Go to the documentation of this file.
1/*
2 * FileMonikers implementation
3 *
4 * Copyright 1999 Noomen Hamza
5 * Copyright 2007 Robert Shearman
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#include <assert.h>
23#include <stdarg.h>
24#include <string.h>
25
26#define COBJMACROS
27#include "windef.h"
28#include "winbase.h"
29#include "winerror.h"
30#include "winnls.h"
31#include "wine/debug.h"
32#include "objbase.h"
33#include "moniker.h"
34
35#include "compobj_private.h"
36
38
39/* filemoniker data structure */
40typedef struct FileMonikerImpl{
44 LPOLESTR filePathName; /* path string identified by this filemoniker */
45 IUnknown *pMarshal; /* custom marshaler */
47
49{
50 return CONTAINING_RECORD(iface, FileMonikerImpl, IMoniker_iface);
51}
52
54{
55 return CONTAINING_RECORD(iface, FileMonikerImpl, IROTData_iface);
56}
57
58static const IMonikerVtbl VT_FileMonikerImpl;
59
61{
62 if (iface->lpVtbl != &VT_FileMonikerImpl)
63 return NULL;
64 return CONTAINING_RECORD(iface, FileMonikerImpl, IMoniker_iface);
65}
66
67/* Local function used by filemoniker implementation */
68static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName);
69
70/*******************************************************************************
71 * FileMoniker_QueryInterface
72 */
74{
76
77 TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), ppvObject);
78
79 if (!ppvObject)
80 return E_INVALIDARG;
81
82 *ppvObject = 0;
83
87 IsEqualIID(&IID_IMoniker, riid) ||
88 IsEqualGUID(&CLSID_FileMoniker, riid))
89 {
90 *ppvObject = iface;
91 }
92 else if (IsEqualIID(&IID_IROTData, riid))
93 *ppvObject = &This->IROTData_iface;
94 else if (IsEqualIID(&IID_IMarshal, riid))
95 {
96 HRESULT hr = S_OK;
97 if (!This->pMarshal)
98 hr = MonikerMarshal_Create(iface, &This->pMarshal);
99 if (hr != S_OK)
100 return hr;
101 return IUnknown_QueryInterface(This->pMarshal, riid, ppvObject);
102 }
103
104 if (!*ppvObject)
105 return E_NOINTERFACE;
106
107 IMoniker_AddRef(iface);
108
109 return S_OK;
110}
111
112/******************************************************************************
113 * FileMoniker_AddRef
114 */
115static ULONG WINAPI
117{
119
120 TRACE("(%p)\n",iface);
121
122 return InterlockedIncrement(&This->ref);
123}
124
126{
129
130 TRACE("%p, refcount %lu.\n", iface, ref);
131
132 if (!ref)
133 {
134 if (moniker->pMarshal) IUnknown_Release(moniker->pMarshal);
135 free(moniker->filePathName);
136 free(moniker);
137 }
138
139 return ref;
140}
141
142/******************************************************************************
143 * FileMoniker_GetClassID
144 */
145static HRESULT WINAPI
147{
148 TRACE("(%p,%p)\n",iface,pClassID);
149
150 if (pClassID==NULL)
151 return E_POINTER;
152
153 *pClassID = CLSID_FileMoniker;
154
155 return S_OK;
156}
157
158/******************************************************************************
159 * FileMoniker_IsDirty
160 *
161 * Note that the OLE-provided implementations of the IPersistStream::IsDirty
162 * method in the OLE-provided moniker interfaces always return S_FALSE because
163 * their internal state never changes.
164 */
165static HRESULT WINAPI
167{
168
169 TRACE("(%p)\n",iface);
170
171 return S_FALSE;
172}
173
174/******************************************************************************
175 * FileMoniker_Load
176 *
177 * this function locates and reads from the stream the filePath string
178 * written by FileMonikerImpl_Save
179 */
180static HRESULT WINAPI
182{
184 HRESULT res;
185 CHAR* filePathA = NULL;
186 WCHAR* filePathW = NULL;
187 ULONG bread;
188 WORD wbuffer;
189 DWORD dwbuffer, bytesA, bytesW, len;
190 int i;
191
192
193 TRACE("(%p,%p)\n",iface,pStm);
194
195 /* first WORD */
196 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
197 if (bread!=sizeof(WORD))
198 {
199 WARN("Couldn't read 0 word\n");
200 goto fail;
201 }
202
203 /* read filePath string length (plus one) */
204 res=IStream_Read(pStm,&bytesA,sizeof(DWORD),&bread);
205 if (bread != sizeof(DWORD))
206 {
207 WARN("Couldn't read file string length\n");
208 goto fail;
209 }
210
211 /* read filePath string */
212 filePathA = malloc(bytesA);
213 if (!filePathA)
214 {
216 goto fail;
217 }
218
219 res=IStream_Read(pStm,filePathA,bytesA,&bread);
220 if (bread != bytesA)
221 {
222 WARN("Couldn't read file path string\n");
223 goto fail;
224 }
225
226 /* read the unknown value */
227 IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
228 if (bread != sizeof(WORD))
229 {
230 WARN("Couldn't read unknown value\n");
231 goto fail;
232 }
233
234 /* read the DEAD constant */
235 IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
236 if (bread != sizeof(WORD))
237 {
238 WARN("Couldn't read DEAD constant\n");
239 goto fail;
240 }
241
242 for(i=0;i<5;i++)
243 {
244 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
245 if (bread!=sizeof(DWORD))
246 {
247 WARN("Couldn't read 0 padding\n");
248 goto fail;
249 }
250 }
251
252 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
253 if (bread!=sizeof(DWORD))
254 goto fail;
255
256 if (!dwbuffer) /* No W-string */
257 {
258 bytesA--;
259 len=MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, bytesA, NULL, 0);
260 if (!len)
261 goto fail;
262
263 filePathW = malloc((len + 1) * sizeof(WCHAR));
264 if (!filePathW)
265 {
267 goto fail;
268 }
269 MultiByteToWideChar(CP_ACP, MB_ERR_INVALID_CHARS, filePathA, -1, filePathW, len+1);
270 goto succeed;
271 }
272
273 if (dwbuffer < 6)
274 goto fail;
275
276 bytesW=dwbuffer - 6;
277
278 res=IStream_Read(pStm,&dwbuffer,sizeof(DWORD),&bread);
279 if (bread!=sizeof(DWORD) || dwbuffer!=bytesW)
280 goto fail;
281
282 res=IStream_Read(pStm,&wbuffer,sizeof(WORD),&bread);
283 if (bread!=sizeof(WORD) || wbuffer!=0x3)
284 goto fail;
285
286 len=bytesW/sizeof(WCHAR);
287 filePathW = malloc((len + 1) * sizeof(WCHAR));
288 if(!filePathW)
289 {
291 goto fail;
292 }
293 res=IStream_Read(pStm,filePathW,bytesW,&bread);
294 if (bread!=bytesW)
295 goto fail;
296
297 filePathW[len]=0;
298
299 succeed:
300 free(filePathA);
301 free(This->filePathName);
302 This->filePathName=filePathW;
303
304 return S_OK;
305
306 fail:
307 free(filePathA);
308 free(filePathW);
309
310 if (SUCCEEDED(res))
311 res = E_FAIL;
312 return res;
313}
314
315/******************************************************************************
316 * FileMoniker_Save
317 *
318 * This function saves data of this object. In the beginning I thought
319 * that I have just to write the filePath string on Stream. But, when I
320 * tested this function with windows program samples, I noticed that it
321 * was not the case. This implementation is based on XP SP2. Other versions
322 * of Windows have minor variations.
323 *
324 * Data which must be written on stream is:
325 * 1) WORD constant: zero (not validated by Windows)
326 * 2) length of the path string ("\0" included)
327 * 3) path string type A
328 * 4) Unknown WORD value: Frequently 0xFFFF, but not always. If set very large,
329 * Windows returns E_OUTOFMEMORY
330 * 5) WORD Constant: 0xDEAD (not validated by Windows)
331 * 6) five DWORD constant: zero (not validated by Windows)
332 * 7) If we're only writing the multibyte version,
333 * write a zero DWORD and finish.
334 *
335 * 8) DWORD: double-length of the path string type W ("\0" not
336 * included)
337 * 9) WORD constant: 0x3
338 * 10) filePath unicode string.
339 *
340 */
341static HRESULT WINAPI
342FileMonikerImpl_Save(IMoniker* iface, IStream* pStm, BOOL fClearDirty)
343{
345 HRESULT res;
346 LPOLESTR filePathW=This->filePathName;
347 CHAR* filePathA;
348 DWORD bytesA, bytesW, len;
349
350 static const WORD FFFF = 0xFFFF; /* Constants */
351 static const WORD DEAD = 0xDEAD;
352 static const DWORD ZERO = 0;
353 static const WORD THREE = 0x3;
354
355 int i;
356 BOOL bUsedDefault, bWriteWide;
357
358 TRACE("(%p,%p,%d)\n",iface,pStm,fClearDirty);
359
360 if (pStm==NULL)
361 return E_POINTER;
362
363 /* write a 0 WORD */
364 res=IStream_Write(pStm,&ZERO,sizeof(WORD),NULL);
365 if (FAILED(res)) return res;
366
367 /* write length of filePath string ( 0 included )*/
368 bytesA = WideCharToMultiByte( CP_ACP, 0, filePathW, -1, NULL, 0, NULL, NULL );
369 res=IStream_Write(pStm,&bytesA,sizeof(DWORD),NULL);
370 if (FAILED(res)) return res;
371
372 /* write A string (with '\0') */
373 filePathA = malloc(bytesA);
374 if (!filePathA)
375 return E_OUTOFMEMORY;
376 WideCharToMultiByte( CP_ACP, 0, filePathW, -1, filePathA, bytesA, NULL, &bUsedDefault);
377 res=IStream_Write(pStm,filePathA,bytesA,NULL);
378 free(filePathA);
379 if (FAILED(res)) return res;
380
381 /* write a WORD 0xFFFF */
382 res=IStream_Write(pStm,&FFFF,sizeof(WORD),NULL);
383 if (FAILED(res)) return res;
384
385 /* write a WORD 0xDEAD */
386 res=IStream_Write(pStm,&DEAD,sizeof(WORD),NULL);
387 if (FAILED(res)) return res;
388
389 /* write 5 zero DWORDs */
390 for(i=0;i<5;i++)
391 {
392 res=IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
393 if (FAILED(res)) return res;
394 }
395
396 /* Write the wide version if:
397 * + couldn't convert to CP_ACP,
398 * or + it's a directory,
399 * or + there's a character > 0xFF
400 */
401 len = lstrlenW(filePathW);
402 bWriteWide = (bUsedDefault || (len > 0 && filePathW[len-1]=='\\' ));
403 if (!bWriteWide)
404 {
405 WCHAR* pch;
406 for(pch=filePathW;*pch;++pch)
407 {
408 if (*pch > 0xFF)
409 {
410 bWriteWide = TRUE;
411 break;
412 }
413 }
414 }
415
416 if (!bWriteWide)
417 return IStream_Write(pStm,&ZERO,sizeof(DWORD),NULL);
418
419 /* write bytes needed for the filepathW (without 0) + 6 */
420 bytesW = len*sizeof(WCHAR) + 6;
421 res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
422 if (FAILED(res)) return res;
423
424 /* try again, without the extra 6 */
425 bytesW -= 6;
426 res=IStream_Write(pStm,&bytesW,sizeof(DWORD),NULL);
427 if (FAILED(res)) return res;
428
429 /* write a WORD 3 */
430 res=IStream_Write(pStm,&THREE,sizeof(WORD),NULL);
431 if (FAILED(res)) return res;
432
433 /* write W string (no 0) */
434 return IStream_Write(pStm,filePathW,bytesW,NULL);
435}
436
437/******************************************************************************
438 * FileMoniker_GetSizeMax
439 */
440static HRESULT WINAPI
442{
444
445 TRACE("(%p,%p)\n",iface,pcbSize);
446
447 if (!pcbSize)
448 return E_POINTER;
449
450 /* We could calculate exactly (see ...::Save()) but instead
451 * we'll make a quick over-estimate, like Windows (NT4, XP) does.
452 */
453 pcbSize->u.LowPart = 0x38 + 4 * lstrlenW(This->filePathName);
454 pcbSize->u.HighPart = 0;
455
456 return S_OK;
457}
458
459/******************************************************************************
460 * FileMoniker_BindToObject
461 */
462static HRESULT WINAPI
464 REFIID riid, VOID** ppvResult)
465{
468 CLSID clsID;
469 IUnknown* pObj=0;
470 IRunningObjectTable *prot=0;
471 IPersistFile *ppf=0;
472 IClassFactory *pcf=0;
474
475 *ppvResult=0;
476
477 TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvResult);
478
479 if(pmkToLeft==NULL){
480
481 res=IBindCtx_GetRunningObjectTable(pbc,&prot);
482
483 if (SUCCEEDED(res)){
484 /* if the requested class was loaded before ! we don't need to reload it */
485 res = IRunningObjectTable_GetObject(prot,iface,&pObj);
486
487 if (res != S_OK){
488 /* first activation of this class */
489 res=GetClassFile(This->filePathName,&clsID);
490 if (SUCCEEDED(res)){
491
492 res=CoCreateInstance(&clsID,NULL,CLSCTX_SERVER,&IID_IPersistFile,(void**)&ppf);
493 if (SUCCEEDED(res)){
494
495 res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
496 if (SUCCEEDED(res)){
497
498 pObj=(IUnknown*)ppf;
499 IUnknown_AddRef(pObj);
500 }
501 }
502 }
503 }
504 }
505 }
506 else{
507 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassFactory,(void**)&pcf);
508
509 if (res==E_NOINTERFACE){
510
511 res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IClassActivator,(void**)&pca);
512
513 if (res==E_NOINTERFACE)
515 }
516 if (pcf!=NULL){
517
518 IClassFactory_CreateInstance(pcf,NULL,&IID_IPersistFile,(void**)&ppf);
519
520 res=IPersistFile_Load(ppf,This->filePathName,STGM_READ);
521
522 if (SUCCEEDED(res)){
523
524 pObj=(IUnknown*)ppf;
525 IUnknown_AddRef(pObj);
526 }
527 }
528 if (pca!=NULL){
529
530 FIXME("()\n");
531
532 /*res=GetClassFile(This->filePathName,&clsID);
533
534 if (SUCCEEDED(res)){
535
536 res=IClassActivator_GetClassObject(pca,&clsID,CLSCTX_ALL,0,&IID_IPersistFile,(void**)&ppf);
537
538 if (SUCCEEDED(res)){
539
540 pObj=(IUnknown*)ppf;
541 IUnknown_AddRef(pObj);
542 }
543 }*/
544 }
545 }
546
547 if (pObj!=NULL){
548 /* get the requested interface from the loaded class */
549 res= IUnknown_QueryInterface(pObj,riid,ppvResult);
550
551 IBindCtx_RegisterObjectBound(pbc,*ppvResult);
552
553 IUnknown_Release(pObj);
554 }
555
556 if (prot!=NULL)
557 IRunningObjectTable_Release(prot);
558
559 if (ppf!=NULL)
560 IPersistFile_Release(ppf);
561
562 if (pca!=NULL)
563 IClassActivator_Release(pca);
564
565 if (pcf!=NULL)
566 IClassFactory_Release(pcf);
567
568 return res;
569}
570
571/******************************************************************************
572 * FileMoniker_BindToStorage
573 */
574static HRESULT WINAPI
576 REFIID riid, void **object)
577{
579 BIND_OPTS bind_opts;
580 HRESULT hr;
581
582 TRACE("(%p,%p,%p,%s,%p)\n", iface, pbc, pmkToLeft, debugstr_guid(riid), object);
583
584 if (!pbc)
585 return E_INVALIDARG;
586
587 bind_opts.cbStruct = sizeof(bind_opts);
588 hr = IBindCtx_GetBindOptions(pbc, &bind_opts);
589 if (FAILED(hr))
590 return hr;
591
592 if (!pmkToLeft)
593 {
594 if (IsEqualIID(&IID_IStorage, riid))
595 {
596 return StgOpenStorage(moniker->filePathName, NULL, bind_opts.grfMode, NULL, 0, (IStorage **)object);
597 }
598 else if ((IsEqualIID(&IID_IStream, riid)) || (IsEqualIID(&IID_ILockBytes, riid)))
599 return E_FAIL;
600 else
601 return E_NOINTERFACE;
602 }
603
604 FIXME("(%p,%p,%p,%s,%p)\n", iface, pbc, pmkToLeft, debugstr_guid(riid), object);
605
606 return E_NOTIMPL;
607}
608
610 IMoniker **toleft, IMoniker **reduced)
611{
612 TRACE("%p, %p, %ld, %p, %p.\n", iface, pbc, howfar, toleft, reduced);
613
614 if (!pbc || !reduced)
615 return E_INVALIDARG;
616
617 IMoniker_AddRef(iface);
618 *reduced = iface;
619
621}
622
623static void free_stringtable(LPOLESTR *stringTable)
624{
625 int i;
626
627 for (i=0; stringTable[i]!=NULL; i++)
628 CoTaskMemFree(stringTable[i]);
629 CoTaskMemFree(stringTable);
630}
631
632static int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
633{
635 int i=0,j,tabIndex=0, ret=0;
636 LPOLESTR *strgtable ;
637
638 int len=lstrlenW(str);
639
640 TRACE("%s, %p\n", debugstr_w(str), *stringTable);
641
642 strgtable = CoTaskMemAlloc((len + 1)*sizeof(*strgtable));
643
644 if (strgtable==NULL)
645 return E_OUTOFMEMORY;
646
647 word = CoTaskMemAlloc((len + 1)*sizeof(WCHAR));
648
649 if (word==NULL)
650 {
652 goto lend;
653 }
654
655 while(str[i]!=0){
656
657 if (str[i] == L'\\')
658 {
659
660 strgtable[tabIndex]=CoTaskMemAlloc(2*sizeof(WCHAR));
661
662 if (strgtable[tabIndex]==NULL)
663 {
665 goto lend;
666 }
667
668 lstrcpyW(strgtable[tabIndex++], L"\\");
669
670 i++;
671
672 }
673 else {
674
675 for (j = 0; str[i] && str[i] != L'\\'; i++, j++)
676 word[j]=str[i];
677
678 word[j]=0;
679
680 strgtable[tabIndex]=CoTaskMemAlloc(sizeof(WCHAR)*(j+1));
681
682 if (strgtable[tabIndex]==NULL)
683 {
685 goto lend;
686 }
687
688 lstrcpyW(strgtable[tabIndex++],word);
689 }
690 }
691 strgtable[tabIndex]=NULL;
692
693 *stringTable=strgtable;
694
695 ret = tabIndex;
696
697lend:
698 if (ret < 0)
699 {
700 for (i = 0; i < tabIndex; i++)
701 CoTaskMemFree(strgtable[i]);
702
703 CoTaskMemFree(strgtable);
704 }
705
707
708 return ret;
709}
710
711/******************************************************************************
712 * FileMoniker_ComposeWith
713 */
714static HRESULT WINAPI
716 BOOL fOnlyIfNotGeneric, IMoniker** ppmkComposite)
717{
718 HRESULT res;
719 LPOLESTR str1=0,str2=0,*strDec1=0,*strDec2=0,newStr=0;
720 IBindCtx *bind=0;
721 int i=0,j=0,lastIdx1=0,lastIdx2=0;
722 DWORD mkSys, order;
723
724 TRACE("(%p,%p,%d,%p)\n",iface,pmkRight,fOnlyIfNotGeneric,ppmkComposite);
725
726 if (ppmkComposite==NULL)
727 return E_POINTER;
728
729 if (pmkRight==NULL)
730 return E_INVALIDARG;
731
732 *ppmkComposite=0;
733
734 IMoniker_IsSystemMoniker(pmkRight,&mkSys);
735
736 /* check if we have two FileMonikers to compose or not */
737 if(mkSys==MKSYS_FILEMONIKER){
738
740
741 IMoniker_GetDisplayName(iface,bind,NULL,&str1);
742 IMoniker_GetDisplayName(pmkRight,bind,NULL,&str2);
743
744 /* decompose pathnames of the two monikers : (to prepare the path merge operation ) */
745 lastIdx1=FileMonikerImpl_DecomposePath(str1,&strDec1)-1;
746 lastIdx2=FileMonikerImpl_DecomposePath(str2,&strDec2)-1;
747
748 if ((lastIdx1 == -1 && lastIdx2 > -1) || (lastIdx1 == 1 && !wcscmp(strDec1[0], L"..")))
750 else{
751 if (!wcscmp(strDec1[lastIdx1], L"\\"))
752 lastIdx1--;
753
754 /* for each "..\" in the left of str2 remove the right element from str1 */
755 for (i = 0; lastIdx1 >= 0 && strDec2[i] && !wcscmp(strDec2[i], L".."); i += 2)
756 lastIdx1-=2;
757
758 /* the length of the composed path string is increased by the sum of the two paths' lengths */
759 newStr = malloc(sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
760
761 if (newStr){
762 /* new path is the concatenation of the rest of str1 and str2 */
763 for(*newStr=0,j=0;j<=lastIdx1;j++)
764 lstrcatW(newStr,strDec1[j]);
765
766 if ((!strDec2[i] && lastIdx1 > -1 && lastIdx2 > -1) || wcscmp(strDec2[i], L"\\"))
767 lstrcatW(newStr, L"\\");
768
769 for(j=i;j<=lastIdx2;j++)
770 lstrcatW(newStr,strDec2[j]);
771
772 /* create a new moniker with the new string */
773 res=CreateFileMoniker(newStr,ppmkComposite);
774
775 free(newStr);
776 }
777 else res = E_OUTOFMEMORY;
778 }
779
780 free_stringtable(strDec1);
781 free_stringtable(strDec2);
782
785
786 return res;
787 }
788 else if (is_anti_moniker(pmkRight, &order))
789 {
790 return order > 1 ? create_anti_moniker(order - 1, ppmkComposite) : S_OK;
791 }
792 else if (fOnlyIfNotGeneric){
793
794 *ppmkComposite=NULL;
795 return MK_E_NEEDGENERIC;
796 }
797 else
798
799 return CreateGenericComposite(iface,pmkRight,ppmkComposite);
800}
801
802/******************************************************************************
803 * FileMoniker_Enum
804 */
805static HRESULT WINAPI
806FileMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker)
807{
808 TRACE("(%p,%d,%p)\n",iface,fForward,ppenumMoniker);
809
810 if (ppenumMoniker == NULL)
811 return E_POINTER;
812
813 *ppenumMoniker = NULL;
814
815 return S_OK;
816}
817
819{
820 FileMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
821
822 TRACE("%p, %p.\n", iface, other);
823
824 if (!other)
825 return E_INVALIDARG;
826
827 other_moniker = unsafe_impl_from_IMoniker(other);
828 if (!other_moniker)
829 return S_FALSE;
830
831 return !wcsicmp(moniker->filePathName, other_moniker->filePathName) ? S_OK : S_FALSE;
832}
833
834/******************************************************************************
835 * FileMoniker_Hash
836 */
837static HRESULT WINAPI
839{
841 int h = 0,i,skip,len;
842 int off = 0;
844
845 if (pdwHash==NULL)
846 return E_POINTER;
847
848 val = This->filePathName;
849 len = lstrlenW(val);
850
851 if (len < 16) {
852 for (i = len ; i > 0; i--) {
853 h = (h * 37) + val[off++];
854 }
855 } else {
856 /* only sample some characters */
857 skip = len / 8;
858 for (i = len ; i > 0; i -= skip, off += skip) {
859 h = (h * 39) + val[off];
860 }
861 }
862
863 *pdwHash=h;
864
865 return S_OK;
866}
867
868/******************************************************************************
869 * FileMoniker_IsRunning
870 */
871static HRESULT WINAPI
873 IMoniker* pmkNewlyRunning)
874{
876 HRESULT res;
877
878 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pmkNewlyRunning);
879
880 if ( (pmkNewlyRunning!=NULL) && (IMoniker_IsEqual(pmkNewlyRunning,iface)==S_OK) )
881 return S_OK;
882
883 if (pbc==NULL)
884 return E_POINTER;
885
886 res=IBindCtx_GetRunningObjectTable(pbc,&rot);
887
888 if (FAILED(res))
889 return res;
890
891 res = IRunningObjectTable_IsRunning(rot,iface);
892
893 IRunningObjectTable_Release(rot);
894
895 return res;
896}
897
898/******************************************************************************
899 * FileMoniker_GetTimeOfLastChange
900 ******************************************************************************/
901static HRESULT WINAPI
903 IMoniker* pmkToLeft, FILETIME* pFileTime)
904{
907 HRESULT res;
909
910 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,pFileTime);
911
912 if (pFileTime==NULL)
913 return E_POINTER;
914
915 if (pmkToLeft!=NULL)
916 return E_INVALIDARG;
917
918 res=IBindCtx_GetRunningObjectTable(pbc,&rot);
919
920 if (FAILED(res))
921 return res;
922
923 res= IRunningObjectTable_GetTimeOfLastChange(rot,iface,pFileTime);
924
925 if (FAILED(res)){ /* the moniker is not registered */
926
928 return MK_E_NOOBJECT;
929
930 *pFileTime=info.ftLastWriteTime;
931 }
932
933 return S_OK;
934}
935
936/******************************************************************************
937 * FileMoniker_Inverse
938 */
939static HRESULT WINAPI
941{
942 TRACE("(%p,%p)\n",iface,ppmk);
943
944 return CreateAntiMoniker(ppmk);
945}
946
947/******************************************************************************
948 * FileMoniker_CommonPrefixWith
949 */
950static HRESULT WINAPI
952{
953
954 LPOLESTR pathThis = NULL, pathOther = NULL, *stringTable1 = NULL;
955 LPOLESTR *stringTable2 = NULL, commonPath = NULL;
956 IBindCtx *bindctx;
957 DWORD mkSys;
958 ULONG nb1,nb2,i,sameIdx;
959 BOOL machineNameCase = FALSE;
960 HRESULT ret;
961
962 if (ppmkPrefix==NULL)
963 return E_POINTER;
964
965 if (pmkOther==NULL)
966 return E_INVALIDARG;
967
968 *ppmkPrefix=0;
969
970 /* check if we have the same type of moniker */
971 IMoniker_IsSystemMoniker(pmkOther,&mkSys);
972 if (mkSys != MKSYS_FILEMONIKER)
973 return MonikerCommonPrefixWith(iface, pmkOther, ppmkPrefix);
974
975 ret = CreateBindCtx(0, &bindctx);
976 if (FAILED(ret))
977 return ret;
978
979 /* create a string based on common part of the two paths */
980 ret = IMoniker_GetDisplayName(iface, bindctx, NULL, &pathThis);
981 if (FAILED(ret))
982 goto failed;
983
984 ret = IMoniker_GetDisplayName(pmkOther, bindctx, NULL, &pathOther);
985 if (FAILED(ret))
986 goto failed;
987
988 nb1 = FileMonikerImpl_DecomposePath(pathThis, &stringTable1);
989 if (FAILED(nb1)) {
990 ret = nb1;
991 goto failed;
992 }
993
994 nb2 = FileMonikerImpl_DecomposePath(pathOther, &stringTable2);
995 if (FAILED(nb2)) {
996 ret = nb2;
997 goto failed;
998 }
999
1000 if (nb1 == 0 || nb2 == 0) {
1002 goto failed;
1003 }
1004
1005 commonPath = CoTaskMemAlloc(sizeof(WCHAR)*(min(lstrlenW(pathThis),lstrlenW(pathOther))+1));
1006 if (!commonPath) {
1008 goto failed;
1009 }
1010
1011 *commonPath = 0;
1012 for(sameIdx=0; ( (stringTable1[sameIdx]!=NULL) &&
1013 (stringTable2[sameIdx]!=NULL) &&
1014 (lstrcmpiW(stringTable1[sameIdx],stringTable2[sameIdx])==0)); sameIdx++);
1015
1016 if (sameIdx > 1 && *stringTable1[0]=='\\' && *stringTable2[1]=='\\'){
1017 machineNameCase = TRUE;
1018
1019 for(i=2;i<sameIdx;i++)
1020 if( (*stringTable1[i]=='\\') && (i+1 < sameIdx) && (*stringTable1[i+1]=='\\') ){
1021 machineNameCase = FALSE;
1022 break;
1023 }
1024 }
1025
1026 if (machineNameCase && *stringTable1[sameIdx-1]=='\\')
1027 sameIdx--;
1028
1029 if (machineNameCase && (sameIdx<=3) && (nb1 > 3 || nb2 > 3) )
1031 else
1032 {
1033 for (i = 0; i < sameIdx; i++)
1034 lstrcatW(commonPath,stringTable1[i]);
1035 ret = CreateFileMoniker(commonPath, ppmkPrefix);
1036 }
1037
1038failed:
1039 IBindCtx_Release(bindctx);
1040 CoTaskMemFree(pathThis);
1041 CoTaskMemFree(pathOther);
1042 CoTaskMemFree(commonPath);
1043 if (stringTable1) free_stringtable(stringTable1);
1044 if (stringTable2) free_stringtable(stringTable2);
1045
1046 return ret;
1047}
1048
1049/******************************************************************************
1050 * FileMoniker_RelativePathTo
1051 */
1052static HRESULT WINAPI
1054{
1055 IBindCtx *bind;
1056 HRESULT res;
1057 LPOLESTR str1=0,str2=0,*tabStr1=0,*tabStr2=0,relPath=0;
1058 DWORD len1=0,len2=0,sameIdx=0,j=0;
1059
1060 TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
1061
1062 if (ppmkRelPath==NULL)
1063 return E_POINTER;
1064
1065 if (pmOther==NULL)
1066 return E_INVALIDARG;
1067
1069 if (FAILED(res))
1070 return res;
1071
1072 res=IMoniker_GetDisplayName(iface,bind,NULL,&str1);
1073 if (FAILED(res))
1074 return res;
1075 res=IMoniker_GetDisplayName(pmOther,bind,NULL,&str2);
1076 if (FAILED(res))
1077 return res;
1078
1079 len1=FileMonikerImpl_DecomposePath(str1,&tabStr1);
1080 if (FAILED(len1))
1081 return E_OUTOFMEMORY;
1082 len2=FileMonikerImpl_DecomposePath(str2,&tabStr2);
1083
1084 if (FAILED(len2))
1085 {
1086 free_stringtable(tabStr1);
1087 return E_OUTOFMEMORY;
1088 }
1089
1090 /* count the number of similar items from the begin of the two paths */
1091 for(sameIdx=0; ( (tabStr1[sameIdx]!=NULL) &&
1092 (tabStr2[sameIdx]!=NULL) &&
1093 (lstrcmpiW(tabStr1[sameIdx],tabStr2[sameIdx])==0)); sameIdx++);
1094
1095 /* begin the construction of relativePath */
1096 /* if the two paths have a consecutive similar item from the begin ! the relativePath will be composed */
1097 /* by "..\\" in the begin */
1098 relPath = malloc(sizeof(WCHAR)*(1+lstrlenW(str1)+lstrlenW(str2)));
1099
1100 *relPath=0;
1101
1102 if (len2>0 && !(len1==1 && len2==1 && sameIdx==0))
1103 for(j=sameIdx;(tabStr1[j] != NULL); j++)
1104 if (*tabStr1[j]!='\\')
1105 lstrcatW(relPath, L"..\\");
1106
1107 /* add items of the second path (similar items with the first path are not included) to the relativePath */
1108 for(j=sameIdx;tabStr2[j]!=NULL;j++)
1109 lstrcatW(relPath,tabStr2[j]);
1110
1111 res=CreateFileMoniker(relPath,ppmkRelPath);
1112
1113 free_stringtable(tabStr1);
1114 free_stringtable(tabStr2);
1117 free(relPath);
1118
1119 if (len1==0 || len2==0 || (len1==1 && len2==1 && sameIdx==0))
1120 return MK_S_HIM;
1121
1122 return res;
1123}
1124
1125/******************************************************************************
1126 * FileMoniker_GetDisplayName
1127 */
1128static HRESULT WINAPI
1130 IMoniker* pmkToLeft, LPOLESTR *ppszDisplayName)
1131{
1133 int len=lstrlenW(This->filePathName);
1134
1135 TRACE("(%p,%p,%p,%p)\n",iface,pbc,pmkToLeft,ppszDisplayName);
1136
1137 if (ppszDisplayName==NULL)
1138 return E_POINTER;
1139
1140 if (pmkToLeft!=NULL)
1141 return E_INVALIDARG;
1142
1143 *ppszDisplayName=CoTaskMemAlloc(sizeof(WCHAR)*(len+1));
1144 if (*ppszDisplayName==NULL)
1145 return E_OUTOFMEMORY;
1146
1147 lstrcpyW(*ppszDisplayName,This->filePathName);
1148
1149 TRACE("-- %s\n", debugstr_w(*ppszDisplayName));
1150
1151 return S_OK;
1152}
1153
1154/******************************************************************************
1155 * FileMoniker_ParseDisplayName
1156 */
1157static HRESULT WINAPI
1159 LPOLESTR pszDisplayName, ULONG* pchEaten, IMoniker** ppmkOut)
1160{
1161 FIXME("(%p,%p,%p,%p,%p,%p),stub!\n",iface,pbc,pmkToLeft,pszDisplayName,pchEaten,ppmkOut);
1162 return E_NOTIMPL;
1163}
1164
1165/******************************************************************************
1166 * FileMoniker_IsSystemMoniker
1167 */
1168static HRESULT WINAPI
1170{
1171 TRACE("(%p,%p)\n",iface,pwdMksys);
1172
1173 if (!pwdMksys)
1174 return E_POINTER;
1175
1176 (*pwdMksys)=MKSYS_FILEMONIKER;
1177
1178 return S_OK;
1179}
1180
1181/*******************************************************************************
1182 * FileMonikerIROTData_QueryInterface
1183 */
1184static HRESULT WINAPI
1186{
1187
1189
1190 TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
1191
1192 return FileMonikerImpl_QueryInterface(&This->IMoniker_iface, riid, ppvObject);
1193}
1194
1195/***********************************************************************
1196 * FileMonikerIROTData_AddRef
1197 */
1198static ULONG WINAPI
1200{
1202
1203 TRACE("(%p)\n",This);
1204
1205 return IMoniker_AddRef(&This->IMoniker_iface);
1206}
1207
1208/***********************************************************************
1209 * FileMonikerIROTData_Release
1210 */
1211static ULONG WINAPI
1213{
1215
1216 TRACE("(%p)\n",This);
1217
1218 return FileMonikerImpl_Release(&This->IMoniker_iface);
1219}
1220
1221/******************************************************************************
1222 * FileMonikerIROTData_GetComparisonData
1223 */
1224static HRESULT WINAPI
1226 ULONG cbMax, ULONG* pcbData)
1227{
1229 int len = lstrlenW(This->filePathName)+1;
1230 int i;
1232
1233 TRACE("%p, %p, %lu, %p.\n", iface, pbData, cbMax, pcbData);
1234
1235 *pcbData = sizeof(CLSID) + len * sizeof(WCHAR);
1236 if (cbMax < *pcbData)
1237 return E_OUTOFMEMORY;
1238
1239 memcpy(pbData, &CLSID_FileMoniker, sizeof(CLSID));
1240 pszFileName = (LPWSTR)(pbData+sizeof(CLSID));
1241 for (i = 0; i < len; i++)
1242 pszFileName[i] = towupper(This->filePathName[i]);
1243
1244 return S_OK;
1245}
1246
1247/*
1248 * Virtual function table for the FileMonikerImpl class which include IPersist,
1249 * IPersistStream and IMoniker functions.
1250 */
1251static const IMonikerVtbl VT_FileMonikerImpl =
1252{
1276};
1277
1278/* Virtual function table for the IROTData class. */
1279static const IROTDataVtbl VT_ROTDataImpl =
1280{
1285};
1286
1287/******************************************************************************
1288 * FileMoniker_Construct (local function)
1289 */
1291{
1292 int nb=0,i;
1293 int sizeStr=lstrlenW(lpszPathName);
1294 LPOLESTR *tabStr=0;
1295 BOOL addBkSlash;
1296
1297 TRACE("(%p,%s)\n",This,debugstr_w(lpszPathName));
1298
1299 /* Initialize the virtual function table. */
1300 This->IMoniker_iface.lpVtbl = &VT_FileMonikerImpl;
1301 This->IROTData_iface.lpVtbl = &VT_ROTDataImpl;
1302 This->ref = 0;
1303 This->pMarshal = NULL;
1304
1305 This->filePathName = malloc(sizeof(WCHAR)*(sizeStr+1));
1306
1307 if (This->filePathName==NULL)
1308 return E_OUTOFMEMORY;
1309
1310 lstrcpyW(This->filePathName,lpszPathName);
1311
1312 nb=FileMonikerImpl_DecomposePath(This->filePathName,&tabStr);
1313
1314 if (nb > 0 ){
1315
1316 addBkSlash = TRUE;
1317 if (wcscmp(tabStr[0], L".."))
1318 addBkSlash = FALSE;
1319 else
1320 for(i=0;i<nb;i++){
1321
1322 if (wcscmp(tabStr[i], L"..") && wcscmp(tabStr[i], L"\\"))
1323 {
1324 addBkSlash = FALSE;
1325 break;
1326 }
1327 else
1328
1329 if (!wcscmp(tabStr[i], L"\\") && i < nb - 1 && !wcscmp(tabStr[i+1], L"\\"))
1330 {
1331 *tabStr[i]=0;
1332 sizeStr--;
1333 addBkSlash = FALSE;
1334 break;
1335 }
1336 }
1337
1338 if (!wcscmp(tabStr[nb-1], L"\\"))
1339 addBkSlash = FALSE;
1340
1341 This->filePathName = realloc(This->filePathName, (sizeStr+1)*sizeof(WCHAR));
1342
1343 *This->filePathName=0;
1344
1345 for(i=0;tabStr[i]!=NULL;i++)
1346 lstrcatW(This->filePathName,tabStr[i]);
1347
1348 if (addBkSlash)
1349 lstrcatW(This->filePathName, L"\\");
1350 }
1351
1352 free_stringtable(tabStr);
1353
1354 return S_OK;
1355}
1356
1357/******************************************************************************
1358 * CreateFileMoniker (OLE32.@)
1359 ******************************************************************************/
1360HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, IMoniker **ppmk)
1361{
1363 HRESULT hr;
1364
1365 TRACE("%s, %p.\n", debugstr_w(lpszPathName), ppmk);
1366
1367 if (!ppmk)
1368 return E_POINTER;
1369
1370 if(!lpszPathName)
1371 return MK_E_SYNTAX;
1372
1373 *ppmk=NULL;
1374
1375 if (!(moniker = calloc(1, sizeof(*moniker))))
1376 return E_OUTOFMEMORY;
1377
1378 hr = FileMonikerImpl_Construct(moniker, lpszPathName);
1379
1380 if (SUCCEEDED(hr))
1381 hr = IMoniker_QueryInterface(&moniker->IMoniker_iface, &IID_IMoniker, (void **)ppmk);
1382 else
1383 free(moniker);
1384
1385 return hr;
1386}
1387
1388/* find a character from a set in reverse without the string having to be null-terminated */
1389static inline WCHAR *memrpbrkW(const WCHAR *ptr, size_t n, const WCHAR *accept)
1390{
1391 const WCHAR *end, *ret = NULL;
1392 for (end = ptr + n; ptr < end; ptr++) if (wcschr(accept, *ptr)) ret = ptr;
1393 return (WCHAR *)ret;
1394}
1395
1397 LPDWORD pchEaten, IMoniker **ppmk)
1398{
1399 LPCWSTR end;
1400
1401 for (end = szDisplayName + lstrlenW(szDisplayName);
1402 end && (end != szDisplayName);
1403 end = memrpbrkW(szDisplayName, end - szDisplayName, L":\\/!"))
1404 {
1405 HRESULT hr;
1407 IMoniker *file_moniker;
1408 LPWSTR file_display_name;
1409 LPWSTR full_path_name;
1410 DWORD full_path_name_len;
1411 int len = end - szDisplayName;
1412
1413 file_display_name = malloc((len + 1) * sizeof(WCHAR));
1414 if (!file_display_name) return E_OUTOFMEMORY;
1415 memcpy(file_display_name, szDisplayName, len * sizeof(WCHAR));
1416 file_display_name[len] = '\0';
1417
1418 hr = CreateFileMoniker(file_display_name, &file_moniker);
1419 if (FAILED(hr))
1420 {
1421 free(file_display_name);
1422 return hr;
1423 }
1424
1425 hr = IBindCtx_GetRunningObjectTable(pbc, &rot);
1426 if (FAILED(hr))
1427 {
1428 free(file_display_name);
1429 IMoniker_Release(file_moniker);
1430 return hr;
1431 }
1432
1433 hr = IRunningObjectTable_IsRunning(rot, file_moniker);
1434 IRunningObjectTable_Release(rot);
1435 if (FAILED(hr))
1436 {
1437 free(file_display_name);
1438 IMoniker_Release(file_moniker);
1439 return hr;
1440 }
1441 if (hr == S_OK)
1442 {
1443 TRACE("found running file moniker for %s\n", debugstr_w(file_display_name));
1444 *pchEaten = len;
1445 *ppmk = file_moniker;
1446 free(file_display_name);
1447 return S_OK;
1448 }
1449
1450 full_path_name_len = GetFullPathNameW(file_display_name, 0, NULL, NULL);
1451 if (!full_path_name_len)
1452 {
1453 free(file_display_name);
1454 IMoniker_Release(file_moniker);
1455 return MK_E_SYNTAX;
1456 }
1457 full_path_name = malloc(full_path_name_len * sizeof(WCHAR));
1458 if (!full_path_name)
1459 {
1460 free(file_display_name);
1461 IMoniker_Release(file_moniker);
1462 return E_OUTOFMEMORY;
1463 }
1464 GetFullPathNameW(file_display_name, full_path_name_len, full_path_name, NULL);
1465
1466 if (GetFileAttributesW(full_path_name) == INVALID_FILE_ATTRIBUTES)
1467 TRACE("couldn't open file %s\n", debugstr_w(full_path_name));
1468 else
1469 {
1470 TRACE("got file moniker for %s\n", debugstr_w(szDisplayName));
1471 *pchEaten = len;
1472 *ppmk = file_moniker;
1473 free(file_display_name);
1474 free(full_path_name);
1475 return S_OK;
1476 }
1477 free(file_display_name);
1478 free(full_path_name);
1479 IMoniker_Release(file_moniker);
1480 }
1481
1482 return MK_E_CANTOPENFILE;
1483}
1484
1485
1487{
1488 FileMonikerImpl* newFileMoniker;
1489 HRESULT hr;
1490
1491 TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
1492
1493 *ppv = NULL;
1494
1495 if (pUnk)
1496 return CLASS_E_NOAGGREGATION;
1497
1498 newFileMoniker = calloc(1, sizeof(*newFileMoniker));
1499 if (!newFileMoniker)
1500 return E_OUTOFMEMORY;
1501
1502 hr = FileMonikerImpl_Construct(newFileMoniker, L"");
1503
1504 if (SUCCEEDED(hr))
1505 hr = IMoniker_QueryInterface(&newFileMoniker->IMoniker_iface, riid, ppv);
1506 if (FAILED(hr))
1507 free(newFileMoniker);
1508
1509 return hr;
1510}
GLfloat rot
Definition: 3dtext.c:36
#define DEAD
HRESULT create_anti_moniker(DWORD order, IMoniker **ret)
Definition: antimoniker.c:606
BOOL is_anti_moniker(IMoniker *iface, DWORD *order)
Definition: antimoniker.c:54
HRESULT WINAPI CreateAntiMoniker(IMoniker **moniker)
Definition: antimoniker.c:626
#define ZERO
Definition: arc.cc:50
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define skip(...)
Definition: atltest.h:64
#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
HRESULT WINAPI MonikerCommonPrefixWith(IMoniker *pmkThis, IMoniker *pmkOther, IMoniker **ppmkCommon)
HRESULT WINAPI CreateGenericComposite(IMoniker *left, IMoniker *right, IMoniker **composite)
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
#define wcschr
Definition: compat.h:17
#define CP_ACP
Definition: compat.h:109
#define lstrcpyW
Definition: compat.h:749
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
#define wcsicmp
Definition: compat.h:15
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:536
DWORD WINAPI GetFullPathNameW(IN LPCWSTR lpFileName, IN DWORD nBufferLength, OUT LPWSTR lpBuffer, OUT LPWSTR *lpFilePart)
Definition: path.c:1106
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972
HRESULT WINAPI GetClassFile(LPCOLESTR filePathName, CLSID *pclsid)
Definition: moniker.c:921
HRESULT MonikerMarshal_Create(IMoniker *inner, IUnknown **outer)
Definition: moniker.c:1361
HRESULT WINAPI StgOpenStorage(const OLECHAR *pwcsName, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8701
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
static HRESULT WINAPI FileMonikerImpl_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, IMoniker *pmkNewlyRunning)
Definition: filemoniker.c:872
static HRESULT WINAPI FileMonikerImpl_BindToObject(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riid, VOID **ppvResult)
Definition: filemoniker.c:463
static HRESULT WINAPI FileMonikerImpl_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, FILETIME *pFileTime)
Definition: filemoniker.c:902
HRESULT WINAPI CreateFileMoniker(LPCOLESTR lpszPathName, IMoniker **ppmk)
Definition: filemoniker.c:1360
static const IMonikerVtbl VT_FileMonikerImpl
Definition: filemoniker.c:58
static HRESULT WINAPI FileMonikerImpl_ComposeWith(IMoniker *iface, IMoniker *pmkRight, BOOL fOnlyIfNotGeneric, IMoniker **ppmkComposite)
Definition: filemoniker.c:715
static HRESULT WINAPI FileMonikerImpl_QueryInterface(IMoniker *iface, REFIID riid, void **ppvObject)
Definition: filemoniker.c:73
static int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR **stringTable)
Definition: filemoniker.c:632
static ULONG WINAPI FileMonikerROTDataImpl_AddRef(IROTData *iface)
Definition: filemoniker.c:1199
static ULONG WINAPI FileMonikerImpl_Release(IMoniker *iface)
Definition: filemoniker.c:125
static HRESULT WINAPI FileMonikerImpl_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riid, void **object)
Definition: filemoniker.c:575
static HRESULT WINAPI FileMonikerImpl_Enum(IMoniker *iface, BOOL fForward, IEnumMoniker **ppenumMoniker)
Definition: filemoniker.c:806
static HRESULT FileMonikerImpl_Construct(FileMonikerImpl *iface, LPCOLESTR lpszPathName)
Definition: filemoniker.c:1290
static HRESULT WINAPI FileMonikerImpl_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOther, IMoniker **ppmkPrefix)
Definition: filemoniker.c:951
static HRESULT WINAPI FileMonikerImpl_ParseDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
Definition: filemoniker.c:1158
static FileMonikerImpl * impl_from_IMoniker(IMoniker *iface)
Definition: filemoniker.c:48
static HRESULT WINAPI FileMonikerImpl_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD howfar, IMoniker **toleft, IMoniker **reduced)
Definition: filemoniker.c:609
static HRESULT WINAPI FileMonikerImpl_IsDirty(IMoniker *iface)
Definition: filemoniker.c:166
static HRESULT WINAPI FileMonikerImpl_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
Definition: filemoniker.c:342
static const IROTDataVtbl VT_ROTDataImpl
Definition: filemoniker.c:1279
static HRESULT WINAPI FileMonikerROTDataImpl_QueryInterface(IROTData *iface, REFIID riid, VOID **ppvObject)
Definition: filemoniker.c:1185
static FileMonikerImpl * unsafe_impl_from_IMoniker(IMoniker *iface)
Definition: filemoniker.c:60
static HRESULT WINAPI FileMonikerROTDataImpl_GetComparisonData(IROTData *iface, BYTE *pbData, ULONG cbMax, ULONG *pcbData)
Definition: filemoniker.c:1225
static HRESULT WINAPI FileMonikerImpl_Hash(IMoniker *iface, DWORD *pdwHash)
Definition: filemoniker.c:838
static HRESULT WINAPI FileMonikerImpl_IsSystemMoniker(IMoniker *iface, DWORD *pwdMksys)
Definition: filemoniker.c:1169
static FileMonikerImpl * impl_from_IROTData(IROTData *iface)
Definition: filemoniker.c:53
static HRESULT WINAPI FileMonikerImpl_GetClassID(IMoniker *iface, CLSID *pClassID)
Definition: filemoniker.c:146
static void free_stringtable(LPOLESTR *stringTable)
Definition: filemoniker.c:623
static HRESULT WINAPI FileMonikerImpl_GetDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
Definition: filemoniker.c:1129
static WCHAR * memrpbrkW(const WCHAR *ptr, size_t n, const WCHAR *accept)
Definition: filemoniker.c:1389
HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName, LPDWORD pchEaten, IMoniker **ppmk)
Definition: filemoniker.c:1396
static HRESULT WINAPI FileMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other)
Definition: filemoniker.c:818
static ULONG WINAPI FileMonikerROTDataImpl_Release(IROTData *iface)
Definition: filemoniker.c:1212
HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk, REFIID riid, void **ppv)
Definition: filemoniker.c:1486
static HRESULT WINAPI FileMonikerImpl_RelativePathTo(IMoniker *iface, IMoniker *pmOther, IMoniker **ppmkRelPath)
Definition: filemoniker.c:1053
static ULONG WINAPI FileMonikerImpl_AddRef(IMoniker *iface)
Definition: filemoniker.c:116
static HRESULT WINAPI FileMonikerImpl_Inverse(IMoniker *iface, IMoniker **ppmk)
Definition: filemoniker.c:940
static HRESULT WINAPI FileMonikerImpl_Load(IMoniker *iface, IStream *pStm)
Definition: filemoniker.c:181
static HRESULT WINAPI FileMonikerImpl_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
Definition: filemoniker.c:441
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint end
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLuint GLfloat * val
Definition: glext.h:7180
GLuint GLdouble GLdouble GLint GLint order
Definition: glext.h:11194
GLenum GLsizei len
Definition: glext.h:6722
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define MB_ERR_INVALID_CHARS
Definition: unicode.h:41
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const WCHAR * word
Definition: lex.c:36
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_w
Definition: kernel32.h:32
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
@ GetFileExInfoStandard
Definition: minwinbase.h:356
#define pch(ap)
Definition: match.c:418
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PVOID ptr
Definition: dispmode.c:27
static BSTR *static LPOLESTR
Definition: varformat.c:44
#define min(a, b)
Definition: monoChain.cc:55
int other
Definition: msacm.c:1376
IID CLSID
Definition: mstsclib_i.c:62
#define STGM_READ
Definition: objbase.h:934
interface IBindCtx * LPBC
Definition: objfwd.h:18
HRESULT WINAPI CreateBindCtx(DWORD reserved, IBindCtx **bind_context)
Definition: bindctx.c:491
const GUID IID_IPersistFile
long LONG
Definition: pedump.c:60
const GUID IID_IPersist
Definition: proxy.cpp:14
const GUID IID_IPersistStream
Definition: proxy.cpp:13
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
_In_ _Out_writes_opt_ pcchValueName _Inout_opt_ LPDWORD _Out_opt_ _Out_writes_bytes_to_opt_ pcbData _Inout_opt_ LPDWORD pcbData
Definition: shlwapi.h:757
#define calloc
Definition: rosglue.h:14
const WCHAR * str
return succeed
Definition: scsi.h:3782
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35
#define towupper(c)
Definition: wctype.h:99
HRESULT hr
Definition: shlfolder.c:183
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
SOCKET WSAAPI accept(IN SOCKET s, OUT LPSOCKADDR addr, OUT INT FAR *addrlen)
Definition: socklife.c:23
#define TRACE(s)
Definition: solgame.cpp:4
LPOLESTR filePathName
Definition: filemoniker.c:44
IUnknown * pMarshal
Definition: filemoniker.c:45
IMoniker IMoniker_iface
Definition: filemoniker.c:41
IROTData IROTData_iface
Definition: filemoniker.c:42
struct _ULARGE_INTEGER::@4426 u
Definition: main.c:40
IMoniker IMoniker_iface
Definition: main.c:41
Definition: send.c:48
uint32_t * LPDWORD
Definition: typedefs.h:59
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_Inout_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_opt_ COLORADJUSTMENT * pca
Definition: winddi.h:3779
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:3451
#define MK_S_REDUCED_TO_SELF
Definition: winerror.h:3892
#define MK_E_NOOBJECT
Definition: winerror.h:3898
#define E_NOINTERFACE
Definition: winerror.h:3479
#define MK_E_INTERMEDIATEINTERFACENOTSUPPORTED
Definition: winerror.h:3902
#define MK_E_NOPREFIX
Definition: winerror.h:3909
#define MK_E_SYNTAX
Definition: winerror.h:3896
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:3771
#define MK_E_CANTOPENFILE
Definition: winerror.h:3905
#define MK_E_NEEDGENERIC
Definition: winerror.h:3893
#define MK_S_HIM
Definition: winerror.h:3897
#define E_POINTER
Definition: winerror.h:3480
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
char CHAR
Definition: xmlstorage.h:175
unsigned char BYTE
Definition: xxhash.c:193