ReactOS 0.4.15-dev-7991-ge77da17
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 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8#include "precomp.h"
9
11
13{
14 if (pszPath[0] != L'.')
15 return FALSE;
16 return !pszPath[1] || (pszPath[1] == L'.' && !pszPath[2]);
17}
18
19#define PATH_VALID_ELEMENT ( \
20 PATH_CHAR_CLASS_DOT | PATH_CHAR_CLASS_SEMICOLON | PATH_CHAR_CLASS_COMMA | \
21 PATH_CHAR_CLASS_SPACE | PATH_CHAR_CLASS_OTHER_VALID \
22)
23
25{
26 if (!*pszPath || PathIsDotOrDotDotW(pszPath))
27 return FALSE;
28
29 for (LPCWSTR pch = pszPath; *pch; ++pch)
30 {
32 return FALSE;
33 }
34
35 return TRUE;
36}
37
39{
43
44 if (lstrcmpiW(szPath, L"NUL") == 0 || lstrcmpiW(szPath, L"PRN") == 0 ||
45 lstrcmpiW(szPath, L"CON") == 0 || lstrcmpiW(szPath, L"AUX") == 0)
46 {
47 return TRUE;
48 }
49
50 if (_wcsnicmp(szPath, L"LPT", 3) == 0 || _wcsnicmp(szPath, L"COM", 3) == 0)
51 {
52 if ((L'0' <= szPath[3] && szPath[3] <= L'9') && szPath[4] == UNICODE_NULL)
53 return TRUE;
54 }
55
56 return FALSE;
57}
58
60{
61 LPITEMIDLIST pidlOld = *ppidl;
62 if (!pidlOld)
63 {
64 *ppidl = pidl;
65 return S_OK;
66 }
67
68 HRESULT hr = SHILCombine(*ppidl, pidl, ppidl);
69 ILFree(pidlOld);
70 ILFree(pidl);
71 return hr;
72}
73
74static BOOL
78{
79 BOOL ret;
80
81 if (phToken == NULL)
82 {
84 return FALSE;
85 }
86
87 *phToken = NULL;
88
90 if (!ret && GetLastError() == ERROR_NO_TOKEN)
92
93 return ret;
94}
95
99 _In_ HANDLE hToken,
100 _Out_ LPITEMIDLIST *ppidlAlias,
102{
103 return E_FAIL; //FIXME
104}
105
107{
109 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam(const_cast<LPWSTR>(pszName), &punk)))
110 return FALSE;
111 return TRUE;
112}
113
115{
116 if (!pbc)
117 return dwDefault;
118
119 BIND_OPTS BindOpts = { sizeof(BindOpts) };
120 HRESULT hr = pbc->GetBindOptions(&BindOpts);
121 if (FAILED(hr))
122 return dwDefault;
123
124 return BindOpts.grfMode;
125}
126
128{
129 if (!pbc)
130 return FALSE;
131
132 BIND_OPTS BindOps = { sizeof(BindOps) };
133 if (SUCCEEDED(pbc->GetBindOptions(&BindOps)) && BindOps.grfFlags == OLECONTF_LINKS)
134 return TRUE;
135
136 return pclsid && SHSkipJunction(pbc, pclsid);
137}
138
140{
143
144 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam((LPWSTR)STR_FILE_SYS_BIND_DATA, &punk)))
145 return S_FALSE;
146
147 if (FAILED(punk->QueryInterface(IID_PPV_ARG(IFileSystemBindData, &pBindData))))
148 return S_FALSE;
149
150 if (pFindData)
151 pBindData->GetFindData(pFindData);
152
153 return S_OK;
154}
155
157{
159
160 switch (code)
161 {
164 case ERROR_CANCELLED:
165 return TRUE;
166
167 default:
169 }
170}
171
174 _In_opt_ IShellFolder *pShellFolder,
175 _In_ LPCITEMIDLIST pidl,
176 _In_opt_ IBindCtx *pBindCtx,
178 _Out_ void **ppvObj)
179{
180 CComPtr<IShellFolder> psfDesktop;
181
182 *ppvObj = NULL;
183
184 if (!pShellFolder)
185 {
186 SHGetDesktopFolder(&psfDesktop);
187 if (!psfDesktop)
188 return E_FAIL;
189
190 pShellFolder = psfDesktop;
191 }
192
193 HRESULT hr;
194 if (_ILIsDesktop(pidl))
195 hr = pShellFolder->QueryInterface(riid, ppvObj);
196 else
197 hr = pShellFolder->BindToObject(pidl, pBindCtx, riid, ppvObj);
198
199 if (SUCCEEDED(hr) && !*ppvObj)
200 hr = E_FAIL;
201
202 return hr;
203}
204
207 _In_ LPCITEMIDLIST pidl,
209 _Out_ void **ppvObj)
210{
211 return SHBindToObjectEx(psf, pidl, NULL, riid, ppvObj);
212}
213
216 _In_ IShellFolder *psf,
217 _In_ LPCITEMIDLIST pidl,
219 _Out_ LPWSTR pszBuf,
220 _In_ UINT cchBuf)
221{
222 *pszBuf = UNICODE_NULL;
223 STRRET sr;
224 HRESULT hr = psf->GetDisplayNameOf(pidl, dwFlags, &sr);
225 if (FAILED(hr))
226 return hr;
227 return StrRetToBufW(&sr, pidl, pszBuf, cchBuf);
228}
229
230DWORD
232{
233 LPCITEMIDLIST pidlLast;
234
235 if (psf)
236 {
237 psf->AddRef();
238 pidlLast = pidl;
239 }
240 else
241 {
242 SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlLast);
243 }
244
245 if (!psf)
246 return 0;
247
248 DWORD oldAttrs = dwAttributes;
249 if (FAILED(psf->GetAttributesOf(1, &pidlLast, &dwAttributes)))
250 dwAttributes = 0;
251 else
252 dwAttributes &= oldAttrs;
253
254 if ((dwAttributes & SFGAO_FOLDER) &&
255 (dwAttributes & SFGAO_STREAM) &&
256 !(dwAttributes & SFGAO_STORAGEANCESTOR) &&
257 (oldAttrs & SFGAO_STORAGEANCESTOR) &&
258 (SHGetObjectCompatFlags(psf, NULL) & 0x200))
259 {
260 dwAttributes &= ~(SFGAO_STREAM | SFGAO_STORAGEANCESTOR);
261 dwAttributes |= SFGAO_STORAGEANCESTOR;
262 }
263
264 if (psf)
265 psf->Release();
266
267 return dwAttributes;
268}
269
271{
273 if (FAILED(hr))
275 return hr;
276}
277
280 _In_ LPCITEMIDLIST pidl,
282 _Out_opt_ LPWSTR pszText,
283 _In_ UINT cchBuf,
284 _Inout_opt_ DWORD *pdwAttributes)
285{
286 if (pszText)
287 *pszText = UNICODE_NULL;
288
290
291 CComPtr<IShellFolder> psfFolder;
292 LPCITEMIDLIST ppidlLast;
293 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psfFolder), &ppidlLast);
294 if (SUCCEEDED(hr))
295 {
296 if (pszText)
297 hr = Shell_DisplayNameOf(psfFolder, ppidlLast, dwFlags, pszText, cchBuf);
298
299 if (SUCCEEDED(hr))
300 {
301 if (pdwAttributes)
302 *pdwAttributes = SHGetAttributes(psfFolder, ppidlLast, *pdwAttributes);
303 }
304 }
305
306 if (SUCCEEDED(hrCoInit))
308
309 return hr;
310}
311
314{
315 HWND hWnd = NULL;
316
318 if (pBindCtx && SUCCEEDED(pBindCtx->GetObjectParam((LPWSTR)L"UI During Binding", &punk)))
319 IUnknown_GetWindow(punk, &hWnd);
320
321 return hWnd;
322}
323
325{
326protected:
329
330public:
332 virtual ~CDummyOleWindow() { }
333
334 // IUnknown methods
336 {
337 static const QITAB c_tab[] =
338 {
340 { NULL }
341 };
342 return ::QISearch(this, c_tab, riid, ppvObj);
343 }
345 {
346 return ++m_cRefs;
347 }
349 {
350 if (--m_cRefs == 0)
351 {
352 delete this;
353 return 0;
354 }
355 return m_cRefs;
356 }
357
358 // IOleWindow methods
359 STDMETHODIMP GetWindow(HWND *phWnd) override
360 {
361 *phWnd = m_hWnd;
362 if (!m_hWnd)
363 return E_NOTIMPL;
364 return S_OK;
365 }
367 {
368 return E_NOTIMPL;
369 }
370};
371
374 _In_ IBindCtx *pBindCtx,
375 _In_ LPOLESTR pszKey,
376 _In_opt_ IUnknown *punk,
377 _Out_ LPBC *ppbc)
378{
379 HRESULT hr = S_OK;
381
382 *ppbc = pBindCtx;
383
384 if (pBindCtx)
385 {
386 pBindCtx->AddRef();
387 }
388 else
389 {
390 hr = CreateBindCtx(0, ppbc);
391 if (FAILED(hr))
392 return hr;
393 }
394
395 if (!punk)
396 punk = pUnknown = new CDummyOleWindow();
397
398 hr = (*ppbc)->RegisterObjectParam(pszKey, punk);
399
400 if (pUnknown)
401 pUnknown->Release();
402
403 if (FAILED(hr))
404 {
405 (*ppbc)->Release();
406 *ppbc = NULL;
407 }
408
409 return hr;
410}
411
412/*************************************************************************
413 * SHSetFolderPathA (SHELL32.231)
414 *
415 * @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shsetfolderpatha
416 */
420 _In_ INT csidl,
421 _In_ HANDLE hToken,
423 _In_ LPCSTR pszPath)
424{
425 TRACE("(%d, %p, 0x%X, %s)\n", csidl, hToken, dwFlags, debugstr_a(pszPath));
426 CStringW strPathW(pszPath);
427 return SHSetFolderPathW(csidl, hToken, dwFlags, strPathW);
428}
429
430/*************************************************************************
431 * PathIsSlowA (SHELL32.240)
432 *
433 * @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj/nf-shlobj-pathisslowa
434 */
438 _In_ LPCSTR pszFile,
439 _In_ DWORD dwAttr)
440{
441 TRACE("(%s, 0x%X)\n", debugstr_a(pszFile), dwAttr);
442 CStringW strFileW(pszFile);
443 return PathIsSlowW(strFileW, dwAttr);
444}
445
446/*************************************************************************
447 * ExtractIconResInfoA (SHELL32.221)
448 */
452 _In_ HANDLE hHandle,
454 _In_ WORD wIndex,
455 _Out_ LPWORD lpSize,
456 _Out_ LPHANDLE lpIcon)
457{
458 TRACE("(%p, %s, %u, %p, %p)\n", hHandle, debugstr_a(lpFileName), wIndex, lpSize, lpIcon);
459
460 if (!lpFileName)
461 return 0;
462
463 CStringW strFileNameW(lpFileName);
464 return ExtractIconResInfoW(hHandle, strFileNameW, wIndex, lpSize, lpIcon);
465}
466
467/*************************************************************************
468 * ShortSizeFormatW (SHELL32.204)
469 */
473 _In_ DWORD dwNumber,
474 _Out_writes_(0x8FFF) LPWSTR pszBuffer)
475{
476 TRACE("(%lu, %p)\n", dwNumber, pszBuffer);
477 return StrFormatByteSizeW(dwNumber, pszBuffer, 0x8FFF);
478}
479
480/*************************************************************************
481 * SHOpenEffectiveToken (SHELL32.235)
482 */
484{
485 TRACE("%p\n", phToken);
487}
488
489/*************************************************************************
490 * SHGetUserSessionId (SHELL32.248)
491 */
493{
494 DWORD dwSessionId, dwLength;
495 BOOL bOpenToken = FALSE;
496
497 TRACE("%p\n", hToken);
498
499 if (!hToken)
500 bOpenToken = SHOpenEffectiveToken(&hToken);
501
502 if (!hToken ||
503 !GetTokenInformation(hToken, TokenSessionId, &dwSessionId, sizeof(dwSessionId), &dwLength))
504 {
505 dwSessionId = 0;
506 }
507
508 if (bOpenToken)
509 CloseHandle(hToken);
510
511 return dwSessionId;
512}
513
514/*************************************************************************
515 * SHInvokePrivilegedFunctionW (SHELL32.246)
516 */
520 _In_ LPCWSTR pszName,
523{
524 TRACE("(%s %p %p)\n", debugstr_w(pszName), fn, lParam);
525
526 if (!pszName || !fn)
527 return E_INVALIDARG;
528
529 HANDLE hToken = NULL;
530 TOKEN_PRIVILEGES NewPriv, PrevPriv;
531 BOOL bAdjusted = FALSE;
532
533 if (SHOpenEffectiveToken(&hToken) &&
534 ::LookupPrivilegeValueW(NULL, pszName, &NewPriv.Privileges[0].Luid))
535 {
536 NewPriv.PrivilegeCount = 1;
538
539 DWORD dwReturnSize;
540 bAdjusted = ::AdjustTokenPrivileges(hToken, FALSE, &NewPriv,
541 sizeof(PrevPriv), &PrevPriv, &dwReturnSize);
542 }
543
544 HRESULT hr = fn(lParam);
545
546 if (bAdjusted)
547 ::AdjustTokenPrivileges(hToken, FALSE, &PrevPriv, 0, NULL, NULL);
548
549 if (hToken)
550 ::CloseHandle(hToken);
551
552 return hr;
553}
554
555/*************************************************************************
556 * SHTestTokenPrivilegeW (SHELL32.236)
557 *
558 * @see http://undoc.airesoft.co.uk/shell32.dll/SHTestTokenPrivilegeW.php
559 */
563 _In_opt_ HANDLE hToken,
565{
566 LUID Luid;
568 PTOKEN_PRIVILEGES pTokenPriv;
569 HANDLE hNewToken = NULL;
570 BOOL ret = FALSE;
571
572 TRACE("(%p, %s)\n", hToken, debugstr_w(lpName));
573
574 if (!lpName)
575 return FALSE;
576
577 if (!hToken)
578 {
579 if (!SHOpenEffectiveToken(&hNewToken))
580 goto Quit;
581
582 if (!hNewToken)
583 return FALSE;
584
585 hToken = hNewToken;
586 }
587
588 if (!LookupPrivilegeValueW(NULL, lpName, &Luid))
589 return FALSE;
590
591 dwLength = 0;
593 goto Quit;
594
596 if (!pTokenPriv)
597 goto Quit;
598
599 if (GetTokenInformation(hToken, TokenPrivileges, pTokenPriv, dwLength, &dwLength))
600 {
601 UINT iPriv, cPrivs;
602 cPrivs = pTokenPriv->PrivilegeCount;
603 for (iPriv = 0; !ret && iPriv < cPrivs; ++iPriv)
604 {
605 ret = RtlEqualLuid(&Luid, &pTokenPriv->Privileges[iPriv].Luid);
606 }
607 }
608
609 LocalFree(pTokenPriv);
610
611Quit:
612 if (hToken == hNewToken)
613 CloseHandle(hNewToken);
614
615 return ret;
616}
617
619{
621}
622
623/*************************************************************************
624 * IsSuspendAllowed (SHELL32.53)
625 */
627{
628 TRACE("()\n");
630}
631
632/*************************************************************************
633 * SHGetShellStyleHInstance (SHELL32.749)
634 */
636WINAPI
638{
641 HRESULT hr;
642 CStringW strShellStyle;
643
644 TRACE("SHGetShellStyleHInstance called\n");
645
646 /* First, attempt to load the shellstyle dll from the current active theme */
648 if (FAILED(hr))
649 goto DoDefault;
650
651 /* Strip the theme filename */
653
654 strShellStyle = szPath;
655 strShellStyle += L"\\Shell\\";
656 strShellStyle += szColorName;
657 strShellStyle += L"\\ShellStyle.dll";
658
660 if (hInst)
661 return hInst;
662
663 /* Otherwise, use the version stored in the System32 directory */
664DoDefault:
665 if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\System32\\ShellStyle.dll",
667 {
668 ERR("Expand failed\n");
669 return NULL;
670 }
672}
673
674/*************************************************************************
675 * SHCreatePropertyBag (SHELL32.715)
676 */
678WINAPI
680{
682}
683
684/*************************************************************************
685 * SheRemoveQuotesA (SHELL32.@)
686 */
688WINAPI
690{
691 PCHAR pch;
692
693 if (*psz == '"')
694 {
695 for (pch = psz + 1; *pch && *pch != '"'; ++pch)
696 {
697 *(pch - 1) = *pch;
698 }
699
700 if (*pch == '"')
701 *(pch - 1) = ANSI_NULL;
702 }
703
704 return psz;
705}
706
707/*************************************************************************
708 * SheRemoveQuotesW (SHELL32.@)
709 *
710 * ExtractAssociatedIconExW uses this function.
711 */
713WINAPI
715{
716 PWCHAR pch;
717
718 if (*psz == L'"')
719 {
720 for (pch = psz + 1; *pch && *pch != L'"'; ++pch)
721 {
722 *(pch - 1) = *pch;
723 }
724
725 if (*pch == L'"')
726 *(pch - 1) = UNICODE_NULL;
727 }
728
729 return psz;
730}
731
732/*************************************************************************
733 * SHFindComputer [SHELL32.91]
734 *
735 * Invokes the shell search in My Computer. Used in SHFindFiles.
736 * Two parameters are ignored.
737 */
739WINAPI
741{
742 UNREFERENCED_PARAMETER(pidlRoot);
743 UNREFERENCED_PARAMETER(pidlSavedSearch);
744
745 TRACE("%p %p\n", pidlRoot, pidlSavedSearch);
746
747 IContextMenu *pCM;
748 HRESULT hr = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
749 IID_IContextMenu, (void **)&pCM);
750 if (FAILED(hr))
751 {
752 ERR("0x%08X\n", hr);
753 return hr;
754 }
755
756 CMINVOKECOMMANDINFO InvokeInfo = { sizeof(InvokeInfo) };
757 InvokeInfo.lpParameters = "{996E1EB1-B524-11D1-9120-00A0C98BA67D}";
758 InvokeInfo.nShow = SW_SHOWNORMAL;
759 hr = pCM->InvokeCommand(&InvokeInfo);
760 pCM->Release();
761
762 return SUCCEEDED(hr);
763}
764
765static HRESULT
767 _In_ LONGLONG llValue,
768 _Out_writes_(cchValue) LPWSTR pszValue,
769 _In_ UINT cchValue)
770{
771 WCHAR szBuff[40];
772 UINT ich = 0, ichValue;
773#if (WINVER >= _WIN32_WINNT_VISTA)
774 BOOL bMinus = (llValue < 0);
775
776 if (bMinus)
777 llValue = -llValue;
778#endif
779
780 if (cchValue <= 0)
781 return E_FAIL;
782
783 do
784 {
785 szBuff[ich++] = (WCHAR)(L'0' + (llValue % 10));
786 llValue /= 10;
787 } while (llValue != 0 && ich < _countof(szBuff) - 1);
788
789#if (WINVER >= _WIN32_WINNT_VISTA)
790 if (bMinus && ich < _countof(szBuff))
791 szBuff[ich++] = '-';
792#endif
793
794 for (ichValue = 0; ich > 0 && ichValue < cchValue; ++ichValue)
795 {
796 --ich;
797 pszValue[ichValue] = szBuff[ich];
798 }
799
800 if (ichValue >= cchValue)
801 {
802 pszValue[cchValue - 1] = UNICODE_NULL;
803 return E_FAIL;
804 }
805
806 pszValue[ichValue] = UNICODE_NULL;
807 return S_OK;
808}
809
810static VOID
812 _Out_ NUMBERFMTW *pDest,
813 _In_opt_ const NUMBERFMTW *pSrc,
814 _In_ DWORD dwNumberFlags,
815 _Out_writes_(cchDecimal) LPWSTR pszDecimal,
816 _In_ INT cchDecimal,
817 _Out_writes_(cchThousand) LPWSTR pszThousand,
818 _In_ INT cchThousand)
819{
820 WCHAR szBuff[20];
821
822 if (pSrc)
823 *pDest = *pSrc;
824 else
825 dwNumberFlags = 0;
826
827 if (!(dwNumberFlags & FMT_USE_NUMDIGITS))
828 {
830 pDest->NumDigits = StrToIntW(szBuff);
831 }
832
833 if (!(dwNumberFlags & FMT_USE_LEADZERO))
834 {
836 pDest->LeadingZero = StrToIntW(szBuff);
837 }
838
839 if (!(dwNumberFlags & FMT_USE_GROUPING))
840 {
842 pDest->Grouping = StrToIntW(szBuff);
843 }
844
845 if (!(dwNumberFlags & FMT_USE_DECIMAL))
846 {
847 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, pszDecimal, cchDecimal);
848 pDest->lpDecimalSep = pszDecimal;
849 }
850
851 if (!(dwNumberFlags & FMT_USE_THOUSAND))
852 {
853 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, pszThousand, cchThousand);
854 pDest->lpThousandSep = pszThousand;
855 }
856
857 if (!(dwNumberFlags & FMT_USE_NEGNUMBER))
858 {
860 pDest->NegativeOrder = StrToIntW(szBuff);
861 }
862}
863
864/*************************************************************************
865 * Int64ToString [SHELL32.209]
866 *
867 * @see http://undoc.airesoft.co.uk/shell32.dll/Int64ToString.php
868 */
872 _In_ LONGLONG llValue,
873 _Out_writes_(cchOut) LPWSTR pszOut,
874 _In_ UINT cchOut,
875 _In_ BOOL bUseFormat,
876 _In_opt_ const NUMBERFMTW *pNumberFormat,
877 _In_ DWORD dwNumberFlags)
878{
879 INT ret;
880 NUMBERFMTW NumFormat;
881 WCHAR szValue[80], szDecimalSep[6], szThousandSep[6];
882
883 Int64ToStr(llValue, szValue, _countof(szValue));
884
885 if (bUseFormat)
886 {
887 Int64GetNumFormat(&NumFormat, pNumberFormat, dwNumberFlags,
888 szDecimalSep, _countof(szDecimalSep),
889 szThousandSep, _countof(szThousandSep));
890 ret = GetNumberFormatW(LOCALE_USER_DEFAULT, 0, szValue, &NumFormat, pszOut, cchOut);
891 if (ret)
892 --ret;
893 return ret;
894 }
895
896 if (FAILED(StringCchCopyW(pszOut, cchOut, szValue)))
897 return 0;
898
899 return lstrlenW(pszOut);
900}
901
902/*************************************************************************
903 * LargeIntegerToString [SHELL32.210]
904 *
905 * @see http://undoc.airesoft.co.uk/shell32.dll/LargeIntegerToString.php
906 */
910 _In_ const LARGE_INTEGER *pLargeInt,
911 _Out_writes_(cchOut) LPWSTR pszOut,
912 _In_ UINT cchOut,
913 _In_ BOOL bUseFormat,
914 _In_opt_ const NUMBERFMTW *pNumberFormat,
915 _In_ DWORD dwNumberFlags)
916{
917 return Int64ToString(pLargeInt->QuadPart, pszOut, cchOut, bUseFormat,
918 pNumberFormat, dwNumberFlags);
919}
920
921/*************************************************************************
922 * CopyStreamUI [SHELL32.726]
923 *
924 * Copy a stream to another stream with optional progress display.
925 */
929 _In_ IStream *pSrc,
930 _Out_ IStream *pDst,
931 _Inout_opt_ IProgressDialog *pProgress,
932 _In_opt_ DWORDLONG dwlSize)
933{
934 HRESULT hr = E_FAIL;
935 DWORD cbBuff, cbRead, dwSizeToWrite;
936 DWORDLONG cbDone;
937 LPVOID pBuff;
938 CComHeapPtr<BYTE> pHeapPtr;
939 STATSTG Stat;
940 BYTE abBuff[1024];
941
942 TRACE("(%p, %p, %p, %I64u)\n", pSrc, pDst, pProgress, dwlSize);
943
944 if (dwlSize == 0) // Invalid size?
945 {
946 // Get the stream size
947 ZeroMemory(&Stat, sizeof(Stat));
948 if (FAILED(pSrc->Stat(&Stat, STATFLAG_NONAME)))
949 pProgress = NULL; // No size info. Disable progress
950 else
951 dwlSize = Stat.cbSize.QuadPart;
952 }
953
954 if (!pProgress) // Progress is disabled?
955 {
956 ULARGE_INTEGER uliSize;
957
958 if (dwlSize > 0)
959 uliSize.QuadPart = dwlSize;
960 else
961 uliSize.HighPart = uliSize.LowPart = INVALID_FILE_SIZE;
962
963 return pSrc->CopyTo(pDst, uliSize, NULL, NULL); // One punch
964 }
965
966 // Allocate the buffer if necessary
967 if (dwlSize > 0 && dwlSize <= sizeof(abBuff))
968 {
969 cbBuff = sizeof(abBuff);
970 pBuff = abBuff;
971 }
972 else
973 {
974#define COPY_STREAM_DEFAULT_BUFFER_SIZE 0x4000
976 if (pHeapPtr.AllocateBytes(cbBuff))
977 {
978 pBuff = pHeapPtr;
979 }
980 else // Low memory?
981 {
982 cbBuff = sizeof(abBuff);
983 pBuff = abBuff;
984 }
985#undef COPY_STREAM_DEFAULT_BUFFER_SIZE
986 }
987
988 // Start reading
990 zero.QuadPart = 0;
991 pSrc->Seek(zero, 0, NULL);
992 pDst->Seek(zero, 0, NULL);
993 cbDone = 0;
994 pProgress->SetProgress64(cbDone, dwlSize);
995
996 // Repeat reading and writing until goal
997 for (;;)
998 {
999 hr = pSrc->Read(pBuff, cbBuff, &cbRead);
1000 if (FAILED(hr))
1001 break;
1002
1003 // Calculate the size to write
1004 if (dwlSize > 0)
1005 dwSizeToWrite = (DWORD)min((DWORDLONG)(dwlSize - cbDone), (DWORDLONG)cbRead);
1006 else
1007 dwSizeToWrite = cbRead;
1008
1009 if (dwSizeToWrite == 0) // No need to write?
1010 {
1011 hr = S_OK;
1012 break;
1013 }
1014
1015 hr = pDst->Write(pBuff, dwSizeToWrite, NULL);
1016 if (hr != S_OK)
1017 break;
1018
1019 cbDone += dwSizeToWrite;
1020
1021 if (pProgress->HasUserCancelled()) // Cancelled?
1022 {
1024 break;
1025 }
1026 pProgress->SetProgress64(cbDone, dwlSize);
1027
1028 if (dwlSize > 0 && cbDone >= dwlSize) // Reached the goal?
1029 {
1030 hr = S_OK;
1031 break;
1032 }
1033 }
1034
1035 return hr;
1036}
1037
1038/*************************************************************************
1039 * SHOpenPropSheetA [SHELL32.707]
1040 *
1041 * @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj/nf-shlobj-shopenpropsheeta
1042 */
1046 _In_opt_ LPCSTR pszCaption,
1047 _In_opt_ HKEY *ahKeys,
1048 _In_ UINT cKeys,
1049 _In_ const CLSID *pclsidDefault,
1050 _In_ IDataObject *pDataObject,
1051 _In_opt_ IShellBrowser *pShellBrowser,
1052 _In_opt_ LPCSTR pszStartPage)
1053{
1054 CStringW strStartPageW, strCaptionW;
1055 LPCWSTR pszCaptionW = NULL, pszStartPageW = NULL;
1056
1057 TRACE("(%s, %p, %u, %p, %p, %p, %s)", debugstr_a(pszCaption), ahKeys, cKeys, pclsidDefault,
1058 pDataObject, pShellBrowser, debugstr_a(pszStartPage));
1059
1060 if (pszCaption)
1061 {
1062 strStartPageW = pszCaption;
1063 pszCaptionW = strCaptionW;
1064 }
1065
1066 if (pszStartPage)
1067 {
1068 strStartPageW = pszStartPage;
1069 pszStartPageW = strStartPageW;
1070 }
1071
1072 return SHOpenPropSheetW(pszCaptionW, ahKeys, cKeys, pclsidDefault,
1073 pDataObject, pShellBrowser, pszStartPageW);
1074}
1075
1076/*************************************************************************
1077 * Activate_RunDLL [SHELL32.105]
1078 *
1079 * Unlocks the foreground window and allows the shell window to become the
1080 * foreground window. Every parameter is unused.
1081 */
1085 _In_ HWND hwnd,
1088 _In_ INT cmdshow)
1089{
1090 DWORD dwProcessID;
1091
1095 UNREFERENCED_PARAMETER(cmdshow);
1096
1097 TRACE("(%p, %p, %s, %d)\n", hwnd, hinst, debugstr_w(cmdline), cmdline);
1098
1100 return AllowSetForegroundWindow(dwProcessID);
1101}
1102
1103/*************************************************************************
1104 * SHStartNetConnectionDialogA (SHELL32.12)
1105 *
1106 * @see https://learn.microsoft.com/en-us/windows/win32/api/shlobj_core/nf-shlobj_core-shstartnetconnectiondialoga
1107 */
1111 _In_ HWND hwnd,
1112 _In_ LPCSTR pszRemoteName,
1113 _In_ DWORD dwType)
1114{
1115 LPCWSTR pszRemoteNameW = NULL;
1116 CStringW strRemoteNameW;
1117
1118 TRACE("(%p, %s, %lu)\n", hwnd, debugstr_a(pszRemoteName), dwType);
1119
1120 if (pszRemoteName)
1121 {
1122 strRemoteNameW = pszRemoteName;
1123 pszRemoteNameW = strRemoteNameW;
1124 }
1125
1126 return SHStartNetConnectionDialogW(hwnd, pszRemoteNameW, dwType);
1127}
1128
1129/*************************************************************************
1130 * Helper functions for PathIsEqualOrSubFolder
1131 */
1132
1133static INT
1135 _In_ LPCWSTR lpszPath1,
1136 _In_ LPCWSTR lpszPath2,
1137 _Out_ CStringW& strPath)
1138{
1139 SIZE_T cchPath1 = wcslen(lpszPath1);
1140 SIZE_T cchPath2 = wcslen(lpszPath2);
1141 LPWSTR lpszPath = strPath.GetBuffer((INT)max(cchPath1, cchPath2) + 16);
1142 INT ret = PathCommonPrefixW(lpszPath1, lpszPath2, lpszPath);
1143 strPath.ReleaseBuffer();
1144 return ret;
1145}
1146
1149
1150static HRESULT
1152 _In_ LPCITEMIDLIST pidl,
1153 _Out_ CStringW& strPath)
1154{
1155 HRESULT hr;
1156
1157 for (UINT cchPath = MAX_PATH;; cchPath *= 2)
1158 {
1159 LPWSTR lpszPath = strPath.GetBuffer(cchPath);
1160 if (!lpszPath)
1161 return E_OUTOFMEMORY;
1162
1163 hr = SHGetPathCchFromIDListW(pidl, lpszPath, cchPath);
1164 strPath.ReleaseBuffer();
1165
1167 break;
1168
1169 if (cchPath >= MAXUINT / 2)
1170 {
1171 hr = E_FAIL;
1172 break;
1173 }
1174 }
1175
1176 if (FAILED(hr))
1177 strPath.Empty();
1178
1179 return hr;
1180}
1181
1182static HRESULT
1184 _In_ HWND hwndOwner,
1185 _Out_ CStringW& strPath,
1186 _In_ INT nCSIDL,
1188{
1189 LPITEMIDLIST pidl;
1190 HRESULT hr = SHGetSpecialFolderLocation(hwndOwner, nCSIDL, &pidl);
1191 if (SUCCEEDED(hr))
1192 {
1193 hr = DynamicSHGetPathFromIDListW(pidl, strPath);
1194 CoTaskMemFree(pidl);
1195 }
1196
1197 if (FAILED(hr))
1198 strPath.Empty();
1199 else if (bCreate)
1200 CreateDirectoryW(strPath, NULL);
1201
1202 return hr;
1203}
1204
1205static VOID
1207 _Out_ CStringW& strPath)
1208{
1209 INT nLength = strPath.GetLength();
1210 if (nLength > 0 && strPath[nLength - 1] == L'\\')
1211 strPath = strPath.Left(nLength - 1);
1212}
1213
1214/*************************************************************************
1215 * PathIsEqualOrSubFolder (SHELL32.755)
1216 */
1220 _In_ LPCWSTR pszPath1OrCSIDL,
1221 _In_ LPCWSTR pszPath2)
1222{
1223 CStringW strCommon, strPath1;
1224
1225 TRACE("(%s %s)\n", debugstr_w(pszPath1OrCSIDL), debugstr_w(pszPath2));
1226
1227 if (IS_INTRESOURCE(pszPath1OrCSIDL))
1228 {
1230 NULL, strPath1, LOWORD(pszPath1OrCSIDL) | CSIDL_FLAG_DONT_VERIFY, FALSE);
1231 }
1232 else
1233 {
1234 strPath1 = pszPath1OrCSIDL;
1235 }
1236
1238
1239 if (!DynamicPathCommonPrefixW(strPath1, pszPath2, strCommon))
1240 return FALSE;
1241
1242 return strPath1.CompareNoCase(strCommon) == 0;
1243}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
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
#define EXTERN_C
Definition: basetyps.h:12
#define STDMETHODIMP
Definition: basetyps.h:43
#define ERR(fmt,...)
Definition: debug.h:110
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:743
STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj) override
Definition: utils.cpp:335
STDMETHODIMP GetWindow(HWND *phWnd) override
Definition: utils.cpp:359
STDMETHODIMP_(ULONG) Release() override
Definition: utils.cpp:348
STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode) override
Definition: utils.cpp:366
STDMETHODIMP_(ULONG) AddRef() override
Definition: utils.cpp:344
virtual ~CDummyOleWindow()
Definition: utils.cpp:332
bool AllocateBytes(_In_ size_t nBytes)
Definition: atlalloc.h:127
LPARAM lParam
Definition: combotst.c:139
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
BOOL WINAPI LookupPrivilegeValueW(LPCWSTR lpSystemName, LPCWSTR lpPrivilegeName, PLUID lpLuid)
Definition: misc.c:782
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
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:411
#define CloseHandle
Definition: compat.h:739
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define GetCurrentProcess()
Definition: compat.h:759
#define MAX_PATH
Definition: compat.h:34
#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:519
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
EXTERN_C WORD WINAPI ExtractIconResInfoW(_In_ HANDLE hHandle, _In_ LPCWSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
Definition: stubs.cpp:789
EXTERN_C HRESULT WINAPI SHSetFolderPathW(_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCWSTR pszPath)
Definition: stubs.cpp:864
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogW(_In_ HWND hwnd, _In_ LPCWSTR pszRemoteName, _In_ DWORD dwType)
Definition: stubs.cpp:596
BOOL WINAPI SHOpenPropSheetW(_In_opt_ LPCWSTR pszCaption, _In_opt_ HKEY *ahKeys, _In_ UINT cKeys, _In_ const CLSID *pclsidDefault, _In_ IDataObject *pDataObject, _In_opt_ IShellBrowser *pShellBrowser, _In_opt_ LPCWSTR pszStartPage)
Definition: stubs.cpp:197
EXTERN_C BOOL WINAPI PathIsSlowW(_In_ LPCWSTR pszFile, _In_ DWORD dwAttr)
Definition: stubs.cpp:912
EXTERN_C BOOL WINAPI SHOpenPropSheetA(_In_opt_ LPCSTR pszCaption, _In_opt_ HKEY *ahKeys, _In_ UINT cKeys, _In_ const CLSID *pclsidDefault, _In_ IDataObject *pDataObject, _In_opt_ IShellBrowser *pShellBrowser, _In_opt_ LPCSTR pszStartPage)
Definition: utils.cpp:1045
BOOL WINAPI IsSuspendAllowed(VOID)
Definition: utils.cpp:626
EXTERN_C HRESULT WINAPI SHGetPathCchFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, SIZE_T cchPathMax)
#define PATH_VALID_ELEMENT
Definition: utils.cpp:19
HRESULT Shell_DisplayNameOf(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_ LPWSTR pszBuf, _In_ UINT cchBuf)
Definition: utils.cpp:215
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:231
static VOID DynamicPathRemoveBackslashW(_Out_ CStringW &strPath)
Definition: utils.cpp:1206
EXTERN_C WORD WINAPI ExtractIconResInfoA(_In_ HANDLE hHandle, _In_ LPCSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
Definition: utils.cpp:451
HRESULT SHGetNameAndFlagsW(_In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_opt_ LPWSTR pszText, _In_ UINT cchBuf, _Inout_opt_ DWORD *pdwAttributes)
Definition: utils.cpp:279
EXTERN_C BOOL WINAPI PathIsEqualOrSubFolder(_In_ LPCWSTR pszPath1OrCSIDL, _In_ LPCWSTR pszPath2)
Definition: utils.cpp:1219
EXTERN_C DWORD WINAPI SHGetUserSessionId(_In_opt_ HANDLE hToken)
Definition: utils.cpp:492
#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:811
EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW(_In_opt_ HANDLE hToken, _In_ LPCWSTR lpName)
Definition: utils.cpp:562
DWORD BindCtx_GetMode(_In_ IBindCtx *pbc, _In_ DWORD dwDefault)
Definition: utils.cpp:114
HRESULT SHBindToObject(_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:205
EXTERN_C HRESULT WINAPI SHInvokePrivilegedFunctionW(_In_ LPCWSTR pszName, _In_ PRIVILEGED_FUNCTION fn, _In_opt_ LPARAM lParam)
Definition: utils.cpp:519
BOOL BindCtx_ContainsObject(_In_ IBindCtx *pBindCtx, _In_ LPCWSTR pszName)
Definition: utils.cpp:106
HRESULT SHIsFileSysBindCtx(_In_ IBindCtx *pBindCtx, _Out_opt_ WIN32_FIND_DATAW *pFindData)
Definition: utils.cpp:139
BOOL PathIsValidElement(_In_ LPCWSTR pszPath)
Definition: utils.cpp:24
EXTERN_C LPWSTR WINAPI ShortSizeFormatW(_In_ DWORD dwNumber, _Out_writes_(0x8FFF) LPWSTR pszBuffer)
Definition: utils.cpp:472
EXTERN_C LPSTR WINAPI SheRemoveQuotesA(LPSTR psz)
Definition: utils.cpp:689
BOOL Shell_FailForceReturn(_In_ HRESULT hr)
Definition: utils.cpp:156
static INT DynamicPathCommonPrefixW(_In_ LPCWSTR lpszPath1, _In_ LPCWSTR lpszPath2, _Out_ CStringW &strPath)
Definition: utils.cpp:1134
static HRESULT DynamicSHGetPathFromIDListW(_In_ LPCITEMIDLIST pidl, _Out_ CStringW &strPath)
Definition: utils.cpp:1151
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:871
EXTERN_C BOOL WINAPI Activate_RunDLL(_In_ HWND hwnd, _In_ HINSTANCE hinst, _In_ LPCWSTR cmdline, _In_ INT cmdshow)
Definition: utils.cpp:1084
EXTERN_C BOOL WINAPI PathIsSlowA(_In_ LPCSTR pszFile, _In_ DWORD dwAttr)
Definition: utils.cpp:437
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:909
EXTERN_C HINSTANCE WINAPI SHGetShellStyleHInstance(VOID)
Definition: utils.cpp:637
EXTERN_C HRESULT BindCtx_RegisterObjectParam(_In_ IBindCtx *pBindCtx, _In_ LPOLESTR pszKey, _In_opt_ IUnknown *punk, _Out_ LPBC *ppbc)
Definition: utils.cpp:373
EXTERN_C HRESULT WINAPI CopyStreamUI(_In_ IStream *pSrc, _Out_ IStream *pDst, _Inout_opt_ IProgressDialog *pProgress, _In_opt_ DWORDLONG dwlSize)
Definition: utils.cpp:928
static BOOL OpenEffectiveToken(_In_ DWORD DesiredAccess, _Out_ HANDLE *phToken)
Definition: utils.cpp:75
EXTERN_C BOOL WINAPI SHFindComputer(LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch)
Definition: utils.cpp:740
static HRESULT Int64ToStr(_In_ LONGLONG llValue, _Out_writes_(cchValue) LPWSTR pszValue, _In_ UINT cchValue)
Definition: utils.cpp:766
EXTERN_C LPWSTR WINAPI SheRemoveQuotesW(LPWSTR psz)
Definition: utils.cpp:714
EXTERN_C HRESULT WINAPI SHCreatePropertyBag(_In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:679
EXTERN_C HWND BindCtx_GetUIWindow(_In_ IBindCtx *pBindCtx)
Definition: utils.cpp:313
HRESULT SHBindToObjectEx(_In_opt_ IShellFolder *pShellFolder, _In_ LPCITEMIDLIST pidl, _In_opt_ IBindCtx *pBindCtx, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:173
EXTERN_C HRESULT WINAPI SHSetFolderPathA(_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCSTR pszPath)
Definition: utils.cpp:419
HRESULT Shell_TranslateIDListAlias(_In_ LPCITEMIDLIST pidl, _In_ HANDLE hToken, _Out_ LPITEMIDLIST *ppidlAlias, _In_ DWORD dwFlags)
Definition: utils.cpp:97
BOOL IsShutdownAllowed(VOID)
Definition: utils.cpp:618
BOOL SHSkipJunctionBinding(_In_ IBindCtx *pbc, _In_ CLSID *pclsid)
Definition: utils.cpp:127
BOOL PathIsDotOrDotDotW(_In_ LPCWSTR pszPath)
Definition: utils.cpp:12
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogA(_In_ HWND hwnd, _In_ LPCSTR pszRemoteName, _In_ DWORD dwType)
Definition: utils.cpp:1110
HRESULT SHILAppend(_Inout_ LPITEMIDLIST pidl, _Inout_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:59
EXTERN_C BOOL WINAPI SHOpenEffectiveToken(_Out_ LPHANDLE phToken)
Definition: utils.cpp:483
static HRESULT DynamicSHGetSpecialFolderPathW(_In_ HWND hwndOwner, _Out_ CStringW &strPath, _In_ INT nCSIDL, _In_ BOOL bCreate)
Definition: utils.cpp:1183
HRESULT SHCoInitializeAnyApartment(VOID)
Definition: utils.cpp:270
BOOL PathIsDosDevice(_In_ LPCWSTR pszName)
Definition: utils.cpp:38
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3225
DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
Definition: ordinal.c:6278
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1332
BOOL WINAPI SHSkipJunction(IBindCtx *pbc, const CLSID *pclsid)
Definition: ordinal.c:4558
int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPath)
Definition: path.c:2806
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
Definition: path.c:4419
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2388
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1530
HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars, LPWSTR pszColorBuff, int cchMaxColorChars, LPWSTR pszSizeBuff, int cchMaxSizeChars)
Definition: system.c:894
static const WCHAR szColorName[]
Definition: system.c:40
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
REFIID riid
Definition: atlbase.h:39
HRESULT InvokeCommand([in] LPCMINVOKECOMMANDINFO lpici)
ULONG AddRef()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
ULONG Release()
#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 GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1108
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1212
#define Stat
Definition: syshdrs.h:78
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define pch(ap)
Definition: match.c:418
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LPCWSTR szPath
Definition: env.c:37
static HINSTANCE hinst
Definition: edit.c:551
static LPOLESTR
Definition: stg_prop.c:27
#define min(a, b)
Definition: monoChain.cc:55
#define _Out_opt_
Definition: ms_sal.h:346
#define _Inout_
Definition: ms_sal.h:378
#define _Out_writes_(size)
Definition: ms_sal.h:348
#define _Inout_opt_
Definition: ms_sal.h:379
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define LOCALE_USER_DEFAULT
#define UNICODE_NULL
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define ANSI_NULL
#define L(x)
Definition: ntvdm.h:50
#define STGM_READWRITE
Definition: objbase.h:919
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
@ COINIT_DISABLE_OLE1DDE
Definition: objbase.h:280
interface IBindCtx * LPBC
Definition: objfwd.h:18
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556
#define LOWORD(l)
Definition: pedump.c:82
long LONG
Definition: pedump.c:60
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:938
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1361
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488
EXTERN_C HRESULT WINAPI SHCreatePropertyBagOnMemory(_In_ DWORD dwMode, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: propbag.cpp:254
#define REFIID
Definition: guiddef.h:118
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
int zero
Definition: sehframes.cpp:29
HRESULT hr
Definition: shlfolder.c:183
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1511
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2219
#define QITABENT(Cthis, Ifoo)
Definition: shlwapi.h:2094
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
#define _countof(array)
Definition: sndvol32.h:68
#define TRACE(s)
Definition: solgame.cpp:4
TCHAR * cmdline
Definition: stretchblt.cpp:32
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
$ULONG PrivilegeCount
Definition: setypes.h:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
$ULONG LowPart
Definition: ntbasedef.h:569
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:570
Definition: inflate.c:139
#define max(a, b)
Definition: svc.c:63
uint16_t * LPWORD
Definition: typedefs.h:56
int64_t LONGLONG
Definition: typedefs.h:68
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
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:745
#define FMT_USE_GROUPING
Definition: undocshell.h:743
#define FMT_USE_NUMDIGITS
Definition: undocshell.h:741
#define FMT_USE_NEGNUMBER
Definition: undocshell.h:746
#define FMT_USE_LEADZERO
Definition: undocshell.h:742
HRESULT(CALLBACK * PRIVILEGED_FUNCTION)(LPARAM lParam)
Definition: undocshell.h:774
#define FMT_USE_DECIMAL
Definition: undocshell.h:744
DWORD dwAttributes
Definition: vdmdbg.h:34
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
HWND WINAPI GetShellWindow(VOID)
Definition: desktop.c:651
BOOL WINAPI AllowSetForegroundWindow(DWORD dwProcessId)
Definition: window.c:49
#define ZeroMemory
Definition: winbase.h:1712
_In_opt_ LPSTR _In_opt_ LPSTR _In_ DWORD _In_ DWORD _Out_opt_ PHANDLE phToken
Definition: winbase.h:2715
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LPCSTR lpFileName
Definition: winbase.h:3071
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define LPTR
Definition: winbase.h:381
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342
_In_ LPCSTR lpName
Definition: winbase.h:2789
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
#define INVALID_FILE_SIZE
Definition: winbase.h:548
_In_ DWORD nLength
Definition: wincon.h:473
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
#define WINAPI
Definition: msvc.h:6
#define ERROR_BAD_NETPATH
Definition: winerror.h:145
#define S_FALSE
Definition: winerror.h:2357
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_CANCELLED
Definition: winerror.h:726
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define HRESULT_CODE(hr)
Definition: winerror.h:76
#define ERROR_NO_TOKEN
Definition: winerror.h:587
#define ERROR_BAD_NET_NAME
Definition: winerror.h:159
#define LOCALE_SGROUPING
Definition: winnls.h:44
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define LOCALE_IDIGITS
Definition: winnls.h:45
#define LOCALE_STHOUSAND
Definition: winnls.h:43
#define LOCALE_INEGNUMBER
Definition: winnls.h:47
#define LOCALE_ILZERO
Definition: winnls.h:46
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:384
#define SW_SHOWNORMAL
Definition: winuser.h:770
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928
@ TokenPrivileges
Definition: setypes.h:968
@ TokenSessionId
Definition: setypes.h:977
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63
#define IID_PPV_ARG(Itype, ppType)
const char * LPCSTR
Definition: xmlstorage.h:183
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
unsigned char BYTE
Definition: xxhash.c:193