ReactOS 0.4.17-dev-573-g8315b8c
pidl.c
Go to the documentation of this file.
1/*
2 * pidl Handling
3 *
4 * Copyright 1998 Juergen Schmied
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 * NOTES
21 * a pidl == NULL means desktop and is legal
22 *
23 */
24
25#include <wine/config.h>
26
27#define WIN32_NO_STATUS
28#define _INC_WINDOWS
29#define COBJMACROS
30#define NONAMELESSUNION
31#define NONAMELESSSTRUCT
32
33#include <windef.h>
34#include <winbase.h>
35#include <strsafe.h>
36#include <shlobj.h>
37#include <undocshell.h>
38#include <shlwapi.h>
39#include <shlguid_undoc.h>
40#include <wine/debug.h>
41#include <wine/unicode.h>
42#include <shellutils.h>
43
44#include "pidl.h"
45#include "shell32_main.h"
46#include "shresdef.h"
47
50
51/* from comctl32.dll */
53extern BOOL WINAPI Free(LPVOID);
54
57
59
62 _In_ IBindCtx *pBindCtx,
63 _In_ LPOLESTR pszKey,
65 _Out_ LPBC *ppbc);
66
67/*************************************************************************
68 * ILGetDisplayNameExA
69 *
70 * Retrieves the display name of an ItemIDList
71 *
72 * PARAMS
73 * psf [I] Shell Folder to start with, if NULL the desktop is used
74 * pidl [I] ItemIDList relative to the psf to get the display name for
75 * path [O] Filled in with the display name, assumed to be at least MAX_PATH long
76 * type [I] Type of display name to retrieve
77 * 0 = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR uses always the desktop as root
78 * 1 = SHGDN_NORMAL relative to the root folder
79 * 2 = SHGDN_INFOLDER relative to the root folder, only the last name
80 *
81 * RETURNS
82 * True if the display name could be retrieved successfully, False otherwise
83 */
84static BOOL ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type)
85{
86 BOOL ret = FALSE;
87 WCHAR wPath[MAX_PATH];
88
89 TRACE("%p %p %p %d\n", psf, pidl, path, type);
90
91 if (!pidl || !path)
92 return FALSE;
93
94 ret = ILGetDisplayNameExW(psf, pidl, wPath, type);
96 TRACE("%p %p %s\n", psf, pidl, debugstr_a(path));
97
98 return ret;
99}
100
102{
103 LPSHELLFOLDER psfParent, lsf = psf;
105 LPCITEMIDLIST pidllast;
106 STRRET strret;
107 DWORD flag;
108
109 TRACE("%p %p %p %x\n", psf, pidl, path, type);
110
111 if (!pidl || !path)
112 return FALSE;
113
114 if (!lsf)
115 {
116 ret = SHGetDesktopFolder(&lsf);
117 if (FAILED(ret))
118 return FALSE;
119 }
120
121 switch (type)
122 {
123 case ILGDN_FORPARSING:
124 flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR;
125 break;
126 case ILGDN_NORMAL:
127 flag = SHGDN_NORMAL;
128 break;
129 case ILGDN_INFOLDER:
130 flag = SHGDN_INFOLDER;
131 break;
132 default:
133 FIXME("Unknown type parameter = %x\n", type);
134 flag = SHGDN_FORPARSING | SHGDN_FORADDRESSBAR;
135 break;
136 }
137
138 if (!*(const WORD*)pidl || type == ILGDN_FORPARSING)
139 {
140 ret = IShellFolder_GetDisplayNameOf(lsf, pidl, flag, &strret);
141 if (SUCCEEDED(ret))
142 {
143 if(!StrRetToStrNW(path, MAX_PATH, &strret, pidl))
144 ret = E_FAIL;
145 }
146 }
147 else
148 {
149 ret = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psfParent, &pidllast);
150 if (SUCCEEDED(ret))
151 {
152 ret = IShellFolder_GetDisplayNameOf(psfParent, pidllast, flag, &strret);
153 if (SUCCEEDED(ret))
154 {
155 if(!StrRetToStrNW(path, MAX_PATH, &strret, pidllast))
156 ret = E_FAIL;
157 }
158 IShellFolder_Release(psfParent);
159 }
160 }
161
162 TRACE("%p %p %s\n", psf, pidl, debugstr_w(path));
163
164 if (!psf)
165 IShellFolder_Release(lsf);
166 return SUCCEEDED(ret);
167}
168
169/*************************************************************************
170 * ILGetDisplayNameEx [SHELL32.186]
171 */
173{
174 TRACE_(shell)("%p %p %p %d\n", psf, pidl, path, type);
175
176 if (SHELL_OsIsUnicode())
177 return ILGetDisplayNameExW(psf, pidl, path, type);
178 return ILGetDisplayNameExA(psf, pidl, path, type);
179}
180
181/*************************************************************************
182 * ILGetDisplayName [SHELL32.15]
183 */
185{
186 TRACE_(shell)("%p %p\n", pidl, path);
187
188 if (SHELL_OsIsUnicode())
191}
192
193/*************************************************************************
194 * ILFindLastID [SHELL32.16]
195 *
196 * NOTES
197 * observed: pidl=Desktop return=pidl
198 */
200{
201 LPCITEMIDLIST pidlLast = pidl;
202
203 TRACE("(pidl=%p)\n",pidl);
204
205 if (!pidl)
206 return NULL;
207
208 while (pidl->mkid.cb)
209 {
210 pidlLast = pidl;
211 pidl = ILGetNext(pidl);
212 }
213 return (LPITEMIDLIST)pidlLast;
214}
215
216/*************************************************************************
217 * ILRemoveLastID [SHELL32.17]
218 *
219 * NOTES
220 * when pidl=Desktop return=FALSE
221 */
223{
224 TRACE_(shell)("pidl=%p\n",pidl);
225
226 if (_ILIsEmpty(pidl))
227 return FALSE;
228 ILFindLastID(pidl)->mkid.cb = 0;
229 return TRUE;
230}
231
232/*************************************************************************
233 * ILClone [SHELL32.18]
234 *
235 * NOTES
236 * duplicate an idlist
237 */
239{
240 DWORD len;
241 LPITEMIDLIST newpidl;
242
243 if (!pidl)
244 return NULL;
245
246 len = ILGetSize(pidl);
247 newpidl = SHAlloc(len);
248 if (newpidl)
249 memcpy(newpidl,pidl,len);
250
251 TRACE("pidl=%p newpidl=%p\n",pidl, newpidl);
252 pdump(pidl);
253
254 return newpidl;
255}
256
257/*************************************************************************
258 * ILCloneFirst [SHELL32.19]
259 *
260 * NOTES
261 * duplicates the first idlist of a complex pidl
262 */
264{
265 DWORD len;
266 LPITEMIDLIST pidlNew = NULL;
267
268 TRACE("pidl=%p\n", pidl);
269 pdump(pidl);
270
271 if (pidl)
272 {
273 len = pidl->mkid.cb;
274 pidlNew = SHAlloc(len+2);
275 if (pidlNew)
276 {
277 memcpy(pidlNew,pidl,len+2); /* 2 -> mind a desktop pidl */
278
279 if (len)
280 ILGetNext(pidlNew)->mkid.cb = 0x00;
281 }
282 }
283 TRACE("-- newpidl=%p\n",pidlNew);
284
285 return pidlNew;
286}
287
288/*************************************************************************
289 * ILLoadFromStream (SHELL32.26)
290 *
291 * NOTES
292 * the first two bytes are the len, the pidl is following then
293 */
295{
296 WORD wLen = 0;
297 DWORD dwBytesRead;
299
300
301 TRACE_(shell)("%p %p\n", pStream , ppPidl);
302
303 SHFree(*ppPidl);
304 *ppPidl = NULL;
305
306 IStream_AddRef (pStream);
307
308 if (SUCCEEDED(IStream_Read(pStream, &wLen, 2, &dwBytesRead)))
309 {
310 TRACE("PIDL length is %d\n", wLen);
311 if (wLen != 0)
312 {
313 *ppPidl = SHAlloc (wLen);
314 if (SUCCEEDED(IStream_Read(pStream, *ppPidl , wLen, &dwBytesRead)))
315 {
316 TRACE("Stream read OK\n");
317 ret = S_OK;
318 }
319 else
320 {
321 WARN("reading pidl failed\n");
322 SHFree(*ppPidl);
323 *ppPidl = NULL;
324 }
325 }
326 else
327 {
328 *ppPidl = NULL;
329 ret = S_OK;
330 }
331 }
332
333 /* we are not yet fully compatible */
334 if (*ppPidl && !pcheck(*ppPidl))
335 {
336 WARN("Check failed\n");
337#ifndef __REACTOS__ /* We don't know all pidl formats, must allow loading unknown */
338 SHFree(*ppPidl);
339 *ppPidl = NULL;
340#endif
341 }
342
343 IStream_Release (pStream);
344 TRACE("done\n");
345 return ret;
346}
347
348/*************************************************************************
349 * ILSaveToStream (SHELL32.27)
350 *
351 * NOTES
352 * the first two bytes are the len, the pidl is following then
353 */
355{
356 WORD wLen = 0;
358
359 TRACE_(shell)("%p %p\n", pStream, pPidl);
360
361 IStream_AddRef (pStream);
362
363 wLen = ILGetSize(pPidl);
364
365 if (SUCCEEDED(IStream_Write(pStream, &wLen, 2, NULL)))
366 {
367 if (SUCCEEDED(IStream_Write(pStream, pPidl, wLen, NULL)))
368 ret = S_OK;
369 }
370 IStream_Release (pStream);
371
372 return ret;
373}
374
375/*************************************************************************
376 * SHILCreateFromPath [SHELL32.28]
377 *
378 * Create an ItemIDList from a path
379 *
380 * PARAMS
381 * path [I]
382 * ppidl [O]
383 * attributes [I/O] requested attributes on call and actual attributes when
384 * the function returns
385 *
386 * RETURNS
387 * NO_ERROR if successful, or an OLE errer code otherwise
388 *
389 * NOTES
390 * Wrapper for IShellFolder_ParseDisplayName().
391 */
393{
394 WCHAR lpszDisplayName[MAX_PATH];
395
396 TRACE_(shell)("%s %p 0x%08x\n", path, ppidl, attributes ? *attributes : 0);
397
398 if (!MultiByteToWideChar(CP_ACP, 0, path, -1, lpszDisplayName, MAX_PATH))
399 lpszDisplayName[MAX_PATH-1] = 0;
400
401 return SHILCreateFromPathW(lpszDisplayName, ppidl, attributes);
402}
403
405{
406 LPSHELLFOLDER sf;
407 DWORD pchEaten;
409
410 TRACE_(shell)("%s %p 0x%08x\n", debugstr_w(path), ppidl, attributes ? *attributes : 0);
411
412 if (SUCCEEDED (SHGetDesktopFolder(&sf)))
413 {
414 ret = IShellFolder_ParseDisplayName(sf, 0, NULL, (LPWSTR)path, &pchEaten, ppidl, attributes);
415 IShellFolder_Release(sf);
416 }
417 return ret;
418}
419
421{
422 if ( SHELL_OsIsUnicode())
423 return SHILCreateFromPathW (path, ppidl, attributes);
424 return SHILCreateFromPathA (path, ppidl, attributes);
425}
426
427/*************************************************************************
428 * SHCloneSpecialIDList [SHELL32.89]
429 *
430 * Create an ItemIDList to one of the special folders.
431
432 * PARAMS
433 * hwndOwner [in]
434 * nFolder [in] CSIDL_xxxxx
435 * fCreate [in] Create folder if it does not exist
436 *
437 * RETURNS
438 * Success: The newly created pidl
439 * Failure: NULL, if inputs are invalid.
440 *
441 * NOTES
442 * exported by ordinal.
443 * Caller is responsible for deallocating the returned ItemIDList with the
444 * shells IMalloc interface, aka ILFree.
445 */
447{
448 LPITEMIDLIST ppidl;
449 TRACE_(shell)("(hwnd=%p,csidl=0x%x,%s).\n", hwndOwner, nFolder, fCreate ? "T" : "F");
450
451 if (fCreate)
453
454 SHGetSpecialFolderLocation(hwndOwner, nFolder, &ppidl);
455 return ppidl;
456}
457
458/*************************************************************************
459 * ILGlobalClone [SHELL32.20]
460 *
461 * Clones an ItemIDList using Alloc.
462 *
463 * PARAMS
464 * pidl [I] ItemIDList to clone
465 *
466 * RETURNS
467 * Newly allocated ItemIDList.
468 *
469 * NOTES
470 * exported by ordinal.
471 */
473{
474 DWORD len;
475 LPITEMIDLIST newpidl;
476
477 if (!pidl)
478 return NULL;
479
480 len = ILGetSize(pidl);
481 newpidl = Alloc(len);
482 if (newpidl)
483 memcpy(newpidl,pidl,len);
484
485 TRACE("pidl=%p newpidl=%p\n",pidl, newpidl);
486 pdump(pidl);
487
488 return newpidl;
489}
490
491#ifdef __REACTOS__
492static inline LPITEMIDLIST _ILUnsafeNext(LPCITEMIDLIST pidl)
493{
494 return (LPITEMIDLIST)(((BYTE*)pidl) + pidl->mkid.cb);
495}
496
498{
499 for (UINT i = 0;; ++i)
500 {
501 if (!pidl || !pidl->mkid.cb)
502 return i;
503 pidl = _ILUnsafeNext(pidl);
504 }
505}
506
507static BOOL _ILMemCmpEqualIDList(LPCITEMIDLIST p1, LPCITEMIDLIST p2)
508{
509 for (;; p1 = _ILUnsafeNext(p1), p2 = _ILUnsafeNext(p2))
510 {
511 DWORD cb1 = p1 ? p1->mkid.cb : 0x80000000; /* Empty != NULL */
512 DWORD cb2 = p2 ? p2->mkid.cb : 0x80000000;
513 if (cb1 != cb2)
514 return FALSE;
515 if (LOWORD(cb1) == 0)
516 return cb1 == cb2;
517 if (memcmp(p1, p2, cb1))
518 return FALSE;
519 }
520}
521#else /* __REACTOS__ */
523{
524 LPPIDLDATA pdata1 = _ILGetDataPointer(pidltemp1);
525 LPPIDLDATA pdata2 = _ILGetDataPointer(pidltemp2);
526
527 IID *iid1 = _ILGetGUIDPointer(pidltemp1);
528 IID *iid2 = _ILGetGUIDPointer(pidltemp2);
529
530 FileStructW* pDataW1 = _ILGetFileStructW(pidltemp1);
531 FileStructW* pDataW2 = _ILGetFileStructW(pidltemp2);
532
533 if (_ILIsDesktop(pidltemp1) && _ILIsDesktop(pidltemp2))
534 {
535 return TRUE;
536 }
537 else if (_ILIsDesktop(pidltemp1) || _ILIsDesktop(pidltemp2))
538 {
539 return FALSE;
540 }
541 else if (iid1 || iid2)
542 {
543 if (!iid1 || !iid2 || memcmp(iid1, iid2, sizeof(GUID)))
544 return FALSE;
545 }
546 else if (pDataW1 || pDataW2)
547 {
548 if (!pDataW1 || !pDataW2 || wcsicmp(pDataW1->wszName, pDataW2->wszName))
549 return FALSE;
550 }
551 else if (_ILIsFolder(pidltemp1) || _ILIsFolder(pidltemp2))
552 {
553 if (!_ILIsFolder(pidltemp1) || !_ILIsFolder(pidltemp2) || strcmp(pdata1->u.file.szNames, pdata2->u.file.szNames))
554 return FALSE;
555 }
556 else if (_ILIsValue(pidltemp1) || _ILIsValue(pidltemp2))
557 {
558 if (!_ILIsValue(pidltemp1) || !_ILIsValue(pidltemp2) || strcmp(pdata1->u.file.szNames, pdata2->u.file.szNames))
559 return FALSE;
560 }
561 else if (_ILIsDrive(pidltemp1) || _ILIsDrive(pidltemp2))
562 {
563 if (!_ILIsDrive(pidltemp1) || !_ILIsDrive(pidltemp2) || pdata1->u.drive.szDriveName[0] != pdata2->u.drive.szDriveName[0])
564 return FALSE;
565 }
566 else
567 {
568 if ((pidltemp1->mkid.cb != pidltemp2->mkid.cb) ||
569 !RtlEqualMemory((BYTE*)&pidltemp1->mkid, (BYTE*)&pidltemp2->mkid, pidltemp1->mkid.cb))
570 {
571 return FALSE;
572 }
573 }
574
575 return TRUE;
576}
577#endif /* __REACTOS__ */
578
579/*************************************************************************
580 * ILIsEqual [SHELL32.21]
581 *
582 */
584{
585 LPCITEMIDLIST pidltemp1 = pidl1;
586 LPCITEMIDLIST pidltemp2 = pidl2;
587
588 TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2);
589
590#ifdef __REACTOS__
591 IShellFolder *psfDesktop;
592 UINT depth1;
593
594 if (pidl1 == pidl2 || _ILMemCmpEqualIDList(pidltemp1, pidltemp2))
595 return TRUE;
596
597 depth1 = _ILGetDepth(pidl1);
598 if (depth1 && depth1 == _ILGetDepth(pidl2) && SUCCEEDED(SHGetDesktopFolder(&psfDesktop)))
599 {
600 HRESULT hr = IShellFolder_CompareIDs(psfDesktop, SHCIDS_CANONICALONLY, pidl1, pidl2);
601 IShellFolder_Release(psfDesktop);
602 return hr == 0;
603 }
604#else /* __REACTOS__ */
605 /*
606 * Explorer reads from registry directly (StreamMRU),
607 * so we can only check here
608 */
609 if (!pcheck(pidl1) || !pcheck (pidl2))
610#ifdef __REACTOS__
611 {
612 /* We don't understand the PIDL content but that does not mean it's invalid */
613 }
614#else
615 return FALSE;
616#endif
617
618 pdump (pidl1);
619 pdump (pidl2);
620
621 if (!pidl1 || !pidl2)
622 return FALSE;
623
624 while (pidltemp1->mkid.cb && pidltemp2->mkid.cb)
625 {
626 if (!_ILHACKCompareSimpleIds(pidltemp1, pidltemp2))
627 return FALSE;
628
629 pidltemp1 = ILGetNext(pidltemp1);
630 pidltemp2 = ILGetNext(pidltemp2);
631 }
632
633 if (!pidltemp1->mkid.cb && !pidltemp2->mkid.cb)
634 return TRUE;
635#endif /* __REACTOS__ */
636 return FALSE;
637}
638
640{
641 LPCITEMIDLIST pParentRoot = pidlParent, pChildRoot = pidlChild, pResult = NULL;
642 LPITEMIDLIST pidl;
643 SIZE_T cb = 0;
644
645 if (!pidlParent || !pidlChild)
646 return pResult;
647
648 while (pidlParent->mkid.cb)
649 {
650 cb += pidlChild->mkid.cb;
651 if (!pidlChild->mkid.cb)
652 {
653 if (pidlParent->mkid.cb)
654 return pResult; /* The child is shorter than the parent */
655 else
656 break;
657 }
658 pidlChild = _ILUnsafeNext(pidlChild);
659 pidlParent = _ILUnsafeNext(pidlParent);
660 }
661
662 if (bImmediate && (!pidlChild->mkid.cb || _ILUnsafeNext(pidlChild)->mkid.cb))
663 return pResult; /* Same as parent or a deeper grandchild */
664
665 if ((pidl = SHAlloc(cb + sizeof(WORD))) != NULL)
666 {
667 CopyMemory(pidl, pChildRoot, cb);
668 ZeroMemory((BYTE*)pidl + cb, sizeof(WORD));
669 if (ILIsEqual(pParentRoot, pidl))
670 pResult = pidlChild;
671 ILFree(pidl);
672 }
673 return pResult;
674}
675
676/*************************************************************************
677 * ILIsParent [SHELL32.23]
678 *
679 * Verifies that pidlParent is indeed the (immediate) parent of pidlChild.
680 *
681 * PARAMS
682 * pidlParent [I]
683 * pidlChild [I]
684 * bImmediate [I] only return true if the parent is the direct parent
685 * of the child
686 *
687 * RETURNS
688 * True if the parent ItemIDlist is a complete part of the child ItemIdList,
689 * False otherwise.
690 *
691 * NOTES
692 * parent = a/b, child = a/b/c -> true, c is in folder a/b
693 * child = a/b/c/d -> false if bImmediate is true, d is not in folder a/b
694 * child = a/b/c/d -> true if bImmediate is false, d is in a subfolder of a/b
695 * child = a/b -> false if bImmediate is true
696 * child = a/b -> true if bImmediate is false
697 */
698BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
699{
700 LPCITEMIDLIST pParent = pidlParent;
701 LPCITEMIDLIST pChild = pidlChild;
702
703 TRACE("%p %p %x\n", pidlParent, pidlChild, bImmediate);
704
705#ifdef __REACTOS__
706 return _ILIsParentEx(pParent, pChild, bImmediate) != NULL;
707#else /* __REACTOS__ */
708 if (!pParent || !pChild)
709 return FALSE;
710
711 while (pParent->mkid.cb && pChild->mkid.cb)
712 {
713 if (!_ILHACKCompareSimpleIds(pParent, pChild))
714 return FALSE;
715
717 pChild = ILGetNext(pChild);
718 }
719
720 /* child has shorter name than parent */
721 if (pParent->mkid.cb)
722 return FALSE;
723
724 /* not immediate descent */
725 if ((!pChild->mkid.cb || ILGetNext(pChild)->mkid.cb) && bImmediate)
726 return FALSE;
727
728 return TRUE;
729#endif /* __REACTOS__ */
730}
731
732/*************************************************************************
733 * ILFindChild [SHELL32.24]
734 *
735 * Compares elements from pidl1 and pidl2.
736 *
737 * PARAMS
738 * pidl1 [I]
739 * pidl2 [I]
740 *
741 * RETURNS
742 * pidl1 is desktop pidl2
743 * pidl1 shorter pidl2 pointer to first different element of pidl2
744 * if there was at least one equal element
745 * pidl2 shorter pidl1 0
746 * pidl2 equal pidl1 pointer to last 0x00-element of pidl2
747 *
748 * NOTES
749 * exported by ordinal.
750 */
752{
753#ifdef __REACTOS__
754 TRACE("pidl1=%p pidl2=%p\n", pidl1, pidl2);
755
756 if (_ILIsDesktop(pidl1))
757 return (PUIDLIST_RELATIVE)pidl2;
758 return (PUIDLIST_RELATIVE)_ILIsParentEx(pidl1, pidl2, FALSE);
759#else /* __REACTOS__ */
760 LPCITEMIDLIST pidltemp1 = pidl1;
761 LPCITEMIDLIST pidltemp2 = pidl2;
763
764 TRACE("pidl1=%p pidl2=%p\n",pidl1, pidl2);
765
766 /* explorer reads from registry directly (StreamMRU),
767 so we can only check here */
768 if ((!pcheck (pidl1)) || (!pcheck (pidl2)))
769 return FALSE;
770
771 pdump (pidl1);
772 pdump (pidl2);
773
774 if (_ILIsDesktop(pidl1))
775 {
776 ret = pidl2;
777 }
778 else
779 {
780 while (pidltemp1->mkid.cb && pidltemp2->mkid.cb)
781 {
782 if (!_ILHACKCompareSimpleIds(pidltemp1, pidltemp2))
783 return FALSE;
784
785 pidltemp1 = ILGetNext(pidltemp1);
786 pidltemp2 = ILGetNext(pidltemp2);
787 ret = pidltemp2;
788 }
789
790 if (pidltemp1->mkid.cb)
791 ret = NULL; /* elements of pidl1 left*/
792 }
793 TRACE_(shell)("--- %p\n", ret);
794 return (PUIDLIST_RELATIVE)ret; /* pidl 1 is shorter */
795#endif /* __REACTOS__ */
796}
797
798/*************************************************************************
799 * ILCombine [SHELL32.25]
800 *
801 * Concatenates two complex ItemIDLists.
802 *
803 * PARAMS
804 * pidl1 [I] first complex ItemIDLists
805 * pidl2 [I] complex ItemIDLists to append
806 *
807 * RETURNS
808 * if both pidl's == NULL NULL
809 * if pidl1 == NULL cloned pidl2
810 * if pidl2 == NULL cloned pidl1
811 * otherwise new pidl with pidl2 appended to pidl1
812 *
813 * NOTES
814 * exported by ordinal.
815 * Does not destroy the passed in ItemIDLists!
816 */
818{
819 DWORD len1,len2;
820 LPITEMIDLIST pidlNew;
821
822 TRACE("pidl=%p pidl=%p\n",pidl1,pidl2);
823
824 if (!pidl1 && !pidl2) return NULL;
825
826 pdump (pidl1);
827 pdump (pidl2);
828
829 if (!pidl1)
830 {
831 pidlNew = ILClone(pidl2);
832 return pidlNew;
833 }
834
835 if (!pidl2)
836 {
837 pidlNew = ILClone(pidl1);
838 return pidlNew;
839 }
840
841 len1 = ILGetSize(pidl1)-2;
842 len2 = ILGetSize(pidl2);
843 pidlNew = SHAlloc(len1+len2);
844
845 if (pidlNew)
846 {
847 memcpy(pidlNew,pidl1,len1);
848 memcpy(((BYTE *)pidlNew)+len1,pidl2,len2);
849 }
850
851 /* TRACE(pidl,"--new pidl=%p\n",pidlNew);*/
852 return pidlNew;
853}
854
855#ifndef __REACTOS__ /* See ..\utils.cpp */
856/*************************************************************************
857 * SHGetRealIDL [SHELL32.98]
858 *
859 * NOTES
860 */
861HRESULT WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST *pidlReal)
862{
863 IDataObject* pDataObj;
864 HRESULT hr;
865
866 hr = IShellFolder_GetUIObjectOf(lpsf, 0, 1, &pidlSimple,
867 &IID_IDataObject, 0, (LPVOID*)&pDataObj);
868 if (SUCCEEDED(hr))
869 {
870 STGMEDIUM medium;
871 FORMATETC fmt;
872
874 fmt.ptd = NULL;
875 fmt.dwAspect = DVASPECT_CONTENT;
876 fmt.lindex = -1;
877 fmt.tymed = TYMED_HGLOBAL;
878
879 hr = IDataObject_GetData(pDataObj, &fmt, &medium);
880
881 IDataObject_Release(pDataObj);
882
883 if (SUCCEEDED(hr))
884 {
885 /*assert(pida->cidl==1);*/
886 LPIDA pida = GlobalLock(medium.u.hGlobal);
887
888 LPCITEMIDLIST pidl_folder = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[0]);
889 LPCITEMIDLIST pidl_child = (LPCITEMIDLIST) ((LPBYTE)pida+pida->aoffset[1]);
890
891 *pidlReal = ILCombine(pidl_folder, pidl_child);
892
893 if (!*pidlReal)
895
896 GlobalUnlock(medium.u.hGlobal);
897 GlobalFree(medium.u.hGlobal);
898 }
899 }
900
901 return hr;
902}
903#endif
904
905/*************************************************************************
906 * SHLogILFromFSIL [SHELL32.95]
907 *
908 * NOTES
909 * pild = CSIDL_DESKTOP ret = 0
910 * pild = CSIDL_DRIVES ret = 0
911 */
913{
914#ifdef __REACTOS__
915 LPITEMIDLIST pidlNew = NULL;
916 SHELL32_AliasTranslatePidl(pidl, &pidlNew, ALIAS_ANY);
917 return pidlNew;
918#else
919 FIXME("(pidl=%p)\n",pidl);
920
921 pdump(pidl);
922
923 return 0;
924#endif
925}
926
927/*************************************************************************
928 * ILGetSize [SHELL32.152]
929 *
930 * Gets the byte size of an ItemIDList including zero terminator
931 *
932 * PARAMS
933 * pidl [I] ItemIDList
934 *
935 * RETURNS
936 * size of pidl in bytes
937 *
938 * NOTES
939 * exported by ordinal
940 */
942{
944 UINT len=0;
945
946 if (pidl)
947 {
948 si = &(pidl->mkid);
949
950 while (si->cb)
951 {
952 len += si->cb;
953 si = (LPCSHITEMID)(((const BYTE*)si)+si->cb);
954 }
955 len += 2;
956 }
957 TRACE("pidl=%p size=%u\n",pidl, len);
958 return len;
959}
960
961/*************************************************************************
962 * ILGetNext [SHELL32.153]
963 *
964 * Gets the next ItemID of an ItemIDList
965 *
966 * PARAMS
967 * pidl [I] ItemIDList
968 *
969 * RETURNS
970 * null -> null
971 * desktop -> null
972 * simple pidl -> pointer to 0x0000 element
973 *
974 * NOTES
975 * exported by ordinal.
976 */
978{
979 WORD len;
980
981 TRACE("%p\n", pidl);
982
983 if (pidl)
984 {
985 len = pidl->mkid.cb;
986 if (len)
987 {
988 pidl = (LPCITEMIDLIST) (((const BYTE*)pidl)+len);
989 TRACE("-- %p\n", pidl);
990 return (LPITEMIDLIST)pidl;
991 }
992 }
993 return NULL;
994}
995
996/*************************************************************************
997 * ILAppendID [SHELL32.154]
998 *
999 * Adds the single ItemID item to the ItemIDList indicated by pidl.
1000 * If bEnd is FALSE, inserts the item in the front of the list,
1001 * otherwise it adds the item to the end. (???)
1002 *
1003 * PARAMS
1004 * pidl [I] ItemIDList to extend
1005 * item [I] ItemID to prepend/append
1006 * bEnd [I] Indicates if the item should be appended
1007 *
1008 * NOTES
1009 * Destroys the passed in idlist! (???)
1010 */
1012{
1013 LPITEMIDLIST idlRet;
1015
1016 WARN("(pidl=%p,pidl=%p,%08u)semi-stub\n",pidl,item,bEnd);
1017
1018 pdump (pidl);
1019 pdump (itemid);
1020
1021 if (_ILIsDesktop(pidl))
1022 {
1023 idlRet = ILClone(itemid);
1024 SHFree (pidl);
1025 return idlRet;
1026 }
1027
1028 if (bEnd)
1029 idlRet = ILCombine(pidl, itemid);
1030 else
1031 idlRet = ILCombine(itemid, pidl);
1032
1033 SHFree(pidl);
1034 return idlRet;
1035}
1036
1037/*************************************************************************
1038 * ILFree [SHELL32.155]
1039 *
1040 * Frees memory (if not NULL) allocated by SHMalloc allocator
1041 *
1042 * PARAMS
1043 * pidl [I]
1044 *
1045 * RETURNS
1046 * Nothing
1047 *
1048 * NOTES
1049 * exported by ordinal
1050 */
1052{
1053 TRACE("(pidl=%p)\n",pidl);
1054 SHFree(pidl);
1055}
1056
1057/*************************************************************************
1058 * ILGlobalFree [SHELL32.156]
1059 *
1060 * Frees memory (if not NULL) allocated by Alloc allocator
1061 *
1062 * PARAMS
1063 * pidl [I]
1064 *
1065 * RETURNS
1066 * Nothing
1067 *
1068 * NOTES
1069 * exported by ordinal.
1070 */
1072{
1073 TRACE("%p\n", pidl);
1074
1075 Free(pidl);
1076}
1077
1078/*************************************************************************
1079 * ILCreateFromPathA [SHELL32.189]
1080 *
1081 * Creates a complex ItemIDList from a path and returns it.
1082 *
1083 * PARAMS
1084 * path [I]
1085 *
1086 * RETURNS
1087 * the newly created complex ItemIDList or NULL if failed
1088 *
1089 * NOTES
1090 * exported by ordinal.
1091 */
1093{
1094 LPITEMIDLIST pidlnew = NULL;
1095
1096 TRACE_(shell)("%s\n", debugstr_a(path));
1097
1098 if (SUCCEEDED(SHILCreateFromPathA(path, &pidlnew, NULL)))
1099 return pidlnew;
1100 return NULL;
1101}
1102
1103/*************************************************************************
1104 * ILCreateFromPathW [SHELL32.190]
1105 *
1106 * See ILCreateFromPathA.
1107 */
1109{
1110 LPITEMIDLIST pidlnew = NULL;
1111
1112 TRACE_(shell)("%s\n", debugstr_w(path));
1113
1114 if (SUCCEEDED(SHILCreateFromPathW(path, &pidlnew, NULL)))
1115 return pidlnew;
1116 return NULL;
1117}
1118
1119/*************************************************************************
1120 * ILCreateFromPath [SHELL32.157]
1121 */
1123{
1124 if ( SHELL_OsIsUnicode())
1125 return ILCreateFromPathW (path);
1126 return ILCreateFromPathA (path);
1127}
1128
1129/*************************************************************************
1130 * _ILParsePathW [internal]
1131 *
1132 * Creates an ItemIDList from a path and returns it.
1133 *
1134 * PARAMS
1135 * path [I] path to parse and convert into an ItemIDList
1136 * lpFindFile [I] pointer to buffer to initialize the FileSystem
1137 * Bind Data object with
1138 * bBindCtx [I] indicates to create a BindContext and assign a
1139 * FileSystem Bind Data object
1140 * ppidl [O] the newly create ItemIDList
1141 * prgfInOut [I/O] requested attributes on input and actual
1142 * attributes on return
1143 *
1144 * RETURNS
1145 * NO_ERROR on success or an OLE error code
1146 *
1147 * NOTES
1148 * If either lpFindFile is non-NULL or bBindCtx is TRUE, this function
1149 * creates a BindContext object and assigns a FileSystem Bind Data object
1150 * to it, passing the BindContext to IShellFolder_ParseDisplayName. Each
1151 * IShellFolder uses that FileSystem Bind Data object of the BindContext
1152 * to pass data about the current path element to the next object. This
1153 * is used to avoid having to verify the current path element on disk, so
1154 * that creating an ItemIDList from a nonexistent path still can work.
1155 */
1157 BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut)
1158{
1159 LPSHELLFOLDER pSF = NULL;
1160 LPBC pBC = NULL;
1161 HRESULT ret;
1162
1163 TRACE("%s %p %d (%p)->%p (%p)->0x%x\n", debugstr_w(path), lpFindFile, bBindCtx,
1164 ppidl, ppidl ? *ppidl : NULL,
1165 prgfInOut, prgfInOut ? *prgfInOut : 0);
1166
1167 ret = SHGetDesktopFolder(&pSF);
1168 if (FAILED(ret))
1169 return ret;
1170
1171 if (lpFindFile || bBindCtx)
1172 ret = IFileSystemBindData_Constructor(lpFindFile, &pBC);
1173
1174 if (SUCCEEDED(ret))
1175 {
1176 ret = IShellFolder_ParseDisplayName(pSF, 0, pBC, (LPOLESTR)path, NULL, ppidl, prgfInOut);
1177 }
1178
1179 if (pBC)
1180 {
1181 IBindCtx_Release(pBC);
1182 pBC = NULL;
1183 }
1184
1185 IShellFolder_Release(pSF);
1186
1187 if (FAILED(ret) && ppidl)
1188 *ppidl = NULL;
1189
1190 TRACE("%s %p 0x%x\n", debugstr_w(path), ppidl ? *ppidl : NULL, prgfInOut ? *prgfInOut : 0);
1191
1192 return ret;
1193}
1194
1196{
1198 LPITEMIDLIST pidl = NULL;
1199 _ILParsePathW(pszPath, &data, TRUE, &pidl, NULL);
1200 return pidl;
1201}
1202
1203/*************************************************************************
1204 * SHSimpleIDListFromPath [SHELL32.162]
1205 *
1206 * Creates a simple ItemIDList from a path and returns it. This function
1207 * does not fail on nonexistent paths.
1208 *
1209 * PARAMS
1210 * path [I] path to parse and convert into an ItemIDList
1211 *
1212 * RETURNS
1213 * the newly created simple ItemIDList
1214 *
1215 * NOTES
1216 * Simple in the name does not mean a relative ItemIDList but rather a
1217 * fully qualified list, where only the file name is filled in and the
1218 * directory flag for those ItemID elements this is known about, eg.
1219 * it is not the last element in the ItemIDList or the actual directory
1220 * exists on disk.
1221 * exported by ordinal.
1222 */
1224{
1225 LPITEMIDLIST pidl = NULL;
1226 LPWSTR wPath = NULL;
1227 int len;
1228
1229 TRACE("%s\n", debugstr_a(lpszPath));
1230
1231 if (lpszPath)
1232 {
1233 len = MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, NULL, 0);
1234 wPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
1235 MultiByteToWideChar(CP_ACP, 0, lpszPath, -1, wPath, len);
1236 }
1237
1238 _ILParsePathW(wPath, NULL, TRUE, &pidl, NULL);
1239
1240 HeapFree(GetProcessHeap(), 0, wPath);
1241 TRACE("%s %p\n", debugstr_a(lpszPath), pidl);
1242 return pidl;
1243}
1244
1246{
1247 LPITEMIDLIST pidl = NULL;
1248
1249 TRACE("%s\n", debugstr_w(lpszPath));
1250
1251 _ILParsePathW(lpszPath, NULL, TRUE, &pidl, NULL);
1252
1253 TRACE("%s %p\n", debugstr_w(lpszPath), pidl);
1254 return pidl;
1255}
1256
1258{
1259 if ( SHELL_OsIsUnicode())
1260 return SHSimpleIDListFromPathW (lpszPath);
1261 return SHSimpleIDListFromPathA (lpszPath);
1262}
1263
1265 const SHCOLUMNID *pscid, void*buf, UINT cb)
1266{
1267 VARIANT var;
1268 V_VT(&var) = VT_EMPTY;
1269 HRESULT hr = IShellFolder2_GetDetailsEx(psf2, pidl, pscid, &var);
1270 if (SUCCEEDED(hr))
1271 {
1273 VariantClear(&var);
1274 }
1275 return hr;
1276}
1277
1279 const SHCOLUMNID *pscid, void*buf, UINT cb)
1280{
1281 IShellFolder2 *psf2;
1282 HRESULT hr = IShellFolder_QueryInterface(psf, &IID_IShellFolder2, (void**)&psf2);
1283 if (SUCCEEDED(hr))
1284 {
1285 hr = GetShellFolder2ItemDetailsExToBuffer(psf2, pidl, pscid, buf, cb);
1286 IShellFolder2_Release(psf2);
1287 }
1288 return hr;
1289}
1290
1291/*************************************************************************
1292 * SHGetDataFromIDListA [SHELL32.247]
1293 *
1294 * NOTES
1295 * the pidl can be a simple one. since we can't get the path out of the pidl
1296 * we have to take all data from the pidl
1297 */
1299 int nFormat, LPVOID dest, int len)
1300{
1301 LPSTR filename, shortname;
1303
1304 TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len);
1305
1306 pdump(pidl);
1307 if (!psf || !dest)
1308 return E_INVALIDARG;
1309
1310 switch (nFormat)
1311 {
1312 case SHGDFIL_FINDDATA:
1313 pfd = dest;
1314
1315 if (_ILIsDrive(pidl) || _ILIsSpecialFolder(pidl))
1316 return E_INVALIDARG;
1317
1318 if (len < sizeof(WIN32_FIND_DATAA))
1319 return E_INVALIDARG;
1320
1321 ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA));
1322 _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
1323 pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0);
1324 pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0);
1325
1327 shortname = _ILGetSTextPointer(pidl);
1328
1329 if (filename)
1330 lstrcpynA(pfd->cFileName, filename, sizeof(pfd->cFileName));
1331 else
1332 pfd->cFileName[0] = '\0';
1333
1334 if (shortname)
1335 lstrcpynA(pfd->cAlternateFileName, shortname, sizeof(pfd->cAlternateFileName));
1336 else
1337 pfd->cAlternateFileName[0] = '\0';
1338 return S_OK;
1339
1341 return SHGetDataFromIDListW(psf, pidl, nFormat, dest, len);
1342
1344 FIXME_(shell)("SHGDFIL %i stub\n", nFormat);
1345 break;
1346
1347 default:
1348 ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat);
1349 }
1350
1351 return E_INVALIDARG;
1352}
1353
1354/*************************************************************************
1355 * SHGetDataFromIDListW [SHELL32.248]
1356 *
1357 */
1359 int nFormat, LPVOID dest, int len)
1360{
1361 LPSTR filename, shortname;
1363
1364 TRACE_(shell)("sf=%p pidl=%p 0x%04x %p 0x%04x stub\n",psf,pidl,nFormat,dest,len);
1365
1366 pdump(pidl);
1367
1368 if (!psf || !dest)
1369 return E_INVALIDARG;
1370
1371 switch (nFormat)
1372 {
1373 case SHGDFIL_FINDDATA: /* FIXME: Ask the folder for PID_FINDDATA */
1374 pfd = dest;
1375
1376 if (_ILIsDrive(pidl))
1377 return E_INVALIDARG;
1378
1379 if (len < sizeof(WIN32_FIND_DATAW))
1380 return E_INVALIDARG;
1381
1382 ZeroMemory(pfd, sizeof (WIN32_FIND_DATAW));
1383 _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
1384 pfd->dwFileAttributes = _ILGetFileAttributes(pidl, NULL, 0);
1385 pfd->nFileSizeLow = _ILGetFileSize ( pidl, NULL, 0);
1386
1388 shortname = _ILGetSTextPointer(pidl);
1389
1390 if (!filename)
1391 pfd->cFileName[0] = '\0';
1392 else if (!MultiByteToWideChar(CP_ACP, 0, filename, -1, pfd->cFileName, MAX_PATH))
1393 pfd->cFileName[MAX_PATH-1] = 0;
1394
1395 if (!shortname)
1396 pfd->cAlternateFileName[0] = '\0';
1397 else if (!MultiByteToWideChar(CP_ACP, 0, shortname, -1, pfd->cAlternateFileName, 14))
1398 pfd->cAlternateFileName[13] = 0;
1399 return S_OK;
1400
1402 {
1403 /* TODO: Use PKEY_DescriptionID when the propsys headers are ready */
1404 SHCOLUMNID scid = { FMTID_ShellDetails, PID_DESCRIPTIONID };
1405 return GetShellFolder1ItemDetailsExToBuffer(psf, pidl, &scid, dest, len);
1406 }
1407
1409 FIXME_(shell)("SHGDFIL %i stub\n", nFormat);
1410 break;
1411
1412 default:
1413 ERR_(shell)("Unknown SHGDFIL %i, please report\n", nFormat);
1414 }
1415
1416 return E_INVALIDARG;
1417}
1418
1419/*************************************************************************
1420 * SHGetPathFromIDListA [SHELL32.@][NT 4.0: SHELL32.220]
1421 *
1422 * PARAMETERS
1423 * pidl, [IN] pidl
1424 * pszPath [OUT] path
1425 *
1426 * RETURNS
1427 * path from a passed PIDL.
1428 *
1429 * NOTES
1430 * NULL returns FALSE
1431 * desktop pidl gives path to desktop directory back
1432 * special pidls returning FALSE
1433 */
1435{
1436 WCHAR wszPath[MAX_PATH];
1437 BOOL bSuccess;
1438
1439 bSuccess = SHGetPathFromIDListW(pidl, wszPath);
1440 WideCharToMultiByte(CP_ACP, 0, wszPath, -1, pszPath, MAX_PATH, NULL, NULL);
1441
1442 return bSuccess;
1443}
1444
1445/*************************************************************************
1446 * SHGetPathFromIDListW [SHELL32.@]
1447 *
1448 * See SHGetPathFromIDListA.
1449 */
1452 _In_ LPCITEMIDLIST pidl,
1453 _Out_writes_(cchPathMax) LPWSTR pszPath,
1454 _In_ SIZE_T cchPathMax)
1455{
1456 HRESULT hr;
1457 LPCITEMIDLIST pidlLast;
1458 LPSHELLFOLDER psfFolder;
1460 STRRET strret;
1461
1462 TRACE_(shell)("(pidl=%p,%p)\n", pidl, pszPath);
1463 pdump(pidl);
1464
1465 *pszPath = UNICODE_NULL;
1466 if (!pidl)
1467 return E_FAIL;
1468
1469 hr = SHBindToParent(pidl, &IID_IShellFolder, (VOID**)&psfFolder, &pidlLast);
1470 if (FAILED(hr))
1471 {
1472 ERR("SHBindToParent failed: %x\n", hr);
1473 return hr;
1474 }
1475
1476 dwAttributes = SFGAO_FILESYSTEM;
1477 hr = IShellFolder_GetAttributesOf(psfFolder, 1, &pidlLast, &dwAttributes);
1478 if (FAILED(hr) || !(dwAttributes & SFGAO_FILESYSTEM))
1479 {
1480 WARN("Wrong dwAttributes or GetAttributesOf failed: %x\n", hr);
1481 IShellFolder_Release(psfFolder);
1482 return E_FAIL;
1483 }
1484
1485 hr = IShellFolder_GetDisplayNameOf(psfFolder, pidlLast, SHGDN_FORPARSING, &strret);
1486 IShellFolder_Release(psfFolder);
1487 if (FAILED(hr))
1488 return hr;
1489
1490 hr = StrRetToBufW(&strret, pidlLast, pszPath, cchPathMax);
1491
1492 TRACE_(shell)("-- %s, 0x%08x\n",debugstr_w(pszPath), hr);
1493 return hr;
1494}
1495
1497{
1498 return SUCCEEDED(SHGetPathCchFromIDListW(pidl, pszPath, MAX_PATH));
1499}
1500
1501/*************************************************************************
1502 * SHBindToParent [shell version 5.0]
1503 */
1505{
1506 IShellFolder * psfDesktop;
1508
1509 TRACE_(shell)("pidl=%p\n", pidl);
1510 pdump(pidl);
1511
1512 if (!pidl || !ppv)
1513 return E_INVALIDARG;
1514
1515 *ppv = NULL;
1516 if (ppidlLast)
1517 *ppidlLast = NULL;
1518
1519 hr = SHGetDesktopFolder(&psfDesktop);
1520 if (FAILED(hr))
1521 return hr;
1522
1523 if (_ILIsPidlSimple(pidl))
1524 {
1525 /* we are on desktop level */
1526 hr = IShellFolder_QueryInterface(psfDesktop, riid, ppv);
1527 }
1528 else
1529 {
1530 LPITEMIDLIST pidlParent = ILClone(pidl);
1531 ILRemoveLastID(pidlParent);
1532 hr = IShellFolder_BindToObject(psfDesktop, pidlParent, NULL, riid, ppv);
1533 SHFree (pidlParent);
1534 }
1535
1536 IShellFolder_Release(psfDesktop);
1537
1538 if (SUCCEEDED(hr) && ppidlLast)
1539 *ppidlLast = ILFindLastID(pidl);
1540
1541 TRACE_(shell)("-- psf=%p pidl=%p ret=0x%08x\n", *ppv, (ppidlLast)?*ppidlLast:NULL, hr);
1542 return hr;
1543}
1544
1545/*************************************************************************
1546 * SHParseDisplayName [shell version 6.0]
1547 */
1549 LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
1550{
1551 HRESULT hr;
1552 LPWSTR pszNameDup;
1553 IShellFolder *psfDesktop;
1554 IBindCtx *pBindCtx = NULL;
1555
1556 TRACE("(%s, %p, %p, 0x%X, %p)\n", pszName, pbc, ppidl, sfgaoIn, psfgaoOut);
1557
1558 *ppidl = NULL;
1559
1560 if (psfgaoOut)
1561 *psfgaoOut = 0;
1562
1563 pszNameDup = StrDupW(pszName);
1564 if (!pszNameDup)
1565 return E_OUTOFMEMORY;
1566
1567 psfDesktop = NULL;
1568 hr = SHGetDesktopFolder(&psfDesktop);
1569 if (FAILED(hr))
1570 {
1571 LocalFree(pszNameDup);
1572 return hr;
1573 }
1574
1575 if (!pbc)
1576 {
1577 hr = BindCtx_RegisterObjectParam(NULL, STR_PARSE_TRANSLATE_ALIASES, NULL, &pBindCtx);
1578 pbc = pBindCtx;
1579 }
1580
1581 if (SUCCEEDED(hr))
1582 {
1583 ULONG sfgao = sfgaoIn, cchEaten;
1584 HWND hwndUI = BindCtx_GetUIWindow(pbc);
1585 hr = psfDesktop->lpVtbl->ParseDisplayName(psfDesktop,
1586 hwndUI,
1587 pbc,
1588 pszNameDup,
1589 &cchEaten,
1590 ppidl,
1591 (psfgaoOut ? &sfgao : NULL));
1592 if (SUCCEEDED(hr) && psfgaoOut)
1593 *psfgaoOut = (sfgao & sfgaoIn);
1594 }
1595
1596 LocalFree(pszNameDup);
1597
1598 if (psfDesktop)
1599 psfDesktop->lpVtbl->Release(psfDesktop);
1600
1601 if (pBindCtx)
1602 pBindCtx->lpVtbl->Release(pBindCtx);
1603
1604 return hr;
1605}
1606
1607/*************************************************************************
1608 * SHGetNameFromIDList [SHELL32.@]
1609 */
1611{
1612 IShellFolder *psfparent;
1613 LPCITEMIDLIST child_pidl;
1614 STRRET disp_name;
1615 HRESULT ret;
1616
1617 TRACE("%p 0x%08x %p\n", pidl, sigdnName, ppszName);
1618
1619 *ppszName = NULL;
1620 ret = SHBindToParent(pidl, &IID_IShellFolder, (void**)&psfparent, &child_pidl);
1621 if(SUCCEEDED(ret))
1622 {
1623 switch(sigdnName)
1624 {
1625 /* sigdnName & 0xffff */
1626 case SIGDN_NORMALDISPLAY: /* SHGDN_NORMAL */
1627 case SIGDN_PARENTRELATIVEPARSING: /* SHGDN_INFOLDER | SHGDN_FORPARSING */
1628 case SIGDN_PARENTRELATIVEEDITING: /* SHGDN_INFOLDER | SHGDN_FOREDITING */
1629 case SIGDN_DESKTOPABSOLUTEPARSING: /* SHGDN_FORPARSING */
1630 case SIGDN_DESKTOPABSOLUTEEDITING: /* SHGDN_FOREDITING | SHGDN_FORADDRESSBAR*/
1631 case SIGDN_PARENTRELATIVEFORADDRESSBAR: /* SIGDN_INFOLDER | SHGDN_FORADDRESSBAR */
1632 case SIGDN_PARENTRELATIVE: /* SIGDN_INFOLDER */
1633
1634 disp_name.uType = STRRET_WSTR;
1635 ret = IShellFolder_GetDisplayNameOf(psfparent, child_pidl,
1636 sigdnName & 0xffff,
1637 &disp_name);
1638 if(SUCCEEDED(ret))
1639 ret = StrRetToStrW(&disp_name, pidl, ppszName);
1640
1641 break;
1642
1643 case SIGDN_FILESYSPATH:
1645 if(SHGetPathFromIDListW(pidl, *ppszName))
1646 {
1647 TRACE("Got string %s\n", debugstr_w(*ppszName));
1648 ret = S_OK;
1649 }
1650 else
1651 {
1653 ret = E_INVALIDARG;
1654 }
1655 break;
1656
1657 case SIGDN_URL:
1658 default:
1659 FIXME("Unsupported SIGDN %x\n", sigdnName);
1660 ret = E_FAIL;
1661 }
1662
1663 IShellFolder_Release(psfparent);
1664 }
1665 return ret;
1666}
1667
1668#ifndef __REACTOS__
1669/*************************************************************************
1670 * SHGetItemFromDataObject [SHELL32.@]
1671 */
1673 REFIID riid, void **ppv)
1674{
1675 return E_NOTIMPL; // FIXME
1676}
1677#endif
1678
1679/*************************************************************************
1680 * SHGetIDListFromObject [SHELL32.@]
1681 */
1683{
1684 IPersistIDList *ppersidl;
1685 IPersistFolder2 *ppf2;
1686 IDataObject *pdo;
1687 IFolderView *pfv;
1688 HRESULT ret;
1689
1690 if(!punk)
1691 return E_NOINTERFACE;
1692
1693 *ppidl = NULL;
1694
1695 /* Try IPersistIDList */
1696 ret = IUnknown_QueryInterface(punk, &IID_IPersistIDList, (void**)&ppersidl);
1697 if(SUCCEEDED(ret))
1698 {
1699 TRACE("IPersistIDList (%p)\n", ppersidl);
1700 ret = IPersistIDList_GetIDList(ppersidl, ppidl);
1701 IPersistIDList_Release(ppersidl);
1702 if(SUCCEEDED(ret))
1703 return ret;
1704 }
1705
1706 /* Try IPersistFolder2 */
1707 ret = IUnknown_QueryInterface(punk, &IID_IPersistFolder2, (void**)&ppf2);
1708 if(SUCCEEDED(ret))
1709 {
1710 TRACE("IPersistFolder2 (%p)\n", ppf2);
1711 ret = IPersistFolder2_GetCurFolder(ppf2, ppidl);
1712 IPersistFolder2_Release(ppf2);
1713 if(SUCCEEDED(ret))
1714 return ret;
1715 }
1716
1717 /* Try IDataObject */
1718 ret = IUnknown_QueryInterface(punk, &IID_IDataObject, (void**)&pdo);
1719 if(SUCCEEDED(ret))
1720 {
1721 IShellItem *psi;
1722 TRACE("IDataObject (%p)\n", pdo);
1724 &IID_IShellItem, (void**)&psi);
1725 if(SUCCEEDED(ret))
1726 {
1727 ret = SHGetIDListFromObject((IUnknown*)psi, ppidl);
1728 IShellItem_Release(psi);
1729 }
1730 IDataObject_Release(pdo);
1731
1732 if(SUCCEEDED(ret))
1733 return ret;
1734 }
1735
1736 /* Try IFolderView */
1737 ret = IUnknown_QueryInterface(punk, &IID_IFolderView, (void**)&pfv);
1738 if(SUCCEEDED(ret))
1739 {
1740 IShellFolder *psf;
1741 TRACE("IFolderView (%p)\n", pfv);
1742 ret = IFolderView_GetFolder(pfv, &IID_IShellFolder, (void**)&psf);
1743 if(SUCCEEDED(ret))
1744 {
1745 /* We might be able to get IPersistFolder2 from a shellfolder. */
1746 ret = SHGetIDListFromObject((IUnknown*)psf, ppidl);
1747 }
1748 IFolderView_Release(pfv);
1749 return ret;
1750 }
1751
1752 return ret;
1753}
1754
1755/**************************************************************************
1756 *
1757 * internal functions
1758 *
1759 * ### 1. section creating pidls ###
1760 *
1761 *************************************************************************
1762 */
1763
1764/* Basic PIDL constructor. Allocates size + 5 bytes, where:
1765 * - two bytes are SHITEMID.cb
1766 * - one byte is PIDLDATA.type
1767 * - two bytes are the NULL PIDL terminator
1768 * Sets type of the returned PIDL to type.
1769 */
1771{
1772 LPITEMIDLIST pidlOut = NULL;
1773
1774 pidlOut = SHAlloc(size + 5);
1775 if(pidlOut)
1776 {
1778 LPITEMIDLIST pidlNext;
1779
1780 ZeroMemory(pidlOut, size + 5);
1781 pidlOut->mkid.cb = size + 3;
1782
1783 pData = _ILGetDataPointer(pidlOut);
1784 if (pData)
1785 pData->type = type;
1786
1787 pidlNext = ILGetNext(pidlOut);
1788 if (pidlNext)
1789 pidlNext->mkid.cb = 0x00;
1790 TRACE("-- (pidl=%p, size=%u)\n", pidlOut, size);
1791 }
1792
1793 return pidlOut;
1794}
1795
1797{
1799
1800 TRACE("()\n");
1801 ret = SHAlloc(2);
1802 if (ret)
1803 ret->mkid.cb = 0;
1804 return ret;
1805}
1806
1808{
1809 TRACE("()\n");
1810 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_MyComputer, REGITEMORDER_MYCOMPUTER);
1811}
1812
1814{
1815 TRACE("()\n");
1816 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_MyDocuments, REGITEMORDER_MYDOCS_DEFAULT);
1817}
1818
1820{
1821 TRACE("()\n");
1822 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_Internet, REGITEMORDER_INTERNET);
1823}
1824
1826{
1828
1829 TRACE("()\n");
1830 if (parent)
1831 {
1832 LPITEMIDLIST cpl = _ILCreateGuid(PT_COMPUTER_REGITEM, &CLSID_ControlPanel, REGITEMORDER_MYCOMPUTER_CONTROLS);
1833 if (cpl)
1834 {
1835 ret = ILCombine(parent, cpl);
1836 SHFree(cpl);
1837 }
1838 SHFree(parent);
1839 }
1840 return ret;
1841}
1842
1844{
1845#ifdef __REACTOS__
1846 // Note: Wine returns the PIDL as it was in Windows 95, NT5 moved it into CSIDL_CONTROLS
1847 extern HRESULT SHGetFolderLocationHelper(HWND hwnd, int nFolder, REFCLSID clsid, LPITEMIDLIST *ppidl);
1848 LPITEMIDLIST pidl;
1849 SHGetFolderLocationHelper(NULL, CSIDL_CONTROLS, &CLSID_Printers, &pidl);
1850 return pidl;
1851#else
1852 LPITEMIDLIST parent = _ILCreateGuid(PT_GUID, &CLSID_MyComputer), ret = NULL;
1853
1854 TRACE("()\n");
1855 if (parent)
1856 {
1857 LPITEMIDLIST printers = _ILCreateGuid(PT_YAGUID, &CLSID_Printers);
1858
1859 if (printers)
1860 {
1861 ret = ILCombine(parent, printers);
1862 SHFree(printers);
1863 }
1864 SHFree(parent);
1865 }
1866 return ret;
1867#endif
1868}
1869
1871{
1872 TRACE("()\n");
1873 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_NetworkPlaces, REGITEMORDER_NETHOOD);
1874}
1875
1877{
1878 TRACE("()\n");
1879 return _ILCreateGuid(PT_DESKTOP_REGITEM, &CLSID_RecycleBin, REGITEMORDER_RECYCLEBIN);
1880}
1881
1883{
1884 TRACE("()\n");
1886}
1887
1889{
1890 LPITEMIDLIST pidlOut;
1891
1892 if (type == PT_SHELLEXT || type == PT_GUID || type == PT_YAGUID)
1893 {
1894 pidlOut = _ILAlloc(type, sizeof(GUIDStruct));
1895 if (pidlOut)
1896 {
1898 pData->u.guid.uSortOrder = SortOrder;
1899 pData->u.guid.guid = *guid;
1900 TRACE("-- create GUID-pidl %s\n",
1901 debugstr_guid(&(pData->u.guid.guid)));
1902 }
1903 }
1904 else
1905 {
1906 WARN("%d: invalid type for GUID\n", type);
1907 pidlOut = NULL;
1908 }
1909 return pidlOut;
1910}
1911
1912#ifndef __REACTOS__
1914{
1915 IID iid;
1916
1917 if (FAILED(SHCLSIDFromStringA(szGUID, &iid)))
1918 {
1919 ERR("%s is not a GUID\n", szGUID);
1920 return NULL;
1921 }
1922 return _ILCreateGuid(PT_GUID, &iid);
1923}
1924
1926{
1927 IID iid;
1928
1929#ifndef __REACTOS__
1930 if (FAILED(SHCLSIDFromStringW(szGUID, &iid)))
1931#else
1932 if (!GUIDFromStringW(szGUID, &iid))
1933#endif
1934 {
1935 ERR("%s is not a GUID\n", debugstr_w(szGUID));
1936 return NULL;
1937 }
1938 return _ILCreateGuid(PT_GUID, &iid);
1939}
1940#endif /* __REACTOS__ */
1941
1943{
1944 char buff[MAX_PATH + 14 +1]; /* see WIN32_FIND_DATA */
1945 DWORD len, len1, wlen, alen;
1946 LPITEMIDLIST pidl;
1947 PIDLTYPE type;
1948
1949 if (!wfd)
1950 return NULL;
1951
1952 TRACE("(%s, %s)\n",debugstr_w(wfd->cAlternateFileName), debugstr_w(wfd->cFileName));
1953
1954 /* prepare buffer with both names */
1956 len1 = WideCharToMultiByte(CP_ACP,0,wfd->cAlternateFileName,-1, buff+len, sizeof(buff)-len, NULL, NULL);
1957 alen = len + len1;
1958
1960
1961 wlen = lstrlenW(wfd->cFileName) + 1;
1962 pidl = _ILAlloc(type, FIELD_OFFSET(FileStruct, szNames[alen + (alen & 1)]) +
1963 FIELD_OFFSET(FileStructW, wszName[wlen]) + sizeof(WORD));
1964 if (pidl)
1965 {
1967 FileStruct *fs = &pData->u.file;
1968 FileStructW *fsw;
1969 WORD *pOffsetW;
1970
1971 FileTimeToDosDateTime( &wfd->ftLastWriteTime, &fs->uFileDate, &fs->uFileTime);
1972 fs->dwFileSize = wfd->nFileSizeLow;
1973 fs->uFileAttribs = wfd->dwFileAttributes;
1974 memcpy(fs->szNames, buff, alen);
1975
1976 fsw = (FileStructW*)(pData->u.file.szNames + alen + (alen & 0x1));
1977 fsw->cbLen = FIELD_OFFSET(FileStructW, wszName[wlen]) + sizeof(WORD);
1978 FileTimeToDosDateTime( &wfd->ftCreationTime, &fsw->uCreationDate, &fsw->uCreationTime);
1979 FileTimeToDosDateTime( &wfd->ftLastAccessTime, &fsw->uLastAccessDate, &fsw->uLastAccessTime);
1980 memcpy(fsw->wszName, wfd->cFileName, wlen * sizeof(WCHAR));
1981
1982 pOffsetW = (WORD*)((LPBYTE)pidl + pidl->mkid.cb - sizeof(WORD));
1983 *pOffsetW = (LPBYTE)fsw - (LPBYTE)pidl;
1984 TRACE("-- Set Value: %s\n",debugstr_w(fsw->wszName));
1985 }
1986 return pidl;
1987
1988}
1989
1991{
1992 HANDLE hFile;
1993 WIN32_FIND_DATAW stffile;
1994
1995 if (!ppidl)
1996 return E_INVALIDARG;
1997
1998 hFile = FindFirstFileW(szPath, &stffile);
2001
2003
2004 *ppidl = _ILCreateFromFindDataW(&stffile);
2005
2006 return *ppidl ? S_OK : E_OUTOFMEMORY;
2007}
2008
2010{
2011 LPITEMIDLIST pidlOut;
2012
2013 TRACE("(%s)\n",debugstr_w(lpszNew));
2014
2015 pidlOut = _ILAlloc(PT_DRIVE, sizeof(DriveStruct));
2016 if (pidlOut)
2017 {
2018 LPSTR pszDest = _ILGetTextPointer(pidlOut);
2019 if (pszDest)
2020 {
2021 lstrcpyA(pszDest, "x:\\");
2022 pszDest[0] = toupper(lpszNew[0]);
2023 TRACE("-- create Drive: %s\n", debugstr_a(pszDest));
2024 }
2025 }
2026 return pidlOut;
2027}
2028
2030{
2031 LPITEMIDLIST pidlOut;
2032
2033 TRACE("\n");
2034
2035 pidlOut = _ILAlloc(PT_NETWORK, FIELD_OFFSET(PIDLDATA, u.network.szNames[sizeof("Entire Network")]));
2036 if (pidlOut)
2037 {
2039
2040 pData->u.network.dummy = 0;
2041 strcpy(pData->u.network.szNames, "Entire Network");
2042 }
2043 return pidlOut;
2044}
2045
2046/**************************************************************************
2047 * _ILGetDrive()
2048 *
2049 * Gets the text for the drive eg. 'c:\'
2050 *
2051 * RETURNS
2052 * strlen (lpszText)
2053 */
2055{
2056 TRACE("(%p,%p,%u)\n",pidl,pOut,uSize);
2057
2058 if(_ILIsMyComputer(pidl))
2059 pidl = ILGetNext(pidl);
2060
2061 if (pidl && _ILIsDrive(pidl))
2062 return _ILSimpleGetTextW(pidl, pOut, uSize);
2063
2064 return 0;
2065}
2066
2067/**************************************************************************
2068 *
2069 * ### 2. section testing pidls ###
2070 *
2071 **************************************************************************
2072 * _ILIsUnicode()
2073 * _ILIsDesktop()
2074 * _ILIsMyComputer()
2075 * _ILIsSpecialFolder()
2076 * _ILIsDrive()
2077 * _ILIsFolder()
2078 * _ILIsValue()
2079 * _ILIsPidlSimple()
2080 */
2082{
2083 TRACE("(%p)\n",pidl);
2084
2085 return (_ILGetFSType(pidl) & PT_FS_UNICODE_FLAG) != 0;
2086}
2087
2089{
2090 TRACE("(%p)\n",pidl);
2091
2092 return !pidl || !pidl->mkid.cb;
2093}
2094
2096{
2097 IID *iid = _ILGetGUIDPointer(pidl);
2098
2099 TRACE("(%p)\n", pidl);
2100
2101 if (iid)
2102 return IsEqualIID(iid, &CLSID_MyDocuments);
2103 return FALSE;
2104}
2105
2107{
2108 REFIID iid = _ILGetGUIDPointer(pidl);
2109
2110 TRACE("(%p)\n",pidl);
2111
2112 if (iid)
2113 return IsEqualIID(iid, &CLSID_MyComputer);
2114 return FALSE;
2115}
2116
2118{
2119 IID *iid = _ILGetGUIDPointer(pidl);
2120
2121 TRACE("(%p)\n", pidl);
2122
2123 if (iid)
2124 return IsEqualIID(iid, &CLSID_RecycleBin);
2125 return FALSE;
2126}
2127
2129{
2130 LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
2131
2132 TRACE("(%p)\n",pidl);
2133
2134 return (pidl && ( (lpPData && (PT_GUID== lpPData->type || PT_SHELLEXT== lpPData->type || PT_YAGUID == lpPData->type)) ||
2135 (pidl && pidl->mkid.cb == 0x00)
2136 ));
2137}
2138
2140{
2141 const BYTE type = _ILGetType(pidl);
2142 const BYTE fldrtype = (PT_DRIVE & PT_FOLDERTYPEMASK);
2143 return (type & PT_FOLDERTYPEMASK) == fldrtype && type != PT_COMPUTER_REGITEM;
2144}
2145
2147{
2148 /* A folder or a simple PT_FS with a child */
2149 const BYTE type = _ILGetFSType(pidl);
2150 return (type & PT_FS_FOLDER_FLAG) != 0 || (type == PT_FS && ILGetNext(pidl));
2151}
2152
2154{
2155 const BYTE type = _ILGetFSType(pidl);
2156 return type && !(type & PT_FS_FOLDER_FLAG);
2157}
2158
2160{
2161 LPPIDLDATA lpPData = _ILGetDataPointer(pidl);
2162
2163 TRACE("(%p)\n",pidl);
2164
2165 return (pidl && lpPData && (lpPData->type == 0));
2166}
2167
2168/**************************************************************************
2169 * _ILIsPidlSimple
2170 */
2172{
2173 BOOL ret = TRUE;
2174
2175 if(! _ILIsDesktop(pidl)) /* pidl=NULL or mkid.cb=0 */
2176 {
2177 WORD len = pidl->mkid.cb;
2178 LPCITEMIDLIST pidlnext = (LPCITEMIDLIST) (((const BYTE*)pidl) + len );
2179
2180 if (pidlnext->mkid.cb)
2181 ret = FALSE;
2182 }
2183
2184 TRACE("%s\n", ret ? "Yes" : "No");
2185 return ret;
2186}
2187
2188/**************************************************************************
2189 *
2190 * ### 3. section getting values from pidls ###
2191 */
2192
2193/**************************************************************************
2194 * _ILSimpleGetTextW
2195 *
2196 * gets the text for the first item in the pidl (eg. simple pidl)
2197 *
2198 * returns the length of the string
2199 */
2201{
2202 DWORD dwReturn;
2203 FileStructW *pFileStructW = _ILGetFileStructW(pidl);
2204
2205 TRACE("(%p %p %x)\n",pidl,szOut,uOutSize);
2206
2207 if (pFileStructW) {
2208 lstrcpynW(szOut, pFileStructW->wszName, uOutSize);
2209 dwReturn = lstrlenW(pFileStructW->wszName);
2210 } else {
2211 GUID const * riid;
2212 WCHAR szTemp[MAX_PATH];
2213 LPSTR szSrc;
2214 LPWSTR szSrcW;
2215 dwReturn=0;
2216
2217 if (!pidl)
2218 return 0;
2219
2220 if (szOut)
2221 *szOut = 0;
2222
2223 if (_ILIsDesktop(pidl))
2224 {
2225 /* desktop */
2226 if (HCR_GetClassNameW(&CLSID_ShellDesktop, szTemp, _countof(szTemp)))
2227 {
2228 if (szOut)
2229 lstrcpynW(szOut, szTemp, uOutSize);
2230
2231 dwReturn = lstrlenW (szTemp);
2232 }
2233 }
2234 else if (( szSrcW = _ILGetTextPointerW(pidl) ))
2235 {
2236 /* unicode filesystem */
2237 if (szOut)
2238 lstrcpynW(szOut, szSrcW, uOutSize);
2239
2240 dwReturn = lstrlenW(szSrcW);
2241 }
2242 else if (( szSrc = _ILGetTextPointer(pidl) ))
2243 {
2244 /* filesystem */
2245 MultiByteToWideChar(CP_ACP, 0, szSrc, -1, szTemp, _countof(szTemp));
2246
2247 if (szOut)
2248 lstrcpynW(szOut, szTemp, uOutSize);
2249
2250 dwReturn = lstrlenW (szTemp);
2251 }
2252 else if (( riid = _ILGetGUIDPointer(pidl) ))
2253 {
2254 /* special folder */
2255 if ( HCR_GetClassNameW(riid, szTemp, _countof(szTemp)))
2256 {
2257 if (szOut)
2258 lstrcpynW(szOut, szTemp, uOutSize);
2259
2260 dwReturn = lstrlenW (szTemp);
2261 }
2262 }
2263 else
2264 {
2265 ERR("-- no text\n");
2266 }
2267 }
2268
2269 TRACE("-- (%p=%s 0x%08x)\n",szOut,debugstr_w(szOut),dwReturn);
2270 return dwReturn;
2271}
2272
2273/**************************************************************************
2274 *
2275 * ### 4. getting pointers to parts of pidls ###
2276 *
2277 **************************************************************************
2278 * _ILGetDataPointer()
2279 */
2281{
2282 if(!_ILIsEmpty(pidl))
2283 return (LPPIDLDATA)pidl->mkid.abID;
2284 return NULL;
2285}
2286
2287/**************************************************************************
2288 * _ILGetTextPointerW()
2289 * gets a pointer to the unicode long filename string stored in the pidl
2290 */
2292{
2293 /* TRACE(pidl,"(pidl%p)\n", pidl);*/
2294
2296
2297 if (!pdata)
2298 return NULL;
2299
2300 if (_ILGetFSType(pidl) & PT_FS_UNICODE_FLAG)
2301 return (LPWSTR)pdata->u.file.szNames;
2302
2303 switch (pdata->type)
2304 {
2305 case PT_GUID:
2306 case PT_SHELLEXT:
2307 case PT_YAGUID:
2308 return NULL;
2309
2310 case PT_DRIVE:
2311 case PT_DRIVE1:
2312 case PT_DRIVE2:
2313 case PT_DRIVE3:
2314 /*return (LPSTR)&(pdata->u.drive.szDriveName);*/
2315 return NULL;
2316
2317 case PT_IESPECIAL1:
2318 case PT_IESPECIAL2:
2319 /*return (LPSTR)&(pdata->u.file.szNames);*/
2320 return NULL;
2321
2322 case PT_WORKGRP:
2323 case PT_COMP:
2324 case PT_NETWORK:
2325 case PT_NETPROVIDER:
2326 case PT_SHARE:
2327 /*return (LPSTR)&(pdata->u.network.szNames);*/
2328 return NULL;
2329
2330#ifdef __REACTOS__ /* r54423 */
2331 case PT_CPLAPPLET:
2332 return pdata->u.cpanel.szName;
2333#endif
2334
2335 }
2336 return NULL;
2337}
2338
2339
2340/**************************************************************************
2341 * _ILGetTextPointer()
2342 * gets a pointer to the long filename string stored in the pidl
2343 */
2345{
2346 /* TRACE(pidl,"(pidl%p)\n", pidl);*/
2347
2348 PIDLTYPE type;
2350 if (!pdata)
2351 return NULL;
2352
2353 type = _ILGetFSType(pidl);
2354 if (type && !(type & PT_FS_UNICODE_FLAG))
2355 return pdata->u.file.szNames;
2356
2357 if (_ILIsDrive(pidl))
2358 return pdata->u.drive.szDriveName;
2359
2360 switch (pdata->type)
2361 {
2362 case PT_GUID:
2363 case PT_SHELLEXT:
2364 case PT_YAGUID:
2365 return NULL;
2366
2367 case PT_IESPECIAL1:
2368 case PT_IESPECIAL2:
2369 return pdata->u.file.szNames;
2370
2371 case PT_WORKGRP:
2372 case PT_COMP:
2373 case PT_NETWORK:
2374 case PT_NETPROVIDER:
2375 case PT_SHARE:
2376 return pdata->u.network.szNames;
2377 }
2378 return NULL;
2379}
2380
2381/**************************************************************************
2382 * _ILGetSTextPointer()
2383 * gets a pointer to the short filename string stored in the pidl
2384 */
2386{
2387 /* TRACE(pidl,"(pidl%p)\n", pidl); */
2388
2389 PIDLTYPE type;
2391 if (!pdata)
2392 return NULL;
2393
2394 type = pdata->type;
2395 if (_ILGetFSType(pidl) && !(type & PT_FS_UNICODE_FLAG))
2396 type = PT_FS;
2397
2398 switch (type)
2399 {
2400 case PT_FS:
2401 case PT_IESPECIAL1:
2402 case PT_IESPECIAL2:
2403 return pdata->u.file.szNames + strlen (pdata->u.file.szNames) + 1;
2404
2405 case PT_WORKGRP:
2406 return pdata->u.network.szNames + strlen (pdata->u.network.szNames) + 1;
2407 }
2408 return NULL;
2409}
2410
2411/**************************************************************************
2412 * _ILGetGUIDPointer()
2413 *
2414 * returns reference to guid stored in some pidls
2415 */
2417{
2419
2420 TRACE("%p\n", pidl);
2421
2422 if (!pdata)
2423 return NULL;
2424
2425 TRACE("pdata->type 0x%04x\n", pdata->type);
2426 switch (pdata->type)
2427 {
2428 case PT_SHELLEXT:
2429 case PT_GUID:
2430 case PT_YAGUID:
2431 return &(pdata->u.guid.guid);
2432
2433 default:
2434 TRACE("Unknown pidl type 0x%04x\n", pdata->type);
2435 break;
2436 }
2437 return NULL;
2438}
2439
2440/******************************************************************************
2441 * _ILGetFileStructW [Internal]
2442 *
2443 * Get pointer the a SHITEMID's FileStructW field if present
2444 *
2445 * PARAMS
2446 * pidl [I] The SHITEMID
2447 *
2448 * RETURNS
2449 * Success: Pointer to pidl's FileStructW field.
2450 * Failure: NULL
2451 */
2453 FileStructW *pFileStructW;
2454 WORD cbOffset;
2455
2456 if (!_ILIsFolderOrFile(pidl))
2457 return NULL;
2458
2459 cbOffset = *(const WORD *)((const BYTE *)pidl + pidl->mkid.cb - sizeof(WORD));
2460 pFileStructW = (FileStructW*)((LPBYTE)pidl + cbOffset);
2461
2462 /* Currently I don't see a fool prove way to figure out if a pidl is for sure of WinXP
2463 * style with a FileStructW member. If we switch all our shellfolder-implementations to
2464 * the new format, this won't be a problem. For now, we do as many sanity checks as possible. */
2465 if ((cbOffset & 0x1) || /* FileStructW member is word aligned in the pidl */
2466 /* FileStructW is positioned after FileStruct */
2467 cbOffset < sizeof(pidl->mkid.cb) + sizeof(PIDLTYPE) + sizeof(FileStruct) ||
2468 /* There has to be enough space at cbOffset in the pidl to hold FileStructW and cbOffset */
2469 cbOffset > pidl->mkid.cb - sizeof(cbOffset) - sizeof(FileStructW) ||
2470 pidl->mkid.cb != cbOffset + pFileStructW->cbLen)
2471 {
2472 WARN("Invalid pidl format (cbOffset = %d)!\n", cbOffset);
2473 return NULL;
2474 }
2475
2476 return pFileStructW;
2477}
2478
2479/*************************************************************************
2480 * _ILGetFileDateTime
2481 *
2482 * Given the ItemIdList, get the FileTime
2483 *
2484 * PARAMS
2485 * pidl [I] The ItemIDList
2486 * pFt [I] the resulted FILETIME of the file
2487 *
2488 * RETURNS
2489 * True if Successful
2490 *
2491 * NOTES
2492 *
2493 */
2495{
2496 if (_ILGetFSType(pidl) > PT_FS) /* Only non-simple FS items have a date */
2497 {
2499 return DosDateTimeToFileTime(pdata->u.file.uFileDate, pdata->u.file.uFileTime, pFt);
2500 }
2501 return FALSE;
2502}
2503
2504/*************************************************************************
2505 * _ILGetFileSize
2506 *
2507 * Given the ItemIdList, get the FileSize
2508 *
2509 * PARAMS
2510 * pidl [I] The ItemIDList
2511 * pOut [I] The buffer to save the result
2512 * uOutsize [I] The size of the buffer
2513 *
2514 * RETURNS
2515 * The FileSize
2516 *
2517 * NOTES
2518 * pOut can be null when no string is needed
2519 *
2520 */
2522{
2524 if (!pdata)
2525 return 0;
2526
2527 if (_ILGetFSType(pidl) & PT_FS_FILE_FLAG)
2528 {
2529 /* FIXME: Handle INVALID_FILE_SIZE (get size from disk) */
2530 DWORD dwSize = pdata->u.file.dwFileSize;
2531 if (pOut)
2532 StrFormatKBSizeW(dwSize, pOut, uOutSize);
2533 return dwSize;
2534 }
2535 if (pOut)
2536 *pOut = UNICODE_NULL;
2537 return 0;
2538}
2539
2541{
2542 WCHAR szTemp[MAX_PATH];
2543 LPCWSTR pPoint;
2544 LPCITEMIDLIST pidlTemp = pidl;
2545
2546 TRACE("pidl=%p\n",pidl);
2547
2548 if (!pidl)
2549 return FALSE;
2550
2551 pidlTemp = ILFindLastID(pidl);
2552
2553 if (!_ILIsValue(pidlTemp))
2554 return FALSE;
2555 if (!_ILSimpleGetTextW(pidlTemp, szTemp, _countof(szTemp)))
2556 return FALSE;
2557
2558 pPoint = PathFindExtensionW(szTemp);
2559
2560 if (!*pPoint)
2561 return FALSE;
2562
2563 pPoint++;
2564 lstrcpynW(pOut, pPoint, uOutSize);
2565 TRACE("%s\n", debugstr_w(pOut));
2566
2567 return TRUE;
2568}
2569
2570/*************************************************************************
2571 * _ILGetFileAttributes
2572 *
2573 * Given the ItemIdList, get the Attrib string format
2574 *
2575 * PARAMS
2576 * pidl [I] The ItemIDList
2577 * pOut [I] The buffer to save the result
2578 * uOutsize [I] The size of the Buffer
2579 *
2580 * RETURNS
2581 * Attributes
2582 *
2583 * FIXME
2584 * return value 0 in case of error is a valid return value
2585 *
2586 */
2588{
2589 DWORD wAttrib = 0;
2590 if (_ILGetFSType(pidl))
2591 wAttrib = _ILGetDataPointer(pidl)->u.file.uFileAttribs;
2592
2593 if (uOutSize >= 6)
2594 {
2595 UINT i = 0;
2596 if(wAttrib & FILE_ATTRIBUTE_READONLY)
2597 pOut[i++] = L'R';
2598 if(wAttrib & FILE_ATTRIBUTE_HIDDEN)
2599 pOut[i++] = L'H';
2600 if(wAttrib & FILE_ATTRIBUTE_SYSTEM)
2601 pOut[i++] = L'S';
2602 if(wAttrib & FILE_ATTRIBUTE_ARCHIVE)
2603 pOut[i++] = L'A';
2604 if(wAttrib & FILE_ATTRIBUTE_COMPRESSED)
2605 pOut[i++] = L'C';
2606 pOut[i] = UNICODE_NULL;
2607 }
2608 return wAttrib;
2609}
2610
2611/*************************************************************************
2612 * ILFreeaPidl
2613 *
2614 * frees an aPidl struct
2615 */
2616void _ILFreeaPidl(LPITEMIDLIST * apidl, UINT cidl)
2617{
2618 if (apidl)
2619 {
2620 for (UINT i = 0; i < cidl; i++)
2621 SHFree(apidl[i]);
2622 SHFree(apidl);
2623 }
2624}
2625
2626/*************************************************************************
2627 * ILCopyaPidl
2628 *
2629 * copies an aPidl struct
2630 */
2632{
2633 PITEMID_CHILD *apidldest;
2634
2635 if (!apidlsrc)
2636 return NULL;
2637
2638 apidldest = SHAlloc(cidl * sizeof(PITEMID_CHILD));
2639 for (UINT i = 0; i < cidl; i++)
2640 {
2641 PITEMID_CHILD clone = ILClone(apidlsrc[i]);
2642 if ((apidldest[i] = clone) == NULL)
2643 {
2644 _ILFreeaPidl(apidldest, i);
2645 return NULL;
2646 }
2647 }
2648 return apidldest;
2649}
2650
2651/*************************************************************************
2652 * _ILCopyCidaToaPidl
2653 *
2654 * creates aPidl from CIDA
2655 */
2657{
2658 UINT i;
2659 LPITEMIDLIST *dst = SHAlloc(cida->cidl * sizeof(LPITEMIDLIST));
2660 if (!dst)
2661 return NULL;
2662
2663 for (i = 0; i < cida->cidl; i++)
2664 {
2665 PITEMID_CHILD clone = ILClone(HIDA_GetPIDLItem(cida, i));
2666 if ((dst[i] = clone) == NULL)
2667 {
2668 _ILFreeaPidl(dst, i);
2669 return NULL;
2670 }
2671 }
2672
2673 if (pidl)
2674 {
2675 *pidl = ILClone(HIDA_GetPIDLFolder(cida));
2676 if (!*pidl)
2677 {
2678 _ILFreeaPidl(dst, cida->cidl);
2679 return NULL;
2680 }
2681 }
2682 return dst;
2683}
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define EXTERN_C
Definition: basetyps.h:12
#define NO_ERROR
Definition: dderror.h:5
#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
void pdump(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:322
BOOL pcheck(LPCITEMIDLIST pidl)
Definition: debughlp.cpp:360
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SHCIDS_CANONICALONLY
Definition: shobjidl.idl:226
void *WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: malloc.c:381
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
#define GetProcessHeap()
Definition: compat.h:736
#define FIXME_(x)
Definition: compat.h:77
#define CP_ACP
Definition: compat.h:109
#define TRACE_(x)
Definition: compat.h:76
#define lstrcpynA
Definition: compat.h:751
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
#define WideCharToMultiByte
Definition: compat.h:111
#define MultiByteToWideChar
Definition: compat.h:110
@ VT_EMPTY
Definition: compat.h:2295
#define wcsicmp
Definition: compat.h:15
#define lstrcpynW
Definition: compat.h:738
#define lstrlenW
Definition: compat.h:750
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI DosDateTimeToFileTime(IN WORD wFatDate, IN WORD wFatTime, OUT LPFILETIME lpFileTime)
Definition: time.c:75
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
Definition: time.c:37
LPWSTR WINAPI PathFindExtensionW(const WCHAR *path)
Definition: path.c:1250
WCHAR *WINAPI StrDupW(const WCHAR *str)
Definition: string.c:317
GUID guid
Definition: version.c:147
static MonoProfilerRuntimeShutdownBeginCallback cb
Definition: metahost.c:118
int CDECL toupper(int c)
Definition: ctype.c:514
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
const GUID CLSID_AdminFolderShortcut
EXTERN_C HRESULT SHELL32_AliasTranslatePidl(_In_ LPCITEMIDLIST pidl, _Out_ LPITEMIDLIST *ppidlNew, _In_ DWORD dwFlags)
Translate a PIDL to an "alias" PIDL.
Definition: utils.cpp:2321
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:370
DWORD WINAPI SHCLSIDFromStringA(LPCSTR clsid, CLSID *id)
Definition: shellole.c:292
DWORD WINAPI SHCLSIDFromStringW(LPCWSTR clsid, CLSID *id)
Definition: shellole.c:300
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:348
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3385
LPWSTR WINAPI StrFormatKBSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:475
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:248
HRESULT WINAPI StrRetToStrW(LPSTRRET lpStrRet, const ITEMIDLIST *pidl, LPWSTR *ppszName)
Definition: string.c:349
#define IShellFolder_ParseDisplayName
Definition: utils.cpp:14
#define IShellFolder_CompareIDs
Definition: utils.cpp:15
#define IShellFolder_GetDisplayNameOf
Definition: utils.cpp:13
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
r parent
Definition: btrfs.c:3010
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxObject * pParent
Definition: fxdpcapi.cpp:86
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLenum dst
Definition: glext.h:6340
GLenum GLsizei len
Definition: glext.h:6722
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 flag
Definition: glfuncs.h:52
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 * u
Definition: glfuncs.h:240
unsigned int UINT
Definition: sysinfo.c:13
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT ParseDisplayName([in] HWND hwndOwner, [in] LPBC pbcReserved, [in, string] LPOLESTR lpszDisplayName, [out] ULONG *pchEaten, [out] PIDLIST_RELATIVE *ppidl, [in, out, unique] ULONG *pdwAttributes)
ULONG Release()
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
const char * filename
Definition: ioapi.h:137
static ERESOURCE GlobalLock
Definition: sys_arch.c:8
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
#define PT_FS_UNICODE_FLAG
Definition: lnktool.cpp:41
#define PT_FS
Definition: lnktool.cpp:40
#define PT_COMPUTER_REGITEM
Definition: lnktool.cpp:39
#define PT_DESKTOP_REGITEM
Definition: lnktool.cpp:38
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define ZeroMemory
Definition: minwinbase.h:31
#define CopyMemory
Definition: minwinbase.h:29
CONST void * LPCVOID
Definition: minwindef.h:164
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
const char * var
Definition: shader.c:5666
static SYSTEM_INFO si
Definition: virtual.c:39
static char * dest
Definition: rtl.c:149
static PROTOCOLDATA * pdata
Definition: protocol.c:163
const CLSID * clsid
Definition: msctf.cpp:50
_In_ HANDLE hFile
Definition: mswsock.h:90
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define _Out_writes_(s)
Definition: no_sal2.h:176
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
#define FILE_ATTRIBUTE_COMPRESSED
Definition: nt_native.h:711
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
#define FILE_ATTRIBUTE_SYSTEM
Definition: nt_native.h:704
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define UNICODE_NULL
interface IBindCtx * LPBC
Definition: objfwd.h:18
#define V_VT(A)
Definition: oleauto.h:211
const GUID IID_IDataObject
static HANDLE ACCESS_MASK ULONG attributes
Definition: om.c:94
BOOL WINAPI GUIDFromStringW(_In_ PCWSTR psz, _Out_ LPGUID pguid)
#define LOWORD(l)
Definition: pedump.c:82
short WCHAR
Definition: pedump.c:58
LPITEMIDLIST WINAPI SHSimpleIDListFromPathA(LPCSTR lpszPath)
Definition: pidl.c:1223
BOOL _ILIsUnicode(LPCITEMIDLIST pidl)
Definition: pidl.c:2081
LPITEMIDLIST WINAPI SHCloneSpecialIDList(HWND hwndOwner, int nFolder, BOOL fCreate)
Definition: pidl.c:446
LPITEMIDLIST _ILCreateMyComputer(void)
Definition: pidl.c:1807
PITEMID_CHILD * _ILCopyaPidl(PCUITEMID_CHILD_ARRAY apidlsrc, UINT cidl)
Definition: pidl.c:2631
static HRESULT _ILParsePathW(LPCWSTR path, LPWIN32_FIND_DATAW lpFindFile, BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut)
Definition: pidl.c:1156
static LPWSTR _ILGetTextPointerW(LPCITEMIDLIST pidl)
Definition: pidl.c:2291
LPITEMIDLIST _ILCreateIExplore(void)
Definition: pidl.c:1819
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:238
LPITEMIDLIST WINAPI ILGlobalClone(LPCITEMIDLIST pidl)
Definition: pidl.c:472
static LPSTR _ILGetSTextPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2385
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
LPITEMIDLIST * _ILCopyCidaToaPidl(LPITEMIDLIST *pidl, const CIDA *cida)
Definition: pidl.c:2656
BOOL _ILHACKCompareSimpleIds(LPCITEMIDLIST pidltemp1, LPCITEMIDLIST pidltemp2)
Definition: pidl.c:522
HRESULT WINAPI SHILCreateFromPathW(LPCWSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:404
DWORD _ILGetFileAttributes(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2587
LPITEMIDLIST WINAPI ILFindLastID(LPCITEMIDLIST pidl)
Definition: pidl.c:199
HRESULT WINAPI SHGetIDListFromObject(IUnknown *punk, PIDLIST_ABSOLUTE *ppidl)
Definition: pidl.c:1682
LPITEMIDLIST _ILCreateEntireNetwork(void)
Definition: pidl.c:2029
BOOL WINAPI ILIsParent(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
Definition: pidl.c:698
LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW(LPCVOID lpszPath)
Definition: pidl.c:1257
HRESULT WINAPI SHGetNameFromIDList(PCIDLIST_ABSOLUTE pidl, SIGDN sigdnName, PWSTR *ppszName)
Definition: pidl.c:1610
HRESULT WINAPI SHParseDisplayName(LPCWSTR pszName, IBindCtx *pbc, LPITEMIDLIST *ppidl, SFGAOF sfgaoIn, SFGAOF *psfgaoOut)
Definition: pidl.c:1548
BOOL _ILIsMyDocuments(LPCITEMIDLIST pidl)
Definition: pidl.c:2095
LPITEMIDLIST _ILCreateDrive(LPCWSTR lpszNew)
Definition: pidl.c:2009
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:817
LPSTR _ILGetTextPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2344
static HRESULT GetShellFolder2ItemDetailsExToBuffer(IShellFolder2 *psf2, LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, void *buf, UINT cb)
Definition: pidl.c:1264
LPITEMIDLIST _ILCreateDesktop(void)
Definition: pidl.c:1796
LPPIDLDATA _ILGetDataPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2280
LPITEMIDLIST WINAPI SHLogILFromFSIL(LPITEMIDLIST pidl)
Definition: pidl.c:912
HRESULT WINAPI SHGetRealIDL(LPSHELLFOLDER lpsf, LPCITEMIDLIST pidlSimple, LPITEMIDLIST *pidlReal)
Definition: pidl.c:861
LPITEMIDLIST WINAPI ILCloneFirst(LPCITEMIDLIST pidl)
Definition: pidl.c:263
LPCITEMIDLIST _ILIsParentEx(LPCITEMIDLIST pidlParent, LPCITEMIDLIST pidlChild, BOOL bImmediate)
Definition: pidl.c:639
BOOL WINAPI SHGetPathFromIDListA(LPCITEMIDLIST pidl, LPSTR pszPath)
Definition: pidl.c:1434
LPITEMIDLIST WINAPI ILCreateFromPathAW(LPCVOID path)
Definition: pidl.c:1122
BOOL WINAPI ILRemoveLastID(LPITEMIDLIST pidl)
Definition: pidl.c:222
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1504
FileStructW * _ILGetFileStructW(LPCITEMIDLIST pidl)
Definition: pidl.c:2452
BOOL _ILIsSpecialFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:2128
HRESULT _ILCreateFromPathW(LPCWSTR szPath, LPITEMIDLIST *ppidl)
Definition: pidl.c:1990
HRESULT WINAPI ILSaveToStream(IStream *pStream, LPCITEMIDLIST pPidl)
Definition: pidl.c:354
LPITEMIDLIST _ILCreateNetwork(void)
Definition: pidl.c:1870
BOOL WINAPI ILGetDisplayName(LPCITEMIDLIST pidl, LPVOID path)
Definition: pidl.c:184
BOOL _ILIsFolder(LPCITEMIDLIST pidl)
Definition: pidl.c:2146
DWORD _ILGetDrive(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uSize)
Definition: pidl.c:2054
LPITEMIDLIST WINAPI ILAppendID(LPITEMIDLIST pidl, LPCSHITEMID item, BOOL bEnd)
Definition: pidl.c:1011
UINT WINAPI ILGetSize(LPCITEMIDLIST pidl)
Definition: pidl.c:941
BOOL _ILIsPidlSimple(LPCITEMIDLIST pidl)
Definition: pidl.c:2171
BOOL _ILIsBitBucket(LPCITEMIDLIST pidl)
Definition: pidl.c:2117
BOOL _ILIsMyComputer(LPCITEMIDLIST pidl)
Definition: pidl.c:2106
BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
Definition: pidl.c:1496
void _ILFreeaPidl(LPITEMIDLIST *apidl, UINT cidl)
Definition: pidl.c:2616
HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len)
Definition: pidl.c:1298
void WINAPI ILGlobalFree(LPITEMIDLIST pidl)
Definition: pidl.c:1071
BOOL WINAPI ILGetDisplayNameEx(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPVOID path, DWORD type)
Definition: pidl.c:172
HRESULT WINAPI ILLoadFromStream(IStream *pStream, LPITEMIDLIST *ppPidl)
Definition: pidl.c:294
LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath)
Definition: pidl.c:1245
HRESULT WINAPI SHGetItemFromDataObject(IDataObject *pdtobj, DATAOBJ_GET_ITEM_FLAGS dwFlags, REFIID riid, void **ppv)
Definition: pidl.c:1672
LPVOID WINAPI Alloc(INT)
LPITEMIDLIST WINAPI ILGetNext(LPCITEMIDLIST pidl)
Definition: pidl.c:977
LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID)
Definition: pidl.c:1913
EXTERN_C HRESULT BindCtx_RegisterObjectParam(_In_ IBindCtx *pBindCtx, _In_ LPOLESTR pszKey, _In_opt_ IUnknown *punk, _Out_ LPBC *ppbc)
Definition: utils.cpp:645
LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID)
Definition: pidl.c:1925
BOOL ILGetDisplayNameExW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPWSTR path, DWORD type)
Definition: pidl.c:101
static LPITEMIDLIST _ILAlloc(PIDLTYPE type, unsigned int size)
Definition: pidl.c:1770
IID * _ILGetGUIDPointer(LPCITEMIDLIST pidl)
Definition: pidl.c:2416
LPITEMIDLIST SHELL32_CreateSimpleIDListFromPath(LPCWSTR pszPath, DWORD dwAttributes)
Definition: pidl.c:1195
HRESULT WINAPI SHGetPathCchFromIDListW(_In_ LPCITEMIDLIST pidl, _Out_writes_(cchPathMax) LPWSTR pszPath, _In_ SIZE_T cchPathMax)
Definition: pidl.c:1451
HRESULT WINAPI SHILCreateFromPathAW(LPCVOID path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:420
PUIDLIST_RELATIVE WINAPI ILFindChild(PIDLIST_ABSOLUTE pidl1, PCIDLIST_ABSOLUTE pidl2)
Definition: pidl.c:751
BOOL _ILGetFileDateTime(LPCITEMIDLIST pidl, FILETIME *pFt)
Definition: pidl.c:2494
LPITEMIDLIST _ILCreatePrinters(void)
Definition: pidl.c:1843
HRESULT WINAPI SHILCreateFromPathA(LPCSTR path, LPITEMIDLIST *ppidl, DWORD *attributes)
Definition: pidl.c:392
DWORD _ILGetFileSize(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2521
LPITEMIDLIST _ILCreateControlPanel(void)
Definition: pidl.c:1825
static HRESULT GetShellFolder1ItemDetailsExToBuffer(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, const SHCOLUMNID *pscid, void *buf, UINT cb)
Definition: pidl.c:1278
EXTERN_C HWND BindCtx_GetUIWindow(_In_ IBindCtx *pBindCtx)
Definition: utils.cpp:585
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: pidl.c:2088
BOOL _ILIsValue(LPCITEMIDLIST pidl)
Definition: pidl.c:2153
static BOOL ILGetDisplayNameExA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, LPSTR path, DWORD type)
Definition: pidl.c:84
LPITEMIDLIST WINAPI ILCreateFromPathW(LPCWSTR path)
Definition: pidl.c:1108
BOOL _ILIsDrive(LPCITEMIDLIST pidl)
Definition: pidl.c:2139
HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int nFormat, LPVOID dest, int len)
Definition: pidl.c:1358
LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid, BYTE SortOrder)
Definition: pidl.c:1888
BOOL _ILGetExtension(LPCITEMIDLIST pidl, LPWSTR pOut, UINT uOutSize)
Definition: pidl.c:2540
LPITEMIDLIST _ILCreateMyDocuments(void)
Definition: pidl.c:1813
LPITEMIDLIST _ILCreateBitBucket(void)
Definition: pidl.c:1876
DWORD _ILSimpleGetTextW(LPCITEMIDLIST pidl, LPWSTR szOut, UINT uOutSize)
Definition: pidl.c:2200
LPITEMIDLIST WINAPI ILCreateFromPathA(LPCSTR path)
Definition: pidl.c:1092
LPITEMIDLIST _ILCreateFromFindDataW(const WIN32_FIND_DATAW *wfd)
Definition: pidl.c:1942
BOOL WINAPI ILIsEqual(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:583
LPITEMIDLIST _ILCreateAdminTools(void)
Definition: pidl.c:1882
BOOL _ILIsCPanelStruct(LPCITEMIDLIST pidl)
Definition: pidl.c:2159
#define PT_DRIVE1
Definition: pidl.h:92
#define PT_WORKGRP
Definition: pidl.h:98
#define PT_FOLDER
Definition: pidl.h:94
#define PT_DRIVE3
Definition: pidl.h:90
#define PT_VALUE
Definition: pidl.h:95
BYTE PIDLTYPE
Definition: pidl.h:156
#define PT_DRIVE
Definition: pidl.h:88
struct tagFileStruct FileStruct
#define PT_IESPECIAL1
Definition: pidl.h:102
#define PT_DRIVE2
Definition: pidl.h:89
#define PT_SHARE
Definition: pidl.h:105
#define PT_GUID
Definition: pidl.h:87
static BYTE _ILGetType(LPCITEMIDLIST pidl)
Definition: pidl.h:144
#define PT_COMP
Definition: pidl.h:99
#define PT_NETPROVIDER
Definition: pidl.h:100
static BYTE _ILGetFSType(LPCITEMIDLIST pidl)
Definition: pidl.h:149
#define PT_NETWORK
Definition: pidl.h:101
UINT _ILGetDepth(LPCITEMIDLIST pidl)
static BOOL _ILIsEmpty(LPCITEMIDLIST pidl)
Definition: pidl.h:282
#define PT_CPLAPPLET
Definition: pidl.h:86
#define PT_YAGUID
Definition: pidl.h:103
#define PT_SHELLEXT
Definition: pidl.h:91
#define PT_IESPECIAL2
Definition: pidl.h:104
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
_In_opt_ IUnknown * punk
Definition: shlwapi.h:158
#define ERR_(ch,...)
Definition: debug.h:156
strcpy
Definition: string.h:131
static const char *static const char const char DWORD void DWORD *static const char const char DWORD void DWORD *static const char DWORD DWORD void * buff
Definition: shcore.c:41
BOOL HCR_GetClassNameW(REFIID riid, LPWSTR szDest, DWORD len)
Definition: classes.c:422
static HRESULT SHELL_VariantToBuffer(VARIANT *pVar, void *pData, SIZE_T cb)
Definition: shell32_main.h:310
static __inline BOOL SHELL_OsIsUnicode(void)
Definition: shell32_main.h:196
#define ALIAS_ANY
Definition: shell32_main.h:121
static SIGDN
Definition: shelldispatch.c:49
BOOL WINAPI StrRetToStrNW(LPWSTR dest, DWORD len, LPSTRRET src, const ITEMIDLIST *pidl)
Definition: shellstring.c:85
static PCUIDLIST_RELATIVE HIDA_GetPIDLItem(CIDA const *pida, SIZE_T i)
Definition: shellutils.h:721
static PCUIDLIST_ABSOLUTE HIDA_GetPIDLFolder(CIDA const *pida)
Definition: shellutils.h:716
static IBindCtx void **static IBindCtx void **static void **static IShellFolder IShellItem **static IShellFolder LPCITEMIDLIST IShellItemArray **static PCIDLIST_ABSOLUTE IShellItemArray **static void **static void **static PWSTR *static PWSTR *static DATAOBJ_GET_ITEM_FLAGS
Definition: shlfolder.c:60
#define PID_DESCRIPTIONID
Definition: shlguid.h:175
#define SHGDFIL_FINDDATA
Definition: shlobj.h:1468
#define CSIDL_FLAG_CREATE
Definition: shlobj.h:2253
#define SHGDFIL_NETRESOURCE
Definition: shlobj.h:1469
#define SHGDFIL_DESCRIPTIONID
Definition: shlobj.h:1470
#define CSIDL_CONTROLS
Definition: shlobj.h:2194
static const WCHAR CFSTR_SHELLIDLISTW[]
Definition: shlobj.h:516
_In_ int nFolder
Definition: shlobj.h:1535
SIGDN PWSTR * ppszName
Definition: shobjidl.idl:637
SIGDN sigdnName
Definition: shobjidl.idl:637
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
@ STRRET_WSTR
Definition: shtypes.idl:85
const PCUITEMID_CHILD * PCUITEMID_CHILD_ARRAY
Definition: shtypes.idl:71
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
const SHITEMID * LPCSHITEMID
Definition: shtypes.idl:30
ITEMIDLIST_RELATIVE UNALIGNED * PUIDLIST_RELATIVE
Definition: shtypes.idl:55
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
static PIXELFORMATDESCRIPTOR pfd
Definition: ssstars.c:67
Definition: shlobj.h:582
UINT aoffset[1]
Definition: shlobj.h:583
UINT cidl
Definition: shlobj.h:582
WCHAR wszName[1]
Definition: shlfolder.c:1557
UINT uType
Definition: shtypes.idl:93
FILETIME ftLastWriteTime
Definition: minwinbase.h:286
_Field_z_ WCHAR cAlternateFileName[14]
Definition: minwinbase.h:292
_Field_z_ WCHAR cFileName[MAX_PATH]
Definition: minwinbase.h:291
DWORD dwFileAttributes
Definition: minwinbase.h:283
FILETIME ftLastAccessTime
Definition: minwinbase.h:285
FILETIME ftCreationTime
Definition: minwinbase.h:284
Definition: dsound.c:943
Definition: ffs.h:70
struct tagDriveStruct drive
Definition: pidl.h:234
PIDLTYPE type
Definition: pidl.h:230
struct tagFileStruct file
Definition: pidl.h:235
union tagPIDLDATA::@599 u
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint16_t * PWSTR
Definition: typedefs.h:56
const char * LPCSTR
Definition: typedefs.h:52
const uint16_t * LPCWSTR
Definition: typedefs.h:57
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWSTR
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
char * LPSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
#define ILGDN_NORMAL
Definition: undocshell.h:85
#define ILGDN_INFOLDER
Definition: undocshell.h:86
#define ILGDN_FORPARSING
Definition: undocshell.h:84
HRESULT WINAPI DECLSPEC_HOTPATCH VariantClear(VARIANTARG *pVarg)
Definition: variant.c:626
DWORD dwAttributes
Definition: vdmdbg.h:34
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WINAPI
Definition: msvc.h:6
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define E_NOINTERFACE
Definition: winerror.h:3479
UINT WINAPI RegisterClipboardFormatW(_In_ LPCWSTR)
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815
unsigned char BYTE
Definition: xxhash.c:193