ReactOS 0.4.17-dev-970-gcf0f1a6
utils.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: shell32
3 * LICENSE: LGPL-2.1+ (https://spdx.org/licenses/LGPL-2.1+)
4 * PURPOSE: Utility functions
5 * COPYRIGHT: Copyright 2023-2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "precomp.h"
9#include <lmcons.h>
10#include <lmapibuf.h>
11#include <lmaccess.h>
12#include <lmserver.h>
13#include <secext.h>
14
16
18{
19 PCSTR pch, pchEnd = &psz[cch];
20 for (pch = psz; *pch && pch < pchEnd; pch = CharNextA(pch))
21 ;
22 if (pchEnd < pch) // A double-byte character detected at last?
23 pch -= 2; // The width of a double-byte character is 2
24 return pch;
25}
26
28{
29 PCWSTR pch, pchEnd = &psz[cch];
30 for (pch = psz; *pch && pch < pchEnd; ++pch)
31 ;
32 return pch;
33}
34
35static INT _SHMergePopupMenus(HMENU hMenu, HMENU hPopupMenu, UINT uIDAdjust, UINT uIDAdjustMax)
36{
37 INT maxID = uIDAdjust;
38 const INT itemCount = GetMenuItemCount(hPopupMenu);
39 if (itemCount == -1)
40 return maxID;
41
42 MENUITEMINFOW mii = { sizeof(mii), MIIM_ID | MIIM_SUBMENU };
43 for (INT i = itemCount - 1; i >= 0; --i)
44 {
45 if (!GetMenuItemInfoW(hPopupMenu, i, TRUE, &mii))
46 continue;
47
48 HMENU hTargetSubMenu = SHGetMenuFromID(hMenu, mii.wID);
49 if (!hTargetSubMenu)
50 continue;
51
52 INT currentMax = Shell_MergeMenus(hTargetSubMenu, mii.hSubMenu, 0,
53 uIDAdjust, uIDAdjustMax,
55 maxID = max(maxID, currentMax);
56 }
57
58 return maxID;
59}
60
62{
63 HMENU hMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(uMenuId));
64 if (!hMenu)
65 return NULL;
66 HMENU hSubMenu = GetSubMenu(hMenu, 0);
67 RemoveMenu(hMenu, 0, MF_BYPOSITION);
68 DestroyMenu(hMenu);
69 return hSubMenu;
70}
71
72/*************************************************************************
73 * CDefFolderMenu_MergeMenu [SHELL32.702]
74 */
79 _In_ UINT uMainMerge,
80 _In_ UINT uPopupMerge,
81 _Inout_ LPQCMINFO lpQcmInfo)
82{
83 UINT idCmdFirst = lpQcmInfo->idCmdFirst;
84 HMENU hPopupMenu;
85
86 if (uMainMerge)
87 {
88 hPopupMenu = SHLoadPopupMenu(hInstance, uMainMerge);
89 if (hPopupMenu)
90 {
92 idCmdFirst = Shell_MergeMenus(lpQcmInfo->hmenu,
93 hPopupMenu,
94 lpQcmInfo->indexMenu,
95 lpQcmInfo->idCmdFirst,
96 lpQcmInfo->idCmdLast,
97 uFlags);
98 DestroyMenu(hPopupMenu);
99 }
100 }
101
102 if (uPopupMerge)
103 {
104 hPopupMenu = LoadMenuW(hInstance, MAKEINTRESOURCEW(uPopupMerge));
105 if (hPopupMenu)
106 {
107 UINT id = _SHMergePopupMenus(lpQcmInfo->hmenu, hPopupMenu,
108 lpQcmInfo->idCmdFirst, lpQcmInfo->idCmdLast);
109 idCmdFirst = max(idCmdFirst, id);
110 DestroyMenu(hPopupMenu);
111 }
112 }
113
114 lpQcmInfo->idCmdFirst = idCmdFirst;
115}
116
117/*************************************************************************
118 * StrRStrA [SHELL32.389]
119 */
123 _In_ PCSTR pszSrc,
124 _In_opt_ PCSTR pszLast,
125 _In_ PCSTR pszSearch)
126{
127 INT cchSearch = lstrlenA(pszSearch);
128
129 PCSTR pchEnd = pszLast ? pszLast : &pszSrc[lstrlenA(pszSrc)];
130 if (pchEnd == pszSrc)
131 return NULL;
132
133 INT_PTR cchEnd = pchEnd - pszSrc;
134 for (;;)
135 {
136 --pchEnd;
137 --cchEnd;
138 if (!pchEnd)
139 break;
140 if (!StrCmpNA(pchEnd, pszSearch, cchSearch) && pchEnd == StrEndNA(pszSrc, cchEnd))
141 break;
142 if (pchEnd == pszSrc)
143 return NULL;
144 }
145
146 return const_cast<PSTR>(pchEnd);
147}
148
149/*************************************************************************
150 * StrRStrW [SHELL32.392]
151 */
155 _In_ PCWSTR pszSrc,
156 _In_opt_ PCWSTR pszLast,
157 _In_ PCWSTR pszSearch)
158{
159 INT cchSearch = lstrlenW(pszSearch);
160
161 PCWSTR pchEnd = pszLast ? pszLast : &pszSrc[lstrlenW(pszSrc)];
162 if (pchEnd == pszSrc)
163 return NULL;
164
165 INT_PTR cchEnd = pchEnd - pszSrc;
166 for (;;)
167 {
168 --pchEnd;
169 --cchEnd;
170 if (!pchEnd)
171 break;
172 if (!StrCmpNW(pchEnd, pszSearch, cchSearch) && pchEnd == StrEndNW(pszSrc, cchEnd))
173 break;
174 if (pchEnd == pszSrc)
175 return NULL;
176 }
177
178 return const_cast<PWSTR>(pchEnd);
179}
180
181HWND
183{
184 for (HWND hWnd, hWndAfter = NULL;;)
185 {
186 hWnd = hWndAfter = FindWindowExW(NULL, hWndAfter, CSTUBWINDOW32_CLASSNAME, Path);
187 if (!hWnd || !Path)
188 return NULL;
190 return hWnd;
191 }
192}
193
196{
198 {
201 }
202 RECT rcPosition = { pPt ? pPt->x : CW_USEDEFAULT, pPt ? pPt->y : CW_USEDEFAULT, 0, 0 };
205 if (!Create(NULL, rcPosition, Path, Style, ExStyle))
206 {
207 ERR("StubWindow32 creation failed\n");
208 return E_FAIL;
209 }
211 return S_OK;
212}
213
215{
216 if (pszPath[0] != L'.')
217 return FALSE;
218 return !pszPath[1] || (pszPath[1] == L'.' && !pszPath[2]);
219}
220
221#define PATH_VALID_ELEMENT ( \
222 PATH_CHAR_CLASS_DOT | PATH_CHAR_CLASS_SEMICOLON | PATH_CHAR_CLASS_COMMA | \
223 PATH_CHAR_CLASS_SPACE | PATH_CHAR_CLASS_OTHER_VALID \
224)
225
227{
228 if (!*pszPath || PathIsDotOrDotDotW(pszPath))
229 return FALSE;
230
231 for (LPCWSTR pch = pszPath; *pch; ++pch)
232 {
234 return FALSE;
235 }
236
237 return TRUE;
238}
239
241{
245
246 if (lstrcmpiW(szPath, L"NUL") == 0 || lstrcmpiW(szPath, L"PRN") == 0 ||
247 lstrcmpiW(szPath, L"CON") == 0 || lstrcmpiW(szPath, L"AUX") == 0)
248 {
249 return TRUE;
250 }
251
252 if (_wcsnicmp(szPath, L"LPT", 3) == 0 || _wcsnicmp(szPath, L"COM", 3) == 0)
253 {
254 if ((L'0' <= szPath[3] && szPath[3] <= L'9') && szPath[4] == UNICODE_NULL)
255 return TRUE;
256 }
257
258 return FALSE;
259}
260
262{
263 LPITEMIDLIST pidlOld = *ppidl;
264 if (!pidlOld)
265 {
266 *ppidl = pidl;
267 return S_OK;
268 }
269
270 HRESULT hr = SHILCombine(*ppidl, pidl, ppidl);
271 ILFree(pidlOld);
272 ILFree(pidl);
273 return hr;
274}
275
276/*************************************************************************
277 * SHShouldShowWizards [SHELL32.237]
278 *
279 * Used by printer and network features.
280 * @see https://undoc.airesoft.co.uk/shell32.dll/SHShouldShowWizards.php
281 */
285{
286 HRESULT hr;
287 IShellBrowser *pBrowser;
288
289 hr = IUnknown_QueryService(pUnknown, SID_STopWindow, IID_PPV_ARG(IShellBrowser, &pBrowser));
290 if (FAILED(hr))
291 return hr;
292
295 if (state.fWebView &&
296 !SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
297 L"ShowWizardsTEST", FALSE, FALSE))
298 {
299 hr = S_FALSE;
300 }
301
302 pBrowser->Release();
303 return hr;
304}
305
306static BOOL
310{
311 BOOL ret;
312
313 if (phToken == NULL)
314 {
316 return FALSE;
317 }
318
319 *phToken = NULL;
320
322 if (!ret && GetLastError() == ERROR_NO_TOKEN)
324
325 return ret;
326}
327
329{
331 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam(const_cast<LPWSTR>(pszName), &punk)))
332 return FALSE;
333 return TRUE;
334}
335
337{
338 if (!pbc)
339 return dwDefault;
340
341 BIND_OPTS BindOpts = { sizeof(BindOpts) };
342 HRESULT hr = pbc->GetBindOptions(&BindOpts);
343 if (FAILED(hr))
344 return dwDefault;
345
346 return BindOpts.grfMode;
347}
348
350{
351 if (!pbc)
352 return FALSE;
353
354 BIND_OPTS BindOps = { sizeof(BindOps) };
355 if (SUCCEEDED(pbc->GetBindOptions(&BindOps)) && BindOps.grfFlags == OLECONTF_LINKS)
356 return TRUE;
357
358 return pclsid && SHSkipJunction(pbc, pclsid);
359}
360
362{
365
366 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam((LPWSTR)STR_FILE_SYS_BIND_DATA, &punk)))
367 return S_FALSE;
368
370 return S_FALSE;
371
372 if (pFindData)
373 pBindData->GetFindData(pFindData);
374
375 return S_OK;
376}
377
379{
381
382 switch (code)
383 {
386 case ERROR_CANCELLED:
387 return TRUE;
388
389 default:
391 }
392}
393
396 _In_opt_ IShellFolder *pShellFolder,
398 _In_opt_ IBindCtx *pBindCtx,
400 _Out_ void **ppvObj)
401{
402 CComPtr<IShellFolder> psfDesktop;
403
404 *ppvObj = NULL;
405
406 if (!pShellFolder)
407 {
408 SHGetDesktopFolder(&psfDesktop);
409 if (!psfDesktop)
410 return E_FAIL;
411
412 pShellFolder = psfDesktop;
413 }
414
415 HRESULT hr;
416 if (_ILIsDesktop(pidl))
417 hr = pShellFolder->QueryInterface(riid, ppvObj);
418 else
419 hr = pShellFolder->BindToObject(pidl, pBindCtx, riid, ppvObj);
420
421 if (SUCCEEDED(hr) && !*ppvObj)
422 hr = E_FAIL;
423
424 return hr;
425}
426
431 _In_ REFIID riid, _Out_ void **ppvObj)
432{
433 if (!ppvObj)
434 return E_INVALIDARG;
435 *ppvObj = NULL;
436 IShellFolder *psf;
437 PCUITEMID_CHILD pidlChild;
438 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlChild);
439 if (SUCCEEDED(hr))
440 {
441 hr = psf->GetUIObjectOf(hWnd, 1, &pidlChild, riid, NULL, ppvObj);
442 psf->Release();
443 if (SUCCEEDED(hr))
444 {
445 if (*ppvObj)
446 return hr;
447 hr = E_FAIL;
448 }
449 }
450 return hr;
451}
452
456 _In_ LPCITEMIDLIST pidl,
458 _Out_ PWSTR *ppStr)
459{
460 HRESULT hr;
461 CComPtr<IShellFolder> psfRoot;
462 if (!psf)
463 {
464 PCUITEMID_CHILD pidlChild;
465 hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psfRoot), &pidlChild);
466 if (FAILED(hr))
467 return hr;
468 psf = psfRoot;
469 pidl = pidlChild;
470 }
471 STRRET sr;
472 hr = psf->GetDisplayNameOf((PCUITEMID_CHILD)pidl, Flags, &sr);
473 return SUCCEEDED(hr) ? StrRetToStrW(&sr, pidl, ppStr) : hr;
474}
475
476/***********************************************************************
477 * DisplayNameOfW [SHELL32.757] (Vista+)
478 */
481 _In_ IShellFolder *psf,
482 _In_ LPCITEMIDLIST pidl,
484 _Out_ LPWSTR pszBuf,
486{
487 *pszBuf = UNICODE_NULL;
488 STRRET sr;
489 HRESULT hr = psf->GetDisplayNameOf(pidl, dwFlags, &sr);
490 if (FAILED(hr))
491 return hr;
492 return StrRetToBufW(&sr, pidl, pszBuf, cchBuf);
493}
494
495DWORD
497{
498 LPCITEMIDLIST pidlLast = pidl;
499 IShellFolder *release = NULL;
500
501 if (!psf)
502 {
503 SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlLast);
504 if (!psf)
505 return 0;
506 release = psf;
507 }
508
509 DWORD oldAttrs = dwAttributes;
510 if (FAILED(psf->GetAttributesOf(1, &pidlLast, &dwAttributes)))
511 dwAttributes = 0;
512 else
513 dwAttributes &= oldAttrs;
514
515 if ((dwAttributes & SFGAO_FOLDER) &&
516 (dwAttributes & SFGAO_STREAM) &&
517 !(dwAttributes & SFGAO_STORAGEANCESTOR) &&
518 (oldAttrs & SFGAO_STORAGEANCESTOR) &&
519 (SHGetObjectCompatFlags(psf, NULL) & 0x200))
520 {
521 dwAttributes &= ~(SFGAO_STREAM | SFGAO_STORAGEANCESTOR);
522 dwAttributes |= SFGAO_STORAGEANCESTOR;
523 }
524
525 if (release)
526 release->Release();
527 return dwAttributes;
528}
529
531{
532 IShellLink *pSL;
533 HRESULT hr = SHBindToObject(NULL, pidl, NULL, IID_PPV_ARG(IShellLink, &pSL));
534 if (SUCCEEDED(hr))
535 {
536 hr = pSL->GetIDList(ppidl); // Note: Returns S_FALSE if no target pidl
537 pSL->Release();
538 }
539 return hr;
540}
541
543{
545 if (FAILED(hr))
547 return hr;
548}
549
552 _In_ LPCITEMIDLIST pidl,
554 _Out_opt_ LPWSTR pszText,
556 _Inout_opt_ DWORD *pdwAttributes)
557{
558 if (pszText)
559 *pszText = UNICODE_NULL;
560
562
563 CComPtr<IShellFolder> psfFolder;
564 LPCITEMIDLIST ppidlLast;
565 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psfFolder), &ppidlLast);
566 if (SUCCEEDED(hr))
567 {
568 if (pszText)
569 hr = DisplayNameOfW(psfFolder, ppidlLast, dwFlags, pszText, cchBuf);
570
571 if (SUCCEEDED(hr))
572 {
573 if (pdwAttributes)
574 *pdwAttributes = SHGetAttributes(psfFolder, ppidlLast, *pdwAttributes);
575 }
576 }
577
578 if (SUCCEEDED(hrCoInit))
580
581 return hr;
582}
583
586{
587 HWND hWnd = NULL;
588
590 if (pBindCtx && SUCCEEDED(pBindCtx->GetObjectParam((LPWSTR)L"UI During Binding", &punk)))
592
593 return hWnd;
594}
595
597{
598protected:
601
602public:
604 virtual ~CDummyOleWindow() { }
605
606 // IUnknown methods
608 {
609 static const QITAB c_tab[] =
610 {
612 { NULL }
613 };
614 return ::QISearch(this, c_tab, riid, ppvObj);
615 }
617 {
618 return ++m_cRefs;
619 }
621 {
622 if (--m_cRefs == 0)
623 {
624 delete this;
625 return 0;
626 }
627 return m_cRefs;
628 }
629
630 // IOleWindow methods
631 STDMETHODIMP GetWindow(HWND *phWnd) override
632 {
633 *phWnd = m_hWnd;
634 if (!m_hWnd)
635 return E_NOTIMPL;
636 return S_OK;
637 }
639 {
640 return E_NOTIMPL;
641 }
642};
643
646 _In_ IBindCtx *pBindCtx,
647 _In_ LPOLESTR pszKey,
649 _Out_ LPBC *ppbc)
650{
651 HRESULT hr = S_OK;
653
654 *ppbc = pBindCtx;
655
656 if (pBindCtx)
657 {
658 pBindCtx->AddRef();
659 }
660 else
661 {
662 hr = CreateBindCtx(0, ppbc);
663 if (FAILED(hr))
664 return hr;
665 }
666
667 if (!punk)
668 punk = pUnknown = new CDummyOleWindow();
669
670 hr = (*ppbc)->RegisterObjectParam(pszKey, punk);
671
672 if (pUnknown)
673 pUnknown->Release();
674
675 if (FAILED(hr))
676 {
677 (*ppbc)->Release();
678 *ppbc = NULL;
679 }
680
681 return hr;
682}
683
684/*************************************************************************
685 * SHSetFolderPathA (SHELL32.231)
686 *
687 * @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shsetfolderpatha
688 */
692 _In_ INT csidl,
693 _In_ HANDLE hToken,
695 _In_ LPCSTR pszPath)
696{
697 TRACE("(%d, %p, 0x%X, %s)\n", csidl, hToken, dwFlags, debugstr_a(pszPath));
698 CStringW strPathW(pszPath);
699 return SHSetFolderPathW(csidl, hToken, dwFlags, strPathW);
700}
701
702/*************************************************************************
703 * PathIsSlowW (SHELL32.239)
704 *
705 * @param[in] pszFile
706 * Path to check for slowness.
707 *
708 * @param[in] dwAttr
709 * File attributes of pszFile or INVALID_FILE_ATTRIBUTES to get them.
710 *
711 * @return
712 * TRUE if the path is considered slow, FALSE if not.
713 *
714 * @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj/nf-shlobj-pathissloww
715 **/
717WINAPI
719 _In_ LPCWSTR pszFile,
720 _In_ DWORD dwAttr)
721{
722 TRACE("PathIsSlowW(%s, %lx)\n", debugstr_w(pszFile), dwAttr);
723
724 /* If we didn't get attributes, get them */
725 if (dwAttr == INVALID_FILE_ATTRIBUTES)
726 dwAttr = GetFileAttributesW(pszFile);
727
728 /* Offline files are always considered slow */
729 if (dwAttr != INVALID_FILE_ATTRIBUTES &&
730 (dwAttr & FILE_ATTRIBUTE_OFFLINE))
731 {
732 return TRUE;
733 }
734
735 /* Only network paths can be slow bandwidth-wise */
736 if (!PathIsNetworkPathW(pszFile))
737 return FALSE;
738
739 /* Query connection speed with MPR */
740 NETRESOURCEW nr = {0};
741 NETCONNECTINFOSTRUCT nci = { sizeof(nci) };
742
743 WCHAR szRoot[MAX_PATH];
744 if (FAILED(StringCchCopyW(szRoot, _countof(szRoot), pszFile)))
745 return FALSE;
746 PathStripToRootW(szRoot);
747
748 nr.lpRemoteName = szRoot;
749 nr.dwType = RESOURCETYPE_DISK;
750
752 {
753 if (nci.dwSpeed <= 400)
754 return TRUE;
755 }
756
757 return FALSE;
758}
759
760/*************************************************************************
761 * PathIsSlowA (SHELL32.240)
762 *
763 * @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj/nf-shlobj-pathisslowa
764 */
768 _In_ LPCSTR pszFile,
769 _In_ DWORD dwAttr)
770{
771 TRACE("(%s, 0x%X)\n", debugstr_a(pszFile), dwAttr);
772 CStringW strFileW(pszFile);
773 return PathIsSlowW(strFileW, dwAttr);
774}
775
776/*************************************************************************
777 * ExtractIconResInfoA (SHELL32.221)
778 */
782 _In_ HANDLE hHandle,
784 _In_ WORD wIndex,
785 _Out_ LPWORD lpSize,
786 _Out_ LPHANDLE lpIcon)
787{
788 TRACE("(%p, %s, %u, %p, %p)\n", hHandle, debugstr_a(lpFileName), wIndex, lpSize, lpIcon);
789
790 if (!lpFileName)
791 return 0;
792
793 CStringW strFileNameW(lpFileName);
794 return ExtractIconResInfoW(hHandle, strFileNameW, wIndex, lpSize, lpIcon);
795}
796
797/*************************************************************************
798 * ShortSizeFormatW (SHELL32.204)
799 */
803 _In_ DWORD dwNumber,
804 _Out_writes_(0x8FFF) LPWSTR pszBuffer)
805{
806 TRACE("(%lu, %p)\n", dwNumber, pszBuffer);
807 return StrFormatByteSizeW(dwNumber, pszBuffer, 0x8FFF);
808}
809
810/*************************************************************************
811 * SHOpenEffectiveToken (SHELL32.235)
812 */
814{
815 TRACE("%p\n", phToken);
817}
818
819/*************************************************************************
820 * SHGetUserSessionId (SHELL32.248)
821 */
823{
824 DWORD dwSessionId, dwLength;
825 BOOL bOpenToken = FALSE;
826
827 TRACE("%p\n", hToken);
828
829 if (!hToken)
830 bOpenToken = SHOpenEffectiveToken(&hToken);
831
832 if (!hToken ||
833 !GetTokenInformation(hToken, TokenSessionId, &dwSessionId, sizeof(dwSessionId), &dwLength))
834 {
835 dwSessionId = 0;
836 }
837
838 if (bOpenToken)
839 CloseHandle(hToken);
840
841 return dwSessionId;
842}
843
844/*************************************************************************
845 * SHInvokePrivilegedFunctionW (SHELL32.246)
846 */
850 _In_ LPCWSTR pszName,
853{
854 TRACE("(%s %p %p)\n", debugstr_w(pszName), fn, lParam);
855
856 if (!pszName || !fn)
857 return E_INVALIDARG;
858
859 HANDLE hToken = NULL;
860 TOKEN_PRIVILEGES NewPriv, PrevPriv;
861 BOOL bAdjusted = FALSE;
862
863 if (SHOpenEffectiveToken(&hToken) &&
864 ::LookupPrivilegeValueW(NULL, pszName, &NewPriv.Privileges[0].Luid))
865 {
866 NewPriv.PrivilegeCount = 1;
868
869 DWORD dwReturnSize;
870 bAdjusted = ::AdjustTokenPrivileges(hToken, FALSE, &NewPriv,
871 sizeof(PrevPriv), &PrevPriv, &dwReturnSize);
872 }
873
874 HRESULT hr = fn(lParam);
875
876 if (bAdjusted)
877 ::AdjustTokenPrivileges(hToken, FALSE, &PrevPriv, 0, NULL, NULL);
878
879 if (hToken)
880 ::CloseHandle(hToken);
881
882 return hr;
883}
884
885/*************************************************************************
886 * SHTestTokenPrivilegeW (SHELL32.236)
887 *
888 * @see http://undoc.airesoft.co.uk/shell32.dll/SHTestTokenPrivilegeW.php
889 */
893 _In_opt_ HANDLE hToken,
895{
896 LUID Luid;
898 PTOKEN_PRIVILEGES pTokenPriv;
899 HANDLE hNewToken = NULL;
900 BOOL ret = FALSE;
901
902 TRACE("(%p, %s)\n", hToken, debugstr_w(lpName));
903
904 if (!lpName)
905 return FALSE;
906
907 if (!hToken)
908 {
909 if (!SHOpenEffectiveToken(&hNewToken))
910 goto Quit;
911
912 if (!hNewToken)
913 return FALSE;
914
915 hToken = hNewToken;
916 }
917
918 if (!LookupPrivilegeValueW(NULL, lpName, &Luid))
919 return FALSE;
920
921 dwLength = 0;
923 goto Quit;
924
926 if (!pTokenPriv)
927 goto Quit;
928
929 if (GetTokenInformation(hToken, TokenPrivileges, pTokenPriv, dwLength, &dwLength))
930 {
931 UINT iPriv, cPrivs;
932 cPrivs = pTokenPriv->PrivilegeCount;
933 for (iPriv = 0; !ret && iPriv < cPrivs; ++iPriv)
934 {
935 ret = RtlEqualLuid(&Luid, &pTokenPriv->Privileges[iPriv].Luid);
936 }
937 }
938
939 LocalFree(pTokenPriv);
940
941Quit:
942 if (hToken == hNewToken)
943 CloseHandle(hNewToken);
944
945 return ret;
946}
947
949{
951}
952
953/*************************************************************************
954 * IsSuspendAllowed (SHELL32.53)
955 */
957{
958 TRACE("()\n");
960}
961
962/*************************************************************************
963 * SHGetShellStyleHInstance (SHELL32.749)
964 */
966WINAPI
968{
971 HRESULT hr;
972 CStringW strShellStyle;
973
974 TRACE("SHGetShellStyleHInstance called\n");
975
976 /* First, attempt to load the shellstyle dll from the current active theme */
978 if (FAILED(hr))
979 goto DoDefault;
980
981 /* Strip the theme filename */
983
984 strShellStyle = szPath;
985 strShellStyle += L"\\Shell\\";
986 strShellStyle += szColorName;
987 strShellStyle += L"\\ShellStyle.dll";
988
990 if (hInst)
991 return hInst;
992
993 /* Otherwise, use the version stored in the System32 directory */
994DoDefault:
995 if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\System32\\ShellStyle.dll",
997 {
998 ERR("Expand failed\n");
999 return NULL;
1000 }
1002}
1003
1004/*************************************************************************
1005 * SHCreatePropertyBag (SHELL32.715)
1006 */
1008WINAPI
1010{
1012}
1013
1014// The helper function for SHGetUnreadMailCountW
1015static DWORD
1017 _In_ HKEY hKey,
1018 _Out_opt_ PDWORD pdwCount,
1019 _Out_opt_ PFILETIME pFileTime,
1020 _Out_writes_opt_(cchShellExecuteCommand) LPWSTR pszShellExecuteCommand,
1021 _In_ INT cchShellExecuteCommand)
1022{
1023 DWORD dwType, dwCount, cbSize = sizeof(dwCount);
1024 DWORD error = SHQueryValueExW(hKey, L"MessageCount", 0, &dwType, &dwCount, &cbSize);
1025 if (error)
1026 return error;
1027 if (pdwCount && dwType == REG_DWORD)
1028 *pdwCount = dwCount;
1029
1030 FILETIME FileTime;
1031 cbSize = sizeof(FileTime);
1032 error = SHQueryValueExW(hKey, L"TimeStamp", 0, &dwType, &FileTime, &cbSize);
1033 if (error)
1034 return error;
1035 if (pFileTime && dwType == REG_BINARY)
1036 *pFileTime = FileTime;
1037
1038 WCHAR szName[2 * MAX_PATH];
1039 cbSize = sizeof(szName);
1040 error = SHQueryValueExW(hKey, L"Application", 0, &dwType, szName, &cbSize);
1041 if (error)
1042 return error;
1043
1044 if (pszShellExecuteCommand && dwType == REG_SZ &&
1045 FAILED(StringCchCopyW(pszShellExecuteCommand, cchShellExecuteCommand, szName)))
1046 {
1048 }
1049
1050 return ERROR_SUCCESS;
1051}
1052
1053/*************************************************************************
1054 * SHGetUnreadMailCountW [SHELL32.320]
1055 *
1056 * @see https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shgetunreadmailcountw
1057 */
1061 _In_opt_ HKEY hKeyUser,
1062 _In_opt_ PCWSTR pszMailAddress,
1063 _Out_opt_ PDWORD pdwCount,
1064 _Inout_opt_ PFILETIME pFileTime,
1065 _Out_writes_opt_(cchShellExecuteCommand) PWSTR pszShellExecuteCommand,
1066 _In_ INT cchShellExecuteCommand)
1067{
1068 LSTATUS error;
1069 HKEY hKey;
1070
1071 if (!hKeyUser)
1072 hKeyUser = HKEY_CURRENT_USER;
1073
1074 if (pszMailAddress)
1075 {
1076 CStringW strKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail";
1077 strKey += L'\\';
1078 strKey += pszMailAddress;
1079
1080 error = RegOpenKeyExW(hKeyUser, strKey, 0, KEY_QUERY_VALUE, &hKey);
1081 if (error)
1082 return HRESULT_FROM_WIN32(error);
1083
1084 error = SHELL_ReadSingleUnreadMailCount(hKey, pdwCount, pFileTime,
1085 pszShellExecuteCommand, cchShellExecuteCommand);
1086 }
1087 else
1088 {
1089 if (pszShellExecuteCommand || cchShellExecuteCommand)
1090 return E_INVALIDARG;
1091
1092 *pdwCount = 0;
1093
1094 error = RegOpenKeyExW(hKeyUser, L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail",
1096 if (error)
1097 return HRESULT_FROM_WIN32(error);
1098
1099 for (DWORD dwIndex = 0; !error; ++dwIndex)
1100 {
1101 WCHAR Name[2 * MAX_PATH];
1103 FILETIME LastWritten;
1104 error = RegEnumKeyExW(hKey, dwIndex, Name, &cchName, NULL, NULL, NULL, &LastWritten);
1105 if (error)
1106 break;
1107
1108 HKEY hSubKey;
1109 error = RegOpenKeyExW(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey);
1110 if (error)
1111 break;
1112
1113 FILETIME FileTime;
1114 DWORD dwCount;
1115 error = SHELL_ReadSingleUnreadMailCount(hSubKey, &dwCount, &FileTime, NULL, 0);
1116 if (!error && (!pFileTime || CompareFileTime(&FileTime, pFileTime) >= 0))
1117 *pdwCount += dwCount;
1118
1119 RegCloseKey(hSubKey);
1120 }
1121
1124 }
1125
1127
1128 return error ? HRESULT_FROM_WIN32(error) : S_OK;
1129}
1130
1131/*************************************************************************
1132 * SHSetUnreadMailCountW [SHELL32.336]
1133 *
1134 * @see https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shsetunreadmailcountw
1135 */
1139 _In_ PCWSTR pszMailAddress,
1140 _In_ DWORD dwCount,
1141 _In_ PCWSTR pszShellExecuteCommand)
1142{
1143 CString strKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\";
1144 strKey += pszMailAddress;
1145
1146 HKEY hKey;
1147 DWORD dwDisposition;
1149 &hKey, &dwDisposition);
1150 if (error)
1151 return HRESULT_FROM_WIN32(error);
1152
1153 error = RegSetValueExW(hKey, L"MessageCount", 0, REG_DWORD, (PBYTE)&dwCount, sizeof(dwCount));
1154 if (error)
1155 {
1157 return HRESULT_FROM_WIN32(error);
1158 }
1159
1160 FILETIME FileTime;
1161 GetSystemTimeAsFileTime(&FileTime);
1162
1163 error = RegSetValueExW(hKey, L"TimeStamp", 0, REG_BINARY, (PBYTE)&FileTime, sizeof(FileTime));
1164 if (error)
1165 {
1167 return HRESULT_FROM_WIN32(error);
1168 }
1169
1170 WCHAR szBuff[2 * MAX_PATH];
1171 if (!PathUnExpandEnvStringsW(pszShellExecuteCommand, szBuff, _countof(szBuff)))
1172 {
1173 HRESULT hr = StringCchCopyW(szBuff, _countof(szBuff), pszShellExecuteCommand);
1175 {
1177 return hr;
1178 }
1179 }
1180
1181 DWORD cbValue = (lstrlenW(szBuff) + 1) * sizeof(WCHAR);
1182 error = RegSetValueExW(hKey, L"Application", 0, REG_SZ, (PBYTE)szBuff, cbValue);
1183
1185 return (error ? HRESULT_FROM_WIN32(error) : S_OK);
1186}
1187
1188/*************************************************************************
1189 * SheRemoveQuotesA (SHELL32.@)
1190 */
1192WINAPI
1194{
1195 PCHAR pch;
1196
1197 if (*psz == '"')
1198 {
1199 for (pch = psz + 1; *pch && *pch != '"'; ++pch)
1200 {
1201 *(pch - 1) = *pch;
1202 }
1203
1204 if (*pch == '"')
1205 *(pch - 1) = ANSI_NULL;
1206 }
1207
1208 return psz;
1209}
1210
1211/*************************************************************************
1212 * SheRemoveQuotesW (SHELL32.@)
1213 *
1214 * ExtractAssociatedIconExW uses this function.
1215 */
1217WINAPI
1219{
1220 PWCHAR pch;
1221
1222 if (*psz == L'"')
1223 {
1224 for (pch = psz + 1; *pch && *pch != L'"'; ++pch)
1225 {
1226 *(pch - 1) = *pch;
1227 }
1228
1229 if (*pch == L'"')
1230 *(pch - 1) = UNICODE_NULL;
1231 }
1232
1233 return psz;
1234}
1235
1236/*************************************************************************
1237 * SHEnumerateUnreadMailAccountsW [SHELL32.287]
1238 *
1239 * @see https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shenumerateunreadmailaccountsw
1240 */
1244 _In_opt_ HKEY hKeyUser,
1245 _In_ DWORD dwIndex,
1246 _Out_writes_(cchMailAddress) PWSTR pszMailAddress,
1247 _In_ INT cchMailAddress)
1248{
1249 if (!hKeyUser)
1250 hKeyUser = HKEY_CURRENT_USER;
1251
1252 HKEY hKey;
1253 LSTATUS error = RegOpenKeyExW(hKeyUser,
1254 L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail",
1256 if (error)
1257 return HRESULT_FROM_WIN32(error);
1258
1259 FILETIME FileTime;
1260 error = RegEnumKeyExW(hKey, dwIndex, pszMailAddress, (PDWORD)&cchMailAddress, NULL, NULL,
1261 NULL, &FileTime);
1262 if (error)
1263 *pszMailAddress = UNICODE_NULL;
1264
1266 return error ? HRESULT_FROM_WIN32(error) : S_OK;
1267}
1268
1269/*************************************************************************
1270 * SHFindComputer [SHELL32.91]
1271 *
1272 * Invokes the shell search in My Computer. Used in SHFindFiles.
1273 * Two parameters are ignored.
1274 */
1276WINAPI
1278{
1279 UNREFERENCED_PARAMETER(pidlRoot);
1280 UNREFERENCED_PARAMETER(pidlSavedSearch);
1281
1282 TRACE("%p %p\n", pidlRoot, pidlSavedSearch);
1283
1284 IContextMenu *pCM;
1285 HRESULT hr = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
1286 IID_IContextMenu, (void **)&pCM);
1287 if (FAILED(hr))
1288 {
1289 ERR("0x%08X\n", hr);
1290 return hr;
1291 }
1292
1293 CMINVOKECOMMANDINFO InvokeInfo = { sizeof(InvokeInfo) };
1294 InvokeInfo.lpParameters = "{996E1EB1-B524-11D1-9120-00A0C98BA67D}";
1295 InvokeInfo.nShow = SW_SHOWNORMAL;
1296 hr = pCM->InvokeCommand(&InvokeInfo);
1297 pCM->Release();
1298
1299 return SUCCEEDED(hr);
1300}
1301
1302static HRESULT
1304 _In_ LONGLONG llValue,
1305 _Out_writes_(cchValue) LPWSTR pszValue,
1306 _In_ UINT cchValue)
1307{
1308 WCHAR szBuff[40];
1309 UINT ich = 0, ichValue;
1310#if (WINVER >= _WIN32_WINNT_VISTA)
1311 BOOL bMinus = (llValue < 0);
1312
1313 if (bMinus)
1314 llValue = -llValue;
1315#endif
1316
1317 if (cchValue <= 0)
1318 return E_FAIL;
1319
1320 do
1321 {
1322 szBuff[ich++] = (WCHAR)(L'0' + (llValue % 10));
1323 llValue /= 10;
1324 } while (llValue != 0 && ich < _countof(szBuff) - 1);
1325
1326#if (WINVER >= _WIN32_WINNT_VISTA)
1327 if (bMinus && ich < _countof(szBuff))
1328 szBuff[ich++] = '-';
1329#endif
1330
1331 for (ichValue = 0; ich > 0 && ichValue < cchValue; ++ichValue)
1332 {
1333 --ich;
1334 pszValue[ichValue] = szBuff[ich];
1335 }
1336
1337 if (ichValue >= cchValue)
1338 {
1339 pszValue[cchValue - 1] = UNICODE_NULL;
1340 return E_FAIL;
1341 }
1342
1343 pszValue[ichValue] = UNICODE_NULL;
1344 return S_OK;
1345}
1346
1347static VOID
1349 _Out_ NUMBERFMTW *pDest,
1350 _In_opt_ const NUMBERFMTW *pSrc,
1351 _In_ DWORD dwNumberFlags,
1352 _Out_writes_(cchDecimal) LPWSTR pszDecimal,
1353 _In_ INT cchDecimal,
1354 _Out_writes_(cchThousand) LPWSTR pszThousand,
1355 _In_ INT cchThousand)
1356{
1357 WCHAR szBuff[20];
1358
1359 if (pSrc)
1360 *pDest = *pSrc;
1361 else
1362 dwNumberFlags = 0;
1363
1364 if (!(dwNumberFlags & FMT_USE_NUMDIGITS))
1365 {
1367 pDest->NumDigits = StrToIntW(szBuff);
1368 }
1369
1370 if (!(dwNumberFlags & FMT_USE_LEADZERO))
1371 {
1373 pDest->LeadingZero = StrToIntW(szBuff);
1374 }
1375
1376 if (!(dwNumberFlags & FMT_USE_GROUPING))
1377 {
1379 pDest->Grouping = StrToIntW(szBuff);
1380 }
1381
1382 if (!(dwNumberFlags & FMT_USE_DECIMAL))
1383 {
1384 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, pszDecimal, cchDecimal);
1385 pDest->lpDecimalSep = pszDecimal;
1386 }
1387
1388 if (!(dwNumberFlags & FMT_USE_THOUSAND))
1389 {
1390 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, pszThousand, cchThousand);
1391 pDest->lpThousandSep = pszThousand;
1392 }
1393
1394 if (!(dwNumberFlags & FMT_USE_NEGNUMBER))
1395 {
1397 pDest->NegativeOrder = StrToIntW(szBuff);
1398 }
1399}
1400
1401/*************************************************************************
1402 * Int64ToString [SHELL32.209]
1403 *
1404 * @see http://undoc.airesoft.co.uk/shell32.dll/Int64ToString.php
1405 */
1407INT WINAPI
1409 _In_ LONGLONG llValue,
1410 _Out_writes_(cchOut) LPWSTR pszOut,
1411 _In_ UINT cchOut,
1412 _In_ BOOL bUseFormat,
1413 _In_opt_ const NUMBERFMTW *pNumberFormat,
1414 _In_ DWORD dwNumberFlags)
1415{
1416 INT ret;
1417 NUMBERFMTW NumFormat;
1418 WCHAR szValue[80], szDecimalSep[6], szThousandSep[6];
1419
1420 Int64ToStr(llValue, szValue, _countof(szValue));
1421
1422 if (bUseFormat)
1423 {
1424 Int64GetNumFormat(&NumFormat, pNumberFormat, dwNumberFlags,
1425 szDecimalSep, _countof(szDecimalSep),
1426 szThousandSep, _countof(szThousandSep));
1427 ret = GetNumberFormatW(LOCALE_USER_DEFAULT, 0, szValue, &NumFormat, pszOut, cchOut);
1428 if (ret)
1429 --ret;
1430 return ret;
1431 }
1432
1433 if (FAILED(StringCchCopyW(pszOut, cchOut, szValue)))
1434 return 0;
1435
1436 return lstrlenW(pszOut);
1437}
1438
1439/*************************************************************************
1440 * LargeIntegerToString [SHELL32.210]
1441 *
1442 * @see http://undoc.airesoft.co.uk/shell32.dll/LargeIntegerToString.php
1443 */
1445INT WINAPI
1447 _In_ const LARGE_INTEGER *pLargeInt,
1448 _Out_writes_(cchOut) LPWSTR pszOut,
1449 _In_ UINT cchOut,
1450 _In_ BOOL bUseFormat,
1451 _In_opt_ const NUMBERFMTW *pNumberFormat,
1452 _In_ DWORD dwNumberFlags)
1453{
1454 return Int64ToString(pLargeInt->QuadPart, pszOut, cchOut, bUseFormat,
1455 pNumberFormat, dwNumberFlags);
1456}
1457
1458/*************************************************************************
1459 * CopyStreamUI [SHELL32.726]
1460 *
1461 * Copy a stream to another stream with optional progress display.
1462 */
1466 _In_ IStream *pSrc,
1467 _Out_ IStream *pDst,
1468 _Inout_opt_ IProgressDialog *pProgress,
1469 _In_opt_ DWORDLONG dwlSize)
1470{
1471 HRESULT hr = E_FAIL;
1472 DWORD cbBuff, cbRead, dwSizeToWrite;
1473 DWORDLONG cbDone;
1474 LPVOID pBuff;
1475 CComHeapPtr<BYTE> pHeapPtr;
1476 STATSTG Stat;
1477 BYTE abBuff[1024];
1478
1479 TRACE("(%p, %p, %p, %I64u)\n", pSrc, pDst, pProgress, dwlSize);
1480
1481 if (dwlSize == 0) // Invalid size?
1482 {
1483 // Get the stream size
1484 ZeroMemory(&Stat, sizeof(Stat));
1485 if (FAILED(pSrc->Stat(&Stat, STATFLAG_NONAME)))
1486 pProgress = NULL; // No size info. Disable progress
1487 else
1488 dwlSize = Stat.cbSize.QuadPart;
1489 }
1490
1491 if (!pProgress) // Progress is disabled?
1492 {
1493 ULARGE_INTEGER uliSize;
1494
1495 if (dwlSize > 0)
1496 uliSize.QuadPart = dwlSize;
1497 else
1498 uliSize.HighPart = uliSize.LowPart = INVALID_FILE_SIZE;
1499
1500 return pSrc->CopyTo(pDst, uliSize, NULL, NULL); // One punch
1501 }
1502
1503 // Allocate the buffer if necessary
1504 if (dwlSize > 0 && dwlSize <= sizeof(abBuff))
1505 {
1506 cbBuff = sizeof(abBuff);
1507 pBuff = abBuff;
1508 }
1509 else
1510 {
1511#define COPY_STREAM_DEFAULT_BUFFER_SIZE 0x4000
1513 if (pHeapPtr.AllocateBytes(cbBuff))
1514 {
1515 pBuff = pHeapPtr;
1516 }
1517 else // Low memory?
1518 {
1519 cbBuff = sizeof(abBuff);
1520 pBuff = abBuff;
1521 }
1522#undef COPY_STREAM_DEFAULT_BUFFER_SIZE
1523 }
1524
1525 // Start reading
1527 zero.QuadPart = 0;
1528 pSrc->Seek(zero, 0, NULL);
1529 pDst->Seek(zero, 0, NULL);
1530 cbDone = 0;
1531 pProgress->SetProgress64(cbDone, dwlSize);
1532
1533 // Repeat reading and writing until goal
1534 for (;;)
1535 {
1536 hr = pSrc->Read(pBuff, cbBuff, &cbRead);
1537 if (FAILED(hr))
1538 break;
1539
1540 // Calculate the size to write
1541 if (dwlSize > 0)
1542 dwSizeToWrite = (DWORD)min((DWORDLONG)(dwlSize - cbDone), (DWORDLONG)cbRead);
1543 else
1544 dwSizeToWrite = cbRead;
1545
1546 if (dwSizeToWrite == 0) // No need to write?
1547 {
1548 hr = S_OK;
1549 break;
1550 }
1551
1552 hr = pDst->Write(pBuff, dwSizeToWrite, NULL);
1553 if (hr != S_OK)
1554 break;
1555
1556 cbDone += dwSizeToWrite;
1557
1558 if (pProgress->HasUserCancelled()) // Cancelled?
1559 {
1561 break;
1562 }
1563 pProgress->SetProgress64(cbDone, dwlSize);
1564
1565 if (dwlSize > 0 && cbDone >= dwlSize) // Reached the goal?
1566 {
1567 hr = S_OK;
1568 break;
1569 }
1570 }
1571
1572 return hr;
1573}
1574
1575/*************************************************************************
1576 * Activate_RunDLL [SHELL32.105]
1577 *
1578 * Unlocks the foreground window and allows the shell window to become the
1579 * foreground window. Every parameter is unused.
1580 */
1584 _In_ HWND hwnd,
1587 _In_ INT cmdshow)
1588{
1589 DWORD dwProcessID;
1590
1594 UNREFERENCED_PARAMETER(cmdshow);
1595
1596 TRACE("(%p, %p, %s, %d)\n", hwnd, hinst, debugstr_w(cmdline), cmdline);
1597
1599 return AllowSetForegroundWindow(dwProcessID);
1600}
1601
1602/*************************************************************************
1603 * SHStartNetConnectionDialogA (SHELL32.12)
1604 *
1605 * @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shstartnetconnectiondialoga
1606 */
1610 _In_ HWND hwnd,
1611 _In_ LPCSTR pszRemoteName,
1612 _In_ DWORD dwType)
1613{
1614 LPCWSTR pszRemoteNameW = NULL;
1615 CStringW strRemoteNameW;
1616
1617 TRACE("(%p, %s, %lu)\n", hwnd, debugstr_a(pszRemoteName), dwType);
1618
1619 if (pszRemoteName)
1620 {
1621 strRemoteNameW = pszRemoteName;
1622 pszRemoteNameW = strRemoteNameW;
1623 }
1624
1625 return SHStartNetConnectionDialogW(hwnd, pszRemoteNameW, dwType);
1626}
1627
1628/*************************************************************************
1629 * Helper functions for PathIsEqualOrSubFolder
1630 */
1631
1632static INT
1634 _In_ LPCWSTR lpszPath1,
1635 _In_ LPCWSTR lpszPath2,
1636 _Out_ CStringW& strPath)
1637{
1638 SIZE_T cchPath1 = wcslen(lpszPath1);
1639 SIZE_T cchPath2 = wcslen(lpszPath2);
1640 LPWSTR lpszPath = strPath.GetBuffer((INT)max(cchPath1, cchPath2) + 16);
1641 INT ret = PathCommonPrefixW(lpszPath1, lpszPath2, lpszPath);
1642 strPath.ReleaseBuffer();
1643 return ret;
1644}
1645
1648
1649static HRESULT
1651 _In_ LPCITEMIDLIST pidl,
1652 _Out_ CStringW& strPath)
1653{
1654 HRESULT hr;
1655
1656 for (UINT cchPath = MAX_PATH;; cchPath *= 2)
1657 {
1658 LPWSTR lpszPath = strPath.GetBuffer(cchPath);
1659 if (!lpszPath)
1660 return E_OUTOFMEMORY;
1661
1662 hr = SHGetPathCchFromIDListW(pidl, lpszPath, cchPath);
1663 strPath.ReleaseBuffer();
1664
1666 break;
1667
1668 if (cchPath >= MAXUINT / 2)
1669 {
1670 hr = E_FAIL;
1671 break;
1672 }
1673 }
1674
1675 if (FAILED(hr))
1676 strPath.Empty();
1677
1678 return hr;
1679}
1680
1681static HRESULT
1683 _In_ HWND hwndOwner,
1684 _Out_ CStringW& strPath,
1685 _In_ INT nCSIDL,
1687{
1688 LPITEMIDLIST pidl;
1689 HRESULT hr = SHGetSpecialFolderLocation(hwndOwner, nCSIDL, &pidl);
1690 if (SUCCEEDED(hr))
1691 {
1692 hr = DynamicSHGetPathFromIDListW(pidl, strPath);
1693 CoTaskMemFree(pidl);
1694 }
1695
1696 if (FAILED(hr))
1697 strPath.Empty();
1698 else if (bCreate)
1699 CreateDirectoryW(strPath, NULL);
1700
1701 return hr;
1702}
1703
1704static VOID
1706 _Out_ CStringW& strPath)
1707{
1708 INT nLength = strPath.GetLength();
1709 if (nLength > 0 && strPath[nLength - 1] == L'\\')
1710 strPath = strPath.Left(nLength - 1);
1711}
1712
1713/*************************************************************************
1714 * PathIsEqualOrSubFolder (SHELL32.755)
1715 */
1719 _In_ LPCWSTR pszPath1OrCSIDL,
1720 _In_ LPCWSTR pszPath2)
1721{
1722 CStringW strCommon, strPath1;
1723
1724 TRACE("(%s %s)\n", debugstr_w(pszPath1OrCSIDL), debugstr_w(pszPath2));
1725
1726 if (IS_INTRESOURCE(pszPath1OrCSIDL))
1727 {
1729 NULL, strPath1, LOWORD(pszPath1OrCSIDL) | CSIDL_FLAG_DONT_VERIFY, FALSE);
1730 }
1731 else
1732 {
1733 strPath1 = pszPath1OrCSIDL;
1734 }
1735
1737
1738 if (!DynamicPathCommonPrefixW(strPath1, pszPath2, strCommon))
1739 return FALSE;
1740
1741 return strPath1.CompareNoCase(strCommon) == 0;
1742}
1743
1744/*************************************************************************
1745 * SHGetRealIDL [SHELL32.98]
1746 */
1750 _In_ IShellFolder *psf,
1751 _In_ PCUITEMID_CHILD pidlSimple,
1752 _Outptr_ PITEMID_CHILD *ppidlReal)
1753{
1754 HRESULT hr;
1755 STRRET strret;
1757 SFGAOF attrs;
1758
1759 *ppidlReal = NULL;
1760
1761 hr = IShellFolder_GetDisplayNameOf(psf, pidlSimple, SHGDN_INFOLDER | SHGDN_FORPARSING,
1762 &strret, 0);
1764 return hr;
1765
1766 hr = StrRetToBufW(&strret, pidlSimple, szPath, _countof(szPath));
1768 return hr;
1769
1770 attrs = SFGAO_FILESYSTEM;
1771 hr = psf->GetAttributesOf(1, &pidlSimple, &attrs);
1772 if (SUCCEEDED(hr) && !(attrs & SFGAO_FILESYSTEM))
1773 return SHILClone(pidlSimple, ppidlReal);
1774
1775 hr = IShellFolder_ParseDisplayName(psf, NULL, NULL, szPath, NULL, ppidlReal, NULL);
1776 if (hr == E_INVALIDARG || hr == E_NOTIMPL)
1777 return SHILClone(pidlSimple, ppidlReal);
1778
1779 return hr;
1780}
1781
1785 _In_ PCWSTR pszCommandName,
1787{
1788 HRESULT hr;
1790 if (SUCCEEDED(hr = pUnk->QueryInterface(IID_PPV_ARG(IInitializeCommand, &pIC))))
1791 hr = pIC->Initialize(pszCommandName, pPB);
1792 return hr;
1793}
1794
1797 _In_ IExecuteCommand *pEC,
1798 _In_ PCWSTR pszCommandName,
1800 _In_opt_ IShellItemArray *pSIA,
1801 _In_opt_ LPCMINVOKECOMMANDINFOEX pICI,
1802 _In_opt_ IUnknown *pSite)
1803{
1804 if (!pEC)
1805 return E_INVALIDARG;
1806
1807 CScopedSetObjectWithSite site(pEC, pSite);
1808 IUnknown_InitializeCommand(pEC, pszCommandName, pPB);
1809
1811 if (pSIA && SUCCEEDED(pEC->QueryInterface(IID_PPV_ARG(IObjectWithSelection, &pOWS))))
1812 pOWS->SetSelection(pSIA);
1813
1814 DWORD dwKeyState = 0, fMask = pICI ? pICI->fMask : 0;
1815 pEC->SetNoShowUI((fMask & CMIC_MASK_FLAG_NO_UI) != 0);
1816 pEC->SetShowWindow(pICI ? pICI->nShow : SW_SHOW);
1817 if (fMask & CMIC_MASK_SHIFT_DOWN)
1818 dwKeyState |= MK_SHIFT;
1819 if (fMask & CMIC_MASK_CONTROL_DOWN)
1820 dwKeyState |= MK_CONTROL;
1821 pEC->SetKeyState(dwKeyState);
1822 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpDirectoryW)
1823 pEC->SetDirectory(pICI->lpDirectoryW);
1824 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpParametersW)
1825 pEC->SetParameters(pICI->lpParametersW);
1826 if (fMask & CMIC_MASK_PTINVOKE)
1827 pEC->SetPosition(pICI->ptInvoke);
1828
1829 return pEC->Execute();
1830}
1831
1834 _In_ IExecuteCommand *pEC,
1835 _In_ PCWSTR pszCommandName,
1837 _In_ IDataObject *pDO,
1838 _In_opt_ LPCMINVOKECOMMANDINFOEX pICI,
1839 _In_opt_ IUnknown *pSite)
1840{
1842 HRESULT hr = SHCreateShellItemArrayFromDataObject(pDO, IID_PPV_ARG(IShellItemArray, &pSIA));
1843 return SUCCEEDED(hr) ? InvokeIExecuteCommand(pEC, pszCommandName, pPB, pSIA, pICI, pSite) : hr;
1844}
1845
1846static HRESULT
1848{
1849 HRESULT hr = pCM->GetCommandString(Id, GCS & ~GCS_UNICODE, NULL, Buf, cchMax);
1850 if (FAILED(hr))
1851 {
1853 hr = pCM->GetCommandString(Id, GCS | GCS_UNICODE, NULL, (LPSTR)buf, _countof(buf));
1854 if (SUCCEEDED(hr))
1855 hr = SHUnicodeToAnsi(buf, Buf, cchMax) > 0 ? S_OK : E_FAIL;
1856 }
1857 return hr;
1858}
1859
1860UINT
1862{
1863 CHAR buf[MAX_PATH];
1864 if (IS_INTRESOURCE(verba))
1865 {
1866 if (FAILED(GetCommandStringA(pCM, LOWORD(verba), GCS_VERB, buf, _countof(buf))))
1867 return 0;
1868 verba = buf;
1869 }
1870 return MapVerbToDfmCmd(verba); // Returns DFM_CMD_* or 0
1871}
1872
1873HRESULT
1874SHELL_MapContextMenuVerbToCmdId(LPCMINVOKECOMMANDINFO pICI, const CMVERBMAP *pMap)
1875{
1876 LPCSTR pVerbA = pICI->lpVerb;
1877 CHAR buf[MAX_PATH];
1878 LPCMINVOKECOMMANDINFOEX pICIX = (LPCMINVOKECOMMANDINFOEX)pICI;
1879 if (IsUnicode(*pICIX) && !IS_INTRESOURCE(pICIX->lpVerbW))
1880 {
1881 if (SHUnicodeToAnsi(pICIX->lpVerbW, buf, _countof(buf)))
1882 pVerbA = buf;
1883 }
1884
1885 if (IS_INTRESOURCE(pVerbA))
1886 return LOWORD(pVerbA);
1887 for (SIZE_T i = 0; pMap[i].Verb; ++i)
1888 {
1889 assert(SUCCEEDED((int)(pMap[i].CmdId))); // The id must be >= 0 and ideally in the 0..0x7fff range
1890 if (!lstrcmpiA(pMap[i].Verb, pVerbA) && pVerbA[0])
1891 return pMap[i].CmdId;
1892 }
1893 return E_FAIL;
1894}
1895
1896static const CMVERBMAP*
1898{
1899 for (SIZE_T i = 0; pMap[i].Verb; ++i)
1900 {
1901 if (pMap[i].CmdId == CmdId)
1902 return &pMap[i];
1903 }
1904 return NULL;
1905}
1906
1907HRESULT
1909{
1910 const CMVERBMAP* pEntry;
1911 switch (uFlags | GCS_UNICODE)
1912 {
1913 case GCS_VALIDATEW:
1914 case GCS_VERBW:
1915 pEntry = FindVerbMapEntry(CmdId, pMap);
1916 if ((uFlags | GCS_UNICODE) == GCS_VERBW)
1917 {
1918 if (!pEntry)
1919 return E_INVALIDARG;
1920 else if (uFlags & GCS_UNICODE)
1921 return SHAnsiToUnicode(pEntry->Verb, (LPWSTR)Buf, cchBuf) ? S_OK : E_FAIL;
1922 else
1923 return StringCchCopyA(Buf, cchBuf, pEntry->Verb);
1924 }
1925 return pEntry ? S_OK : S_FALSE; // GCS_VALIDATE
1926 }
1927 return E_NOTIMPL;
1928}
1929
1930HRESULT
1932{
1936 return hr;
1937 initIcon->SetNormalIcon(swShell32Name, IconIndex);
1938 return initIcon->QueryInterface(riid, ppvOut);
1939}
1940
1941int DCIA_AddEntry(HDCIA hDCIA, REFCLSID rClsId)
1942{
1943 for (UINT i = 0;; ++i)
1944 {
1945 const CLSID *pClsId = DCIA_GetEntry(hDCIA, i);
1946 if (!pClsId)
1947 break;
1948 if (IsEqualGUID(*pClsId, rClsId))
1949 return i; // Don't allow duplicates
1950 }
1951 return DSA_AppendItem((HDSA)hDCIA, const_cast<CLSID*>(&rClsId));
1952}
1953
1954void DCIA_AddShellExSubkey(HDCIA hDCIA, HKEY hProgId, PCWSTR pszSubkey)
1955{
1956 WCHAR szKey[200];
1957 PathCombineW(szKey, L"shellex", pszSubkey);
1958 HKEY hEnum;
1959 if (RegOpenKeyExW(hProgId, szKey, 0, KEY_READ, &hEnum) != ERROR_SUCCESS)
1960 return;
1961 for (UINT i = 0; RegEnumKeyW(hEnum, i++, szKey, _countof(szKey)) == ERROR_SUCCESS;)
1962 {
1963 CLSID clsid;
1964 if (SUCCEEDED(SHELL_GetShellExtensionRegCLSID(hEnum, szKey, &clsid)))
1965 DCIA_AddEntry(hDCIA, clsid);
1966 }
1967 RegCloseKey(hEnum);
1968}
1969
1970/*************************************************************************
1971 * SHIsBadInterfacePtr [SHELL32.84]
1972 *
1973 * Retired in 6.0 from Windows Vista and higher.
1974 */
1978 _In_ LPCVOID pv,
1979 _In_ UINT_PTR ucb)
1980{
1981 struct CUnknownVtbl
1982 {
1986 };
1987 struct CUnknown { CUnknownVtbl *lpVtbl; };
1988 const CUnknown *punk = reinterpret_cast<const CUnknown *>(pv);
1989 return !punk || IsBadReadPtr(punk, sizeof(punk->lpVtbl)) ||
1990 IsBadReadPtr(punk->lpVtbl, ucb) ||
1991 IsBadCodePtr((FARPROC)punk->lpVtbl->Release);
1992}
1993
1994/*************************************************************************
1995 * SHGetUserDisplayName [SHELL32.241]
1996 *
1997 * @see https://undoc.airesoft.co.uk/shell32.dll/SHGetUserDisplayName.php
1998 */
2002 _Out_writes_to_(*puSize, *puSize) PWSTR pName,
2003 _Inout_ PULONG puSize)
2004{
2005 if (!pName || !puSize)
2006 return E_INVALIDARG;
2007
2008 if (GetUserNameExW(NameDisplay, pName, puSize))
2009 return S_OK;
2010
2011 LONG error = GetLastError(); // for ERROR_NONE_MAPPED
2013
2014 WCHAR UserName[MAX_PATH];
2015 DWORD cchUserName = _countof(UserName);
2016 if (!GetUserNameW(UserName, &cchUserName))
2018
2019 // Was the user name not available in the specified format (NameDisplay)?
2020 if (error == ERROR_NONE_MAPPED)
2021 {
2022 // Try to get the user name by using Network API
2023 PUSER_INFO_2 UserInfo;
2024 DWORD NetError = NetUserGetInfo(NULL, UserName, 2, (PBYTE*)&UserInfo);
2025 if (NetError)
2026 {
2027 hr = HRESULT_FROM_WIN32(NetError);
2028 }
2029 else
2030 {
2031 if (UserInfo->usri2_full_name)
2032 {
2033 hr = StringCchCopyW(pName, *puSize, UserInfo->usri2_full_name);
2034 if (SUCCEEDED(hr))
2035 {
2036 // Include the NUL-terminator
2037 *puSize = lstrlenW(UserInfo->usri2_full_name) + 1;
2038 }
2039 }
2040
2041 NetApiBufferFree(UserInfo);
2042 }
2043 }
2044
2045 if (FAILED(hr))
2046 {
2047 hr = StringCchCopyW(pName, *puSize, UserName);
2048 if (SUCCEEDED(hr))
2049 *puSize = cchUserName;
2050 }
2051
2052 return hr;
2053}
2054
2055// Skip leading backslashes
2056static PCWSTR
2058 _In_ PCWSTR pszPath)
2059{
2060 PCWSTR pch;
2061 for (pch = pszPath; *pch == L'\\'; ++pch)
2062 ;
2063 return pch;
2064}
2065
2066// The registry key for server computer descriptions cache
2067#define COMPUTER_DESCRIPTIONS_KEY \
2068 L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComputerDescriptions"
2069
2070// Get server computer description from cache
2071static HRESULT
2073 _Out_writes_z_(cchDescMax) PWSTR pszDesc,
2074 _In_ DWORD cchDescMax,
2075 _In_ PCWSTR pszServerName)
2076{
2077 cchDescMax *= sizeof(WCHAR);
2079 SHELL_SkipServerSlashes(pszServerName), NULL, pszDesc, &cchDescMax);
2080 return HRESULT_FROM_WIN32(error);
2081}
2082
2083// Do cache a server computer description
2084static VOID
2086 _In_ PCWSTR pszServerName,
2087 _In_ PCWSTR pszDesc)
2088{
2089 if (!pszDesc)
2090 return;
2091
2092 SIZE_T cbDesc = (wcslen(pszDesc) + 1) * sizeof(WCHAR);
2094 SHELL_SkipServerSlashes(pszServerName), REG_SZ, pszDesc, (DWORD)cbDesc);
2095}
2096
2097// Get real server computer description
2098static HRESULT
2100 _Out_writes_z_(cchDescMax) PWSTR pszDesc,
2101 _In_ SIZE_T cchDescMax,
2102 _In_ PWSTR pszServerName)
2103{
2105 NET_API_STATUS error = NetServerGetInfo(pszServerName, 101, (PBYTE*)&bufptr);
2108 return hr;
2109
2110 PCWSTR comment = bufptr->sv101_comment;
2111 if (comment && comment[0])
2112 StringCchCopyW(pszDesc, cchDescMax, comment);
2113 else
2114 hr = E_FAIL;
2115
2117 return hr;
2118}
2119
2120// Build computer display name
2121static HRESULT
2123 _Out_writes_z_(cchNameMax) PWSTR pszName,
2124 _In_ DWORD cchNameMax,
2125 _In_ PCWSTR pszServerName,
2126 _In_ PCWSTR pszDescription)
2127{
2128 if (!pszDescription || !*pszDescription)
2129 return E_FAIL;
2130
2131 PCWSTR pszFormat = (SHRestricted(REST_ALLOWCOMMENTTOGGLE) ? L"%2 (%1)" : L"%1 (%2)");
2132 PCWSTR args[] = { pszDescription , SHELL_SkipServerSlashes(pszServerName) };
2134 pszFormat, 0, 0, pszName, cchNameMax, (va_list *)args) ? S_OK : E_FAIL);
2135}
2136
2137/*************************************************************************
2138 * SHGetComputerDisplayNameW [SHELL32.752]
2139 */
2143 _In_opt_ PWSTR pszServerName,
2145 _Out_writes_z_(cchNameMax) PWSTR pszName,
2146 _In_ DWORD cchNameMax)
2147{
2148 WCHAR szDesc[256], szCompName[MAX_COMPUTERNAME_LENGTH + 1];
2149
2150 // If no server name is specified, retrieve the local computer name
2151 if (!pszServerName)
2152 {
2153 // Use computer name as server name
2154 DWORD cchCompName = _countof(szCompName);
2155 if (!GetComputerNameW(szCompName, &cchCompName))
2156 return E_FAIL;
2157 pszServerName = szCompName;
2158
2159 // Don't use the cache for the local machine
2161 }
2162
2163 // Get computer description from cache if necessary
2164 HRESULT hr = E_FAIL;
2165 if (!(dwFlags & SHGCDN_NOCACHE))
2166 hr = SHELL_GetCachedComputerDescription(szDesc, _countof(szDesc), pszServerName);
2167
2168 // Actually retrieve the computer description if it is not in the cache
2169 if (FAILED(hr))
2170 {
2171 hr = SHELL_GetComputerDescription(szDesc, _countof(szDesc), pszServerName);
2172 if (FAILED(hr))
2173 szDesc[0] = UNICODE_NULL;
2174
2175 // Cache the description if necessary
2176 if (!(dwFlags & SHGCDN_NOCACHE))
2177 SHELL_CacheComputerDescription(pszServerName, szDesc);
2178 }
2179
2180 // If getting the computer description failed, store the server name only
2181 if (FAILED(hr) || !szDesc[0])
2182 {
2184 return hr; // Bail out if no server name is requested
2185
2186 StringCchCopyW(pszName, cchNameMax, SHELL_SkipServerSlashes(pszServerName));
2187 return S_OK;
2188 }
2189
2190 // If no server name is requested, store the description only
2192 {
2193 StringCchCopyW(pszName, cchNameMax, szDesc);
2194 return S_OK;
2195 }
2196
2197 // Build a string like "Description (SERVERNAME)"
2198 return SHELL_BuildDisplayMachineName(pszName, cchNameMax, pszServerName, szDesc);
2199}
2200
2201typedef struct tagALIAS_MAPPING
2202{
2203 BYTE bFlagMask; // The combination of ALIAS_USER_FOLDER and/or ALIAS_DESKTOP
2205 WORD nCsidlSrc; // CSIDL_... (source)
2206 WORD nCsidlDest; // CSIDL_... (destination)
2208
2211{
2212 {
2214 FALSE,
2217 },
2218 {
2220 FALSE,
2223 },
2224 {
2226 FALSE,
2229 },
2230 {
2232 TRUE,
2235 }
2236};
2237
2242 _In_opt_ HANDLE hToken,
2243 _In_ LPCITEMIDLIST pidlTarget,
2244 _Out_ LPITEMIDLIST *ppidlNew,
2246{
2247 if (!pidlTarget || !ppidlNew)
2248 return FALSE;
2249
2250 *ppidlNew = NULL;
2251
2252 for (SIZE_T iEntry = 0; iEntry < _countof(g_AliasTable); ++iEntry)
2253 {
2254 const ALIAS_MAPPING *pEntry = &g_AliasTable[iEntry];
2255
2256 if (!(dwFlags & pEntry->bFlagMask))
2257 continue;
2258
2259 // Get the source root PIDL
2260 LPITEMIDLIST pidlSrcRoot = NULL;
2261 HRESULT hr = SHGetFolderLocation(hwnd, pEntry->nCsidlSrc, hToken, 0, &pidlSrcRoot);
2262 if (FAILED(hr))
2263 continue;
2264
2265 // Check whether the input pidlTarget is under the source folder.
2266 // If it matches, ILFindChild returns the relative PIDL in the pidlTarget.
2267 LPCITEMIDLIST pidlRelative = ILFindChild(pidlSrcRoot, pidlTarget);
2268 if (!pidlRelative) // Not found?
2269 {
2270 ILFree(pidlSrcRoot);
2271 continue;
2272 }
2273
2274 // Found. Get the destination root PIDL
2275 LPITEMIDLIST pidlDestRoot = NULL;
2276 hr = SHGetFolderLocation(hwnd, pEntry->nCsidlDest, hToken, 0, &pidlDestRoot);
2277 if (SUCCEEDED(hr))
2278 {
2279 // Create a new PIDL by combining the destination root PIDL and the relative PIDL
2280 *ppidlNew = ILCombine(pidlDestRoot, pidlRelative);
2281 if (*ppidlNew)
2282 {
2283 // Manipulate specific flags in the PIDL if necessary
2284 if (pEntry->bCommonDesktop && (*ppidlNew)->mkid.cb >= 3)
2285 {
2286 (*ppidlNew)->mkid.abID[0] |= (PT_FS | PT_FS_COMMON_FLAG);
2287 }
2288 }
2289 ILFree(pidlDestRoot);
2290 }
2291
2292 ILFree(pidlSrcRoot);
2293 break; // A match was found, so exit the loop
2294 }
2295
2296 return (*ppidlNew != NULL);
2297}
2298
2299/*************************************************************************
2300 * SHSetLocalizedName (SHELL32.@)
2301 *
2302 * https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shsetlocalizedname
2303 */
2307 _In_ PCWSTR pszPath,
2308 _In_ PCWSTR pszResModule,
2309 _In_ INT idsRes)
2310{
2311 HRESULT hr;
2312 IShellFolder *pDesktop = NULL, *pParent = NULL;
2313 LPITEMIDLIST pidl = NULL;
2314 LPCITEMIDLIST pidlLast;
2316 INT cchShortMax, cchShort, cchName;
2317 PWSTR pszShortPath = NULL, pszName = NULL;
2318
2321 return hr;
2322
2323 hr = SHGetDesktopFolder(&pDesktop);
2325 goto Cleanup;
2326
2327 hr = pDesktop->ParseDisplayName(NULL, NULL, (PWSTR)pszPath, NULL, &pidl, NULL);
2329 goto Cleanup;
2330
2331 hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &pParent), &pidlLast);
2333 goto Cleanup;
2334
2336 cchShortMax = lstrlenW(pszResModule) + 1;
2337 pszShortPath = (PWSTR)HeapAlloc(hProcessHeap, 0, cchShortMax * sizeof(WCHAR));
2338 if (!pszShortPath)
2339 {
2340 hr = E_OUTOFMEMORY;
2341 goto Cleanup;
2342 }
2343
2344 cchShort = GetShortPathNameW(pszResModule, pszShortPath, cchShortMax);
2345 if (cchShort)
2346 pszResModule = pszShortPath;
2347 else
2348 cchShort = cchShortMax;
2349
2350 /* 14 == '@' + ',' + '-' + (digits of max width 10) + NUL */
2351 cchName = cchShort + 14;
2352 pszName = (PWSTR)HeapAlloc(hProcessHeap, 0, cchName * sizeof(WCHAR));
2353 if (!pszName)
2354 {
2355 hr = E_OUTOFMEMORY;
2356 goto Cleanup;
2357 }
2358
2359 wnsprintfW(pszName, cchName, L"@%s,%d", pszResModule, -idsRes);
2360 hr = pParent->SetNameOf(NULL, pidlLast, pszName, 0, NULL);
2361
2362Cleanup:
2363 if (pszName)
2364 HeapFree(hProcessHeap, 0, pszName);
2365 if (pszShortPath)
2366 HeapFree(hProcessHeap, 0, pszShortPath);
2367 if (pParent)
2368 pParent->Release();
2369 if (pidl)
2370 SHFree(pidl);
2371 if (pDesktop)
2372 pDesktop->Release();
2374 return hr;
2375}
2376
2380 _In_ LPCITEMIDLIST pidl,
2381 _Out_ LPITEMIDLIST *ppidlNew,
2383{
2384 return SHELL32_ReparentAsAliasPidl(NULL, NULL, pidl, ppidlNew, dwFlags) ? S_OK : E_FAIL;
2385}
2386
2387/*************************************************************************
2388 * LinkWindow_RegisterClass (SHELL32.258)
2389 *
2390 * https://learn.microsoft.com/en-us/windows/win32/shell/linkwindow-registerclass
2391 */
2393{
2394 INITCOMMONCONTROLSEX iccx = { sizeof(iccx), ICC_LINK_CLASS };
2395 InitCommonControlsEx(&iccx);
2396
2397 WNDCLASSEXW wcx = { sizeof(wcx) };
2398 if (!GetClassInfoExW(NULL, L"SysLink", &wcx))
2399 return FALSE;
2400
2401 /* Superclassing! */
2402 wcx.lpszClassName = L"Link Window";
2404}
2405
2406/*************************************************************************
2407 * LinkWindow_UnregisterClass (SHELL32.259)
2408 */
2410{
2411 /* Do nothing. This is correct. */
2412 return TRUE;
2413}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
UINT MapVerbToDfmCmd(_In_ LPCSTR verba)
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
DWORD Id
EXTERN_C HRESULT WINAPI SHCreateShellItemArrayFromDataObject(_In_ IDataObject *pdo, _In_ REFIID riid, _Out_ void **ppv)
#define IID_PPV_ARG(Itype, ppType)
PRTL_UNICODE_STRING_BUFFER Path
UINT cchMax
Type
Definition: Type.h:7
#define REG_SZ
Definition: layer.c:22
static int state
Definition: maze.c:121
const DWORD Style
Definition: appswitch.c:72
const DWORD ExStyle
Definition: appswitch.c:73
HWND hWnd
Definition: settings.c:17
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
void shell(int argc, const char *argv[])
Definition: cmds.c:1231
@ Create
Definition: registry.c:563
#define ERR(fmt,...)
Definition: precomp.h:57
#define ULongToHandle(h)
Definition: basetsd.h:75
#define EXTERN_C
Definition: basetyps.h:12
#define STDMETHODIMP
Definition: basetyps.h:43
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
#define RegCloseKey(hKey)
Definition: registry.h:49
_In_ BOOLEAN Release
Definition: cdrom.h:920
HINSTANCE hInstance
Definition: charmap.c:19
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:743
HWND GetLastActivePopup() const
Definition: atlwin.h:676
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj) override
Definition: utils.cpp:607
STDMETHODIMP GetWindow(HWND *phWnd) override
Definition: utils.cpp:631
STDMETHODIMP_(ULONG) Release() override
Definition: utils.cpp:620
STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode) override
Definition: utils.cpp:638
STDMETHODIMP_(ULONG) AddRef() override
Definition: utils.cpp:616
virtual ~CDummyOleWindow()
Definition: utils.cpp:604
bool AllocateBytes(_In_ size_t nBytes)
Definition: atlalloc.h:127
HRESULT CreateStub(UINT Type, LPCWSTR Path, const POINT *pPt)
Definition: utils.cpp:195
static LPCWSTR GetTypePropName()
Definition: precomp.h:238
static HWND FindStubWindow(UINT Type, LPCWSTR Path)
Definition: utils.cpp:182
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
LPARAM lParam
Definition: combotst.c:139
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
Definition: commctrl.c:904
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define NO_ERROR
Definition: dderror.h:5
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#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
HRESULT hr
Definition: delayimp.cpp:582
#define ERROR_SUCCESS
Definition: deptool.c:10
LPWSTR Name
Definition: desk.c:124
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
_Check_return_ _In_ PQUERY_INTERFACE QueryInterface
Definition: dispmprt.h:1318
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
BOOL WINAPI AdjustTokenPrivileges(HANDLE TokenHandle, BOOL DisableAllPrivileges, PTOKEN_PRIVILEGES NewState, DWORD BufferLength, PTOKEN_PRIVILEGES PreviousState, PDWORD ReturnLength)
Definition: security.c:374
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
BOOL WINAPI OpenThreadToken(HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, HANDLE *TokenHandle)
Definition: security.c:336
UINT uFlags
Definition: api.c:59
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(void *reserved, DWORD model)
Definition: combase.c:2803
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: combase.c:2842
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, REFIID riid, void **obj)
Definition: combase.c:1685
void WINAPI CoTaskMemFree(void *ptr)
Definition: malloc.c:389
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:407
INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:500
INT WINAPI StrCmpNA(LPCSTR lpszStr, LPCSTR lpszComp, INT iLen)
Definition: string.c:489
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
int(* FARPROC)()
Definition: compat.h:36
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define GetCurrentProcess()
Definition: compat.h:759
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
#define lstrlenW
Definition: compat.h:750
static DWORD DWORD * dwLength
Definition: fusion.c:86
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:492
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:805
BOOL NTAPI IsBadCodePtr(FARPROC lpfn)
Definition: except.c:872
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:58
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:636
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
DWORD WINAPI GetShortPathNameW(IN LPCWSTR lpszLongPath, OUT LPWSTR lpszShortPath, IN DWORD cchBuffer)
Definition: path.c:1851
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4171
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4133
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1675
#define IS_INTRESOURCE(x)
Definition: loader.c:613
int WINAPI PathCommonPrefixW(const WCHAR *file1, const WCHAR *file2, WCHAR *path)
Definition: path.c:1596
void WINAPI PathRemoveExtensionW(WCHAR *path)
Definition: path.c:1922
BOOL WINAPI PathRemoveFileSpecW(WCHAR *path)
Definition: path.c:1121
BOOL WINAPI PathUnExpandEnvStringsW(const WCHAR *path, WCHAR *buffer, UINT buf_len)
Definition: path.c:2681
BOOL WINAPI PathStripToRootW(WCHAR *path)
Definition: path.c:1171
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
Definition: path.c:2197
BOOL WINAPI SHRegGetBoolUSValueW(const WCHAR *subkey, const WCHAR *value, BOOL ignore_hkcu, BOOL default_value)
Definition: registry.c:4139
LPSTR WINAPI CharNextA(const char *ptr)
Definition: string.c:1151
#define assert(_expr)
Definition: assert.h:32
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
_ACRTIMP int __cdecl _wcsnicmp(const wchar_t *, const wchar_t *, size_t)
Definition: wcs.c:200
char * va_list
Definition: vadefs.h:50
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr)
Definition: user.c:3147
static const WCHAR IconIndex[]
Definition: install.c:52
HRESULT WINAPI IUnknown_QueryService(IUnknown *obj, REFGUID sid, REFIID iid, void **out)
Definition: main.c:181
DWORD WINAPI SHQueryValueExW(HKEY hkey, const WCHAR *name, DWORD *reserved, DWORD *type, void *buff, DWORD *buff_len)
Definition: main.c:2101
DWORD WINAPI SHGetValueW(HKEY hkey, const WCHAR *subkey, const WCHAR *value, DWORD *type, void *data, DWORD *data_len)
Definition: main.c:2222
DWORD WINAPI SHAnsiToUnicode(const char *src, WCHAR *dest, int dest_len)
Definition: main.c:1801
DWORD WINAPI SHSetValueW(HKEY hkey, const WCHAR *subkey, const WCHAR *value, DWORD type, const void *data, DWORD data_len)
Definition: main.c:2292
DWORD WINAPI SHUnicodeToAnsi(const WCHAR *src, char *dest, int dest_len)
Definition: main.c:1756
#define CSTUBWINDOW32_CLASSNAME
Definition: precomp.h:228
EXTERN_C WORD WINAPI ExtractIconResInfoW(_In_ HANDLE hHandle, _In_ LPCWSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
Definition: stubs.cpp:639
EXTERN_C HRESULT WINAPI SHSetFolderPathW(_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCWSTR pszPath)
Definition: stubs.cpp:714
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogW(_In_ HWND hwnd, _In_ LPCWSTR pszRemoteName, _In_ DWORD dwType)
Definition: stubs.cpp:457
HRESULT SHELL_DisplayNameOf(_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_opt_ UINT Flags, _Out_ PWSTR *ppStr)
Definition: utils.cpp:454
static DWORD SHELL_ReadSingleUnreadMailCount(_In_ HKEY hKey, _Out_opt_ PDWORD pdwCount, _Out_opt_ PFILETIME pFileTime, _Out_writes_opt_(cchShellExecuteCommand) LPWSTR pszShellExecuteCommand, _In_ INT cchShellExecuteCommand)
Definition: utils.cpp:1016
BOOL WINAPI IsSuspendAllowed(VOID)
Definition: utils.cpp:956
HRESULT SHELL_CreateShell32DefaultExtractIcon(int IconIndex, REFIID riid, LPVOID *ppvOut)
Definition: utils.cpp:1931
EXTERN_C HRESULT WINAPI SHGetPathCchFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, SIZE_T cchPathMax)
EXTERN_C HRESULT WINAPI SHGetComputerDisplayNameW(_In_opt_ PWSTR pszServerName, _In_ DWORD dwFlags, _Out_writes_z_(cchNameMax) PWSTR pszName, _In_ DWORD cchNameMax)
Definition: utils.cpp:2142
EXTERN_C HRESULT WINAPI SHEnumerateUnreadMailAccountsW(_In_opt_ HKEY hKeyUser, _In_ DWORD dwIndex, _Out_writes_(cchMailAddress) PWSTR pszMailAddress, _In_ INT cchMailAddress)
Definition: utils.cpp:1243
static const CMVERBMAP * FindVerbMapEntry(UINT_PTR CmdId, const CMVERBMAP *pMap)
Definition: utils.cpp:1897
#define PATH_VALID_ELEMENT
Definition: utils.cpp:221
EXTERN_C HRESULT WINAPI SHGetUnreadMailCountW(_In_opt_ HKEY hKeyUser, _In_opt_ PCWSTR pszMailAddress, _Out_opt_ PDWORD pdwCount, _Inout_opt_ PFILETIME pFileTime, _Out_writes_opt_(cchShellExecuteCommand) PWSTR pszShellExecuteCommand, _In_ INT cchShellExecuteCommand)
Definition: utils.cpp:1060
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:496
static HRESULT SHELL_GetComputerDescription(_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ SIZE_T cchDescMax, _In_ PWSTR pszServerName)
Definition: utils.cpp:2099
static VOID DynamicPathRemoveBackslashW(_Out_ CStringW &strPath)
Definition: utils.cpp:1705
EXTERN_C BOOL SHELL32_ReparentAsAliasPidl(_In_opt_ HWND hwnd, _In_opt_ HANDLE hToken, _In_ LPCITEMIDLIST pidlTarget, _Out_ LPITEMIDLIST *ppidlNew, _In_ DWORD dwFlags)
Translate a PIDL to an "alias" PIDL.
Definition: utils.cpp:2240
EXTERN_C WORD WINAPI ExtractIconResInfoA(_In_ HANDLE hHandle, _In_ LPCSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
Definition: utils.cpp:781
EXTERN_C PSTR WINAPI StrRStrA(_In_ PCSTR pszSrc, _In_opt_ PCSTR pszLast, _In_ PCSTR pszSearch)
Definition: utils.cpp:122
HRESULT SHGetNameAndFlagsW(_In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_opt_ LPWSTR pszText, _In_ UINT cchBuf, _Inout_opt_ DWORD *pdwAttributes)
Definition: utils.cpp:551
static const ALIAS_MAPPING g_AliasTable[]
PIDL alias table.
Definition: utils.cpp:2210
static HRESULT GetCommandStringA(_In_ IContextMenu *pCM, _In_ UINT_PTR Id, _In_ UINT GCS, _Out_writes_(cchMax) LPSTR Buf, _In_ UINT cchMax)
Definition: utils.cpp:1847
EXTERN_C BOOL WINAPI PathIsEqualOrSubFolder(_In_ LPCWSTR pszPath1OrCSIDL, _In_ LPCWSTR pszPath2)
Definition: utils.cpp:1718
EXTERN_C HRESULT WINAPI SHGetRealIDL(_In_ IShellFolder *psf, _In_ PCUITEMID_CHILD pidlSimple, _Outptr_ PITEMID_CHILD *ppidlReal)
Definition: utils.cpp:1749
EXTERN_C DWORD WINAPI SHGetUserSessionId(_In_opt_ HANDLE hToken)
Definition: utils.cpp:822
#define COPY_STREAM_DEFAULT_BUFFER_SIZE
static VOID Int64GetNumFormat(_Out_ NUMBERFMTW *pDest, _In_opt_ const NUMBERFMTW *pSrc, _In_ DWORD dwNumberFlags, _Out_writes_(cchDecimal) LPWSTR pszDecimal, _In_ INT cchDecimal, _Out_writes_(cchThousand) LPWSTR pszThousand, _In_ INT cchThousand)
Definition: utils.cpp:1348
static INT _SHMergePopupMenus(HMENU hMenu, HMENU hPopupMenu, UINT uIDAdjust, UINT uIDAdjustMax)
Definition: utils.cpp:35
EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW(_In_opt_ HANDLE hToken, _In_ LPCWSTR lpName)
Definition: utils.cpp:892
DWORD BindCtx_GetMode(_In_ IBindCtx *pbc, _In_ DWORD dwDefault)
Definition: utils.cpp:336
static HRESULT SHELL_BuildDisplayMachineName(_Out_writes_z_(cchNameMax) PWSTR pszName, _In_ DWORD cchNameMax, _In_ PCWSTR pszServerName, _In_ PCWSTR pszDescription)
Definition: utils.cpp:2122
static VOID SHELL_CacheComputerDescription(_In_ PCWSTR pszServerName, _In_ PCWSTR pszDesc)
Definition: utils.cpp:2085
EXTERN_C HRESULT WINAPI SHInvokePrivilegedFunctionW(_In_ LPCWSTR pszName, _In_ PRIVILEGED_FUNCTION fn, _In_opt_ LPARAM lParam)
Definition: utils.cpp:849
BOOL BindCtx_ContainsObject(_In_ IBindCtx *pBindCtx, _In_ LPCWSTR pszName)
Definition: utils.cpp:328
HRESULT SHIsFileSysBindCtx(_In_ IBindCtx *pBindCtx, _Out_opt_ WIN32_FIND_DATAW *pFindData)
Definition: utils.cpp:361
BOOL PathIsValidElement(_In_ LPCWSTR pszPath)
Definition: utils.cpp:226
EXTERN_C HRESULT InvokeIExecuteCommand(_In_ IExecuteCommand *pEC, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB, _In_opt_ IShellItemArray *pSIA, _In_opt_ LPCMINVOKECOMMANDINFOEX pICI, _In_opt_ IUnknown *pSite)
Definition: utils.cpp:1796
EXTERN_C LPWSTR WINAPI ShortSizeFormatW(_In_ DWORD dwNumber, _Out_writes_(0x8FFF) LPWSTR pszBuffer)
Definition: utils.cpp:802
static PCSTR StrEndNA(_In_ PCSTR psz, _In_ INT_PTR cch)
Definition: utils.cpp:17
EXTERN_C LPSTR WINAPI SheRemoveQuotesA(LPSTR psz)
Definition: utils.cpp:1193
BOOL Shell_FailForceReturn(_In_ HRESULT hr)
Definition: utils.cpp:378
void DCIA_AddShellExSubkey(HDCIA hDCIA, HKEY hProgId, PCWSTR pszSubkey)
Definition: utils.cpp:1954
static PCWSTR StrEndNW(_In_ PCWSTR psz, _In_ INT_PTR cch)
Definition: utils.cpp:27
static INT DynamicPathCommonPrefixW(_In_ LPCWSTR lpszPath1, _In_ LPCWSTR lpszPath2, _Out_ CStringW &strPath)
Definition: utils.cpp:1633
EXTERN_C HRESULT IUnknown_InitializeCommand(_In_ IUnknown *pUnk, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB)
Definition: utils.cpp:1783
static HRESULT DynamicSHGetPathFromIDListW(_In_ LPCITEMIDLIST pidl, _Out_ CStringW &strPath)
Definition: utils.cpp:1650
EXTERN_C INT WINAPI Int64ToString(_In_ LONGLONG llValue, _Out_writes_(cchOut) LPWSTR pszOut, _In_ UINT cchOut, _In_ BOOL bUseFormat, _In_opt_ const NUMBERFMTW *pNumberFormat, _In_ DWORD dwNumberFlags)
Definition: utils.cpp:1408
SHSTDAPI SHBindToObject(_In_opt_ IShellFolder *pShellFolder, _In_ PCUIDLIST_RELATIVE pidl, _In_opt_ IBindCtx *pBindCtx, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:395
EXTERN_C BOOL WINAPI Activate_RunDLL(_In_ HWND hwnd, _In_ HINSTANCE hinst, _In_ LPCWSTR cmdline, _In_ INT cmdshow)
Definition: utils.cpp:1583
EXTERN_C BOOL WINAPI PathIsSlowA(_In_ LPCSTR pszFile, _In_ DWORD dwAttr)
Definition: utils.cpp:767
UINT GetDfmCmd(_In_ IContextMenu *pCM, _In_ LPCSTR verba)
Definition: utils.cpp:1861
HRESULT SHELL_GetCommandStringImpl(SIZE_T CmdId, UINT uFlags, LPSTR Buf, UINT cchBuf, const CMVERBMAP *pMap)
Definition: utils.cpp:1908
EXTERN_C HRESULT WINAPI DisplayNameOfW(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_ LPWSTR pszBuf, _In_ UINT cchBuf)
Definition: utils.cpp:480
EXTERN_C HRESULT WINAPI SHSetUnreadMailCountW(_In_ PCWSTR pszMailAddress, _In_ DWORD dwCount, _In_ PCWSTR pszShellExecuteCommand)
Definition: utils.cpp:1138
EXTERN_C INT WINAPI LargeIntegerToString(_In_ const LARGE_INTEGER *pLargeInt, _Out_writes_(cchOut) LPWSTR pszOut, _In_ UINT cchOut, _In_ BOOL bUseFormat, _In_opt_ const NUMBERFMTW *pNumberFormat, _In_ DWORD dwNumberFlags)
Definition: utils.cpp:1446
EXTERN_C VOID WINAPI CDefFolderMenu_MergeMenu(_In_ HINSTANCE hInstance, _In_ UINT uMainMerge, _In_ UINT uPopupMerge, _Inout_ LPQCMINFO lpQcmInfo)
Definition: utils.cpp:77
EXTERN_C HINSTANCE WINAPI SHGetShellStyleHInstance(VOID)
Definition: utils.cpp:967
EXTERN_C HRESULT SHELL_GetUIObjectOfAbsoluteItem(_In_opt_ HWND hWnd, _In_ PCIDLIST_ABSOLUTE pidl, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:428
EXTERN_C PWSTR WINAPI StrRStrW(_In_ PCWSTR pszSrc, _In_opt_ PCWSTR pszLast, _In_ PCWSTR pszSearch)
Definition: utils.cpp:154
static HRESULT SHELL_GetCachedComputerDescription(_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ DWORD cchDescMax, _In_ PCWSTR pszServerName)
Definition: utils.cpp:2072
EXTERN_C HRESULT BindCtx_RegisterObjectParam(_In_ IBindCtx *pBindCtx, _In_ LPOLESTR pszKey, _In_opt_ IUnknown *punk, _Out_ LPBC *ppbc)
Definition: utils.cpp:645
EXTERN_C HRESULT WINAPI CopyStreamUI(_In_ IStream *pSrc, _Out_ IStream *pDst, _Inout_opt_ IProgressDialog *pProgress, _In_opt_ DWORDLONG dwlSize)
Definition: utils.cpp:1465
EXTERN_C HRESULT WINAPI SHGetUserDisplayName(_Out_writes_to_(*puSize, *puSize) PWSTR pName, _Inout_ PULONG puSize)
Definition: utils.cpp:2001
#define COMPUTER_DESCRIPTIONS_KEY
Definition: utils.cpp:2067
static BOOL OpenEffectiveToken(_In_ DWORD DesiredAccess, _Out_ HANDLE *phToken)
Definition: utils.cpp:307
EXTERN_C BOOL WINAPI SHFindComputer(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch)
Definition: utils.cpp:1277
static HRESULT Int64ToStr(_In_ LONGLONG llValue, _Out_writes_(cchValue) LPWSTR pszValue, _In_ UINT cchValue)
Definition: utils.cpp:1303
int DCIA_AddEntry(HDCIA hDCIA, REFCLSID rClsId)
Definition: utils.cpp:1941
EXTERN_C HRESULT WINAPI SHSetLocalizedName(_In_ PCWSTR pszPath, _In_ PCWSTR pszResModule, _In_ INT idsRes)
Definition: utils.cpp:2306
HRESULT SHELL_MapContextMenuVerbToCmdId(LPCMINVOKECOMMANDINFO pICI, const CMVERBMAP *pMap)
Definition: utils.cpp:1874
EXTERN_C BOOL WINAPI PathIsSlowW(_In_ LPCWSTR pszFile, _In_ DWORD dwAttr)
Definition: utils.cpp:718
EXTERN_C LPWSTR WINAPI SheRemoveQuotesW(LPWSTR psz)
Definition: utils.cpp:1218
EXTERN_C BOOL WINAPI SHIsBadInterfacePtr(_In_ LPCVOID pv, _In_ UINT_PTR ucb)
Definition: utils.cpp:1977
EXTERN_C HRESULT WINAPI SHCreatePropertyBag(_In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:1009
struct tagALIAS_MAPPING * PALIAS_MAPPING
EXTERN_C HRESULT InvokeIExecuteCommandWithDataObject(_In_ IExecuteCommand *pEC, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB, _In_ IDataObject *pDO, _In_opt_ LPCMINVOKECOMMANDINFOEX pICI, _In_opt_ IUnknown *pSite)
Definition: utils.cpp:1833
EXTERN_C HWND BindCtx_GetUIWindow(_In_ IBindCtx *pBindCtx)
Definition: utils.cpp:585
static HMENU SHLoadPopupMenu(HINSTANCE hInstance, UINT uMenuId)
Definition: utils.cpp:61
EXTERN_C HRESULT WINAPI SHSetFolderPathA(_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCSTR pszPath)
Definition: utils.cpp:691
BOOL IsShutdownAllowed(VOID)
Definition: utils.cpp:948
BOOL SHSkipJunctionBinding(_In_ IBindCtx *pbc, _In_ CLSID *pclsid)
Definition: utils.cpp:349
HRESULT SHELL_GetIDListTarget(_In_ LPCITEMIDLIST pidl, _Out_ PIDLIST_ABSOLUTE *ppidl)
Definition: utils.cpp:530
BOOL PathIsDotOrDotDotW(_In_ LPCWSTR pszPath)
Definition: utils.cpp:214
static PCWSTR SHELL_SkipServerSlashes(_In_ PCWSTR pszPath)
Definition: utils.cpp:2057
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogA(_In_ HWND hwnd, _In_ LPCSTR pszRemoteName, _In_ DWORD dwType)
Definition: utils.cpp:1609
HRESULT SHILAppend(_Inout_ LPITEMIDLIST pidl, _Inout_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:261
struct tagALIAS_MAPPING ALIAS_MAPPING
EXTERN_C BOOL WINAPI LinkWindow_UnregisterClass(_In_ DWORD dwUnused)
Definition: utils.cpp:2409
EXTERN_C HRESULT WINAPI SHShouldShowWizards(_In_ IUnknown *pUnknown)
Definition: utils.cpp:284
EXTERN_C BOOL WINAPI SHOpenEffectiveToken(_Out_ LPHANDLE phToken)
Definition: utils.cpp:813
static HRESULT DynamicSHGetSpecialFolderPathW(_In_ HWND hwndOwner, _Out_ CStringW &strPath, _In_ INT nCSIDL, _In_ BOOL bCreate)
Definition: utils.cpp:1682
EXTERN_C HRESULT SHELL32_AliasTranslatePidl(_In_ LPCITEMIDLIST pidl, _Out_ LPITEMIDLIST *ppidlNew, _In_ DWORD dwFlags)
Translate a PIDL to an "alias" PIDL.
Definition: utils.cpp:2379
HRESULT SHCoInitializeAnyApartment(VOID)
Definition: utils.cpp:542
BOOL PathIsDosDevice(_In_ LPCWSTR pszName)
Definition: utils.cpp:240
#define DCIA_GetEntry(hDCIA, iItem)
Definition: utils.h:127
void WINAPI SHFree(LPVOID pv)
Definition: shellole.c:370
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3385
HRESULT WINAPI SHGetFolderLocation(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwReserved, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3278
HMENU WINAPI SHGetMenuFromID(HMENU hMenu, UINT uID)
Definition: ordinal.c:1592
DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
Definition: ordinal.c:5727
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:988
BOOL WINAPI SHSkipJunction(IBindCtx *pbc, const CLSID *pclsid)
Definition: ordinal.c:4022
BOOL WINAPI PathIsNetworkPathW(LPCWSTR lpszPath)
Definition: path.c:1334
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:854
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 FAILED_UNEXPECTEDLY
Definition: utils.cpp:33
#define IShellFolder_ParseDisplayName
Definition: utils.cpp:14
#define IShellFolder_GetDisplayNameOf
Definition: utils.cpp:13
int WINAPIV wnsprintfW(LPWSTR lpOut, int cchLimitIn, LPCWSTR lpFmt,...)
Definition: wsprintf.c:564
HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars, LPWSTR pszColorBuff, int cchMaxColorChars, LPWSTR pszSizeBuff, int cchMaxSizeChars)
Definition: system.c:980
static const WCHAR szColorName[]
Definition: system.c:42
static const WCHAR Cleanup[]
Definition: register.c:80
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:41
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
HINSTANCE hInst
Definition: dxdiag.c:13
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83
HANDLE hProcessHeap
Definition: explorer.cpp:25
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22
FxObject * pParent
Definition: fxdpcapi.cpp:86
FxAutoRegKey hKey
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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
unsigned int UINT
Definition: sysinfo.c:13
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
REFIID riid
Definition: atlbase.h:39
HRESULT InvokeCommand([in] LPCMINVOKECOMMANDINFO lpici)
HRESULT GetUIObjectOf([in] HWND hwndOwner, [in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in] REFIID riid, [in, out, unique] UINT *prgfInOut, [out, iid_is(riid)] void **ppvOut)
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 AddRef()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
nsresult QueryInterface(nsIIDRef riid, void **result)
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
unsigned long long DWORDLONG
Definition: intsafe.h:93
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1130
#define Stat
Definition: syshdrs.h:78
#define PT_FS
Definition: lnktool.cpp:40
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ZeroMemory
Definition: minwinbase.h:31
#define LPTR
Definition: minwinbase.h:93
LONG_PTR LPARAM
Definition: minwindef.h:175
CONST void * LPCVOID
Definition: minwindef.h:164
#define error(str)
Definition: mkdosfs.c:1605
#define pch(ap)
Definition: match.c:418
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LPCWSTR szPath
Definition: env.c:37
ULONG nr
Definition: thread.c:7
static LPSTR pName
Definition: security.c:86
static HINSTANCE hinst
Definition: edit.c:551
#define comment(fmt, arg1)
Definition: rebar.c:847
static IActiveScriptSite * site
Definition: script.c:149
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:83
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define min(a, b)
Definition: monoChain.cc:55
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
const CLSID * clsid
Definition: msctf.cpp:50
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
DWORD WINAPI MultinetGetConnectionPerformanceW(LPNETRESOURCEW lpNetResource, LPNETCONNECTINFOSTRUCT lpNetConnectInfoStruct)
Definition: multinet.c:54
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
#define _Out_writes_z_(s)
Definition: no_sal2.h:180
#define _Out_opt_
Definition: no_sal2.h:214
#define _Inout_
Definition: no_sal2.h:162
#define _Out_writes_opt_(s)
Definition: no_sal2.h:226
#define _Outptr_
Definition: no_sal2.h:262
#define _Inout_opt_
Definition: no_sal2.h:216
#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 _Out_writes_to_(s, c)
Definition: no_sal2.h:188
#define REG_BINARY
Definition: nt_native.h:1499
#define KEY_READ
Definition: nt_native.h:1026
#define FILE_ATTRIBUTE_OFFLINE
Definition: nt_native.h:712
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1022
#define DWORD
Definition: nt_native.h:44
#define KEY_SET_VALUE
Definition: nt_native.h:1020
#define LOCALE_USER_DEFAULT
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define ANSI_NULL
#define STGM_READWRITE
Definition: objbase.h:938
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:279
@ COINIT_DISABLE_OLE1DDE
Definition: objbase.h:281
interface IBindCtx * LPBC
Definition: objfwd.h:18
HRESULT WINAPI CreateBindCtx(DWORD reserved, IBindCtx **bind_context)
Definition: bindctx.c:491
#define PathCombineW
Definition: pathcch.h:318
#define LOWORD(l)
Definition: pedump.c:82
#define WS_CAPTION
Definition: pedump.c:624
BYTE * PBYTE
Definition: pedump.c:66
short WCHAR
Definition: pedump.c:58
DWORD * PDWORD
Definition: pedump.c:68
long LONG
Definition: pedump.c:60
#define WS_DISABLED
Definition: pedump.c:621
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
char CHAR
Definition: pedump.c:57
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1051
LPITEMIDLIST WINAPI ILCombine(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2)
Definition: pidl.c:817
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1504
PUIDLIST_RELATIVE WINAPI ILFindChild(PIDLIST_ABSOLUTE pidl1, PCIDLIST_ABSOLUTE pidl2)
Definition: pidl.c:751
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:713
static const WCHAR szName[]
Definition: powrprof.c:45
EXTERN_C HRESULT WINAPI SHCreatePropertyBagOnMemory(_In_ DWORD dwMode, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: propbag.cpp:260
#define DSA_AppendItem(hdsa, pitem)
Definition: commctrl.h:4832
#define ICC_LINK_CLASS
Definition: commctrl.h:74
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
_In_opt_ IUnknown * punk
Definition: shlwapi.h:158
#define QITABENT(Cthis, Ifoo)
Definition: shlwapi.h:152
_In_ UINT cchBuf
Definition: shlwapi.h:378
_In_opt_ LPCSTR _In_opt_ LPCSTR pszValue
Definition: shlwapi.h:783
#define SW_SHOWNORMAL
Definition: winuser.h:781
#define MK_SHIFT
Definition: winuser.h:2405
#define MIIM_ID
Definition: winuser.h:733
int WINAPI GetMenuItemCount(_In_opt_ HMENU)
#define WS_EX_APPWINDOW
Definition: winuser.h:383
BOOL WINAPI GetClassInfoExW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _Out_ LPWNDCLASSEXW)
HWND WINAPI FindWindowExW(_In_opt_ HWND, _In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR)
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MIIM_SUBMENU
Definition: winuser.h:734
#define MK_CONTROL
Definition: winuser.h:2406
#define MF_BYPOSITION
Definition: winuser.h:203
BOOL WINAPI RemoveMenu(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define WS_EX_WINDOWEDGE
Definition: winuser.h:407
#define CW_USEDEFAULT
Definition: winuser.h:225
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
BOOL WINAPI DestroyMenu(_In_ HMENU)
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define SW_SHOW
Definition: winuser.h:786
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
#define REG_DWORD
Definition: sdbapi.c:615
int zero
Definition: sehframes.cpp:29
#define ALIAS_USER_FOLDER
Definition: shell32_main.h:119
#define ALIAS_DESKTOP
Definition: shell32_main.h:120
_In_ UINT _In_ UINT cch
Definition: shellapi.h:432
BOOL WINAPI LinkWindow_RegisterClass(void)
Definition: shellord.c:2809
VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
Definition: shellord.c:229
UINT WINAPI Shell_MergeMenus(HMENU hmDst, HMENU hmSrc, UINT uInsert, UINT uIDAdjust, UINT uIDAdjustMax, ULONG uFlags)
Definition: shlmenu.c:856
#define CSIDL_COMMON_DESKTOPDIRECTORY
Definition: shlobj.h:2215
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1536
#define CSIDL_DESKTOPDIRECTORY
Definition: shlobj.h:2206
#define CSIDL_PERSONAL
Definition: shlobj.h:2196
#define CSIDL_FLAG_NO_ALIAS
Definition: shlobj.h:2251
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2252
#define MM_SUBMENUSHAVEIDS
Definition: shlobj.h:2547
#define SSF_WEBVIEW
Definition: shlobj.h:1637
#define MM_DONTREMOVESEPS
Definition: shlobj.h:2548
#define CSIDL_DESKTOP
Definition: shlobj.h:2191
#define MM_ADDSEPARATOR
Definition: shlobj.h:2546
@ REST_ALLOWCOMMENTTOGGLE
Definition: shlobj.h:1888
#define CSIDL_COMMON_DOCUMENTS
Definition: shlobj.h:2236
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:166
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70
const ITEMIDLIST_RELATIVE UNALIGNED * PCUIDLIST_RELATIVE
Definition: shtypes.idl:57
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define _countof(array)
Definition: sndvol32.h:70
#define TRACE(s)
Definition: solgame.cpp:4
BOOLEAN WINAPI GetUserNameExW(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)
Definition: sspi.c:1079
TCHAR * cmdline
Definition: stretchblt.cpp:32
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
WORD CmdId
Definition: utils.h:89
LPCSTR Verb
Definition: utils.h:88
long y
Definition: dcommon.idl:24
long x
Definition: dcommon.idl:24
Definition: shlwapi.h:139
Definition: dcommon.idl:28
Definition: dsa.c:45
$ULONG PrivilegeCount
Definition: setypes.h:1035
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1036
$ULONG LowPart
Definition: ntbasedef.h:581
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:582
LPWSTR usri2_full_name
Definition: lmaccess.h:222
LPCWSTR lpszClassName
Definition: winuser.h:3334
Definition: match.c:390
Definition: inflate.c:139
BYTE bCommonDesktop
Definition: utils.cpp:2204
#define max(a, b)
Definition: svc.c:63
static unsigned int bufptr
Definition: tncon.cpp:77
uint16_t * PWSTR
Definition: typedefs.h:56
const char * LPCSTR
Definition: typedefs.h:52
int32_t INT_PTR
Definition: typedefs.h:64
uint32_t * PULONG
Definition: typedefs.h:59
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
const uint16_t * LPCWSTR
Definition: typedefs.h:57
uint16_t * LPWSTR
Definition: typedefs.h:56
int64_t LONGLONG
Definition: typedefs.h:68
uint16_t * LPWORD
Definition: typedefs.h:56
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * LPSTR
Definition: typedefs.h:51
int32_t INT
Definition: typedefs.h:58
const char * PCSTR
Definition: typedefs.h:52
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
#define FMT_USE_THOUSAND
Definition: undocshell.h:907
#define FMT_USE_GROUPING
Definition: undocshell.h:905
#define SHGCDN_NOSERVERNAME
Definition: undocshell.h:1070
#define FMT_USE_NUMDIGITS
Definition: undocshell.h:903
#define SHSTDAPI
Definition: undocshell.h:22
#define FMT_USE_NEGNUMBER
Definition: undocshell.h:908
#define FMT_USE_LEADZERO
Definition: undocshell.h:904
HRESULT(CALLBACK * PRIVILEGED_FUNCTION)(LPARAM lParam)
Definition: undocshell.h:936
#define SHGCDN_NOCACHE
Definition: undocshell.h:1069
#define FMT_USE_DECIMAL
Definition: undocshell.h:906
DWORD dwAttributes
Definition: vdmdbg.h:34
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2664
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
EXTERN_C HRESULT SHELL_GetShellExtensionRegCLSID(HKEY hKey, LPCWSTR KeyName, CLSID *pClsId)
Definition: propsheet.cpp:13
VOID WINAPI SwitchToThisWindow(HWND hwnd, BOOL fAltTab)
Definition: window.c:82
BOOL WINAPI AllowSetForegroundWindow(DWORD dwProcessId)
Definition: window.c:49
HWND WINAPI GetShellWindow(void)
Definition: input.c:974
_In_opt_ LPSTR _In_opt_ LPSTR _In_ DWORD _In_ DWORD _Out_opt_ PHANDLE phToken
Definition: winbase.h:2445
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LPCSTR lpFileName
Definition: winbase.h:2800
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:398
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1195
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:338
_In_ LPCSTR lpName
Definition: winbase.h:2519
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
#define INVALID_FILE_SIZE
Definition: winbase.h:528
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:401
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2497
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:268
WINBASEAPI _In_ DWORD nLength
Definition: wincon.h:682
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define ERROR_BAD_NETPATH
Definition: winerror.h:267
#define S_FALSE
Definition: winerror.h:3451
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210
#define ERROR_CLASS_ALREADY_EXISTS
Definition: winerror.h:1236
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:3437
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:228
#define ERROR_CANCELLED
Definition: winerror.h:1055
#define HRESULT_CODE(hr)
Definition: winerror.h:188
#define ERROR_NO_TOKEN
Definition: winerror.h:911
#define ERROR_BAD_NET_NAME
Definition: winerror.h:281
#define ERROR_NONE_MAPPED
Definition: winerror.h:1159
#define RESOURCETYPE_DISK
Definition: winnetwk.h:64
#define LOCALE_SGROUPING
Definition: winnls.h:54
#define LOCALE_SDECIMAL
Definition: winnls.h:52
#define LOCALE_IDIGITS
Definition: winnls.h:55
#define LOCALE_STHOUSAND
Definition: winnls.h:53
#define LOCALE_INEGNUMBER
Definition: winnls.h:57
#define LOCALE_ILZERO
Definition: winnls.h:56
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:427
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:304
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:942
#define TOKEN_QUERY
Definition: setypes.h:940
@ TokenPrivileges
Definition: setypes.h:980
@ TokenSessionId
Definition: setypes.h:989
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
unsigned char BYTE
Definition: xxhash.c:193