ReactOS 0.4.15-dev-7928-g68a8619
utils.cpp File Reference
#include "precomp.h"
Include dependency graph for utils.cpp:

Go to the source code of this file.

Classes

class  CDummyOleWindow
 

Macros

#define PATH_VALID_ELEMENT
 
#define COPY_STREAM_DEFAULT_BUFFER_SIZE   0x4000
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
BOOL PathIsDotOrDotDotW (_In_ LPCWSTR pszPath)
 
BOOL PathIsValidElement (_In_ LPCWSTR pszPath)
 
BOOL PathIsDosDevice (_In_ LPCWSTR pszName)
 
HRESULT SHILAppend (_Inout_ LPITEMIDLIST pidl, _Inout_ LPITEMIDLIST *ppidl)
 
static BOOL OpenEffectiveToken (_In_ DWORD DesiredAccess, _Out_ HANDLE *phToken)
 
HRESULT Shell_TranslateIDListAlias (_In_ LPCITEMIDLIST pidl, _In_ HANDLE hToken, _Out_ LPITEMIDLIST *ppidlAlias, _In_ DWORD dwFlags)
 
BOOL BindCtx_ContainsObject (_In_ IBindCtx *pBindCtx, _In_ LPCWSTR pszName)
 
DWORD BindCtx_GetMode (_In_ IBindCtx *pbc, _In_ DWORD dwDefault)
 
BOOL SHSkipJunctionBinding (_In_ IBindCtx *pbc, _In_ CLSID *pclsid)
 
HRESULT SHIsFileSysBindCtx (_In_ IBindCtx *pBindCtx, _Out_opt_ WIN32_FIND_DATAW *pFindData)
 
BOOL Shell_FailForceReturn (_In_ HRESULT hr)
 
HRESULT SHBindToObjectEx (_In_opt_ IShellFolder *pShellFolder, _In_ LPCITEMIDLIST pidl, _In_opt_ IBindCtx *pBindCtx, _In_ REFIID riid, _Out_ void **ppvObj)
 
HRESULT SHBindToObject (_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ REFIID riid, _Out_ void **ppvObj)
 
HRESULT Shell_DisplayNameOf (_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_ LPWSTR pszBuf, _In_ UINT cchBuf)
 
DWORD SHGetAttributes (_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
 
HRESULT SHCoInitializeAnyApartment (VOID)
 
HRESULT SHGetNameAndFlagsW (_In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_opt_ LPWSTR pszText, _In_ UINT cchBuf, _Inout_opt_ DWORD *pdwAttributes)
 
EXTERN_C HWND BindCtx_GetUIWindow (_In_ IBindCtx *pBindCtx)
 
EXTERN_C HRESULT BindCtx_RegisterObjectParam (_In_ IBindCtx *pBindCtx, _In_ LPOLESTR pszKey, _In_opt_ IUnknown *punk, _Out_ LPBC *ppbc)
 
EXTERN_C HRESULT WINAPI SHSetFolderPathA (_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCSTR pszPath)
 
EXTERN_C BOOL WINAPI PathIsSlowA (_In_ LPCSTR pszFile, _In_ DWORD dwAttr)
 
EXTERN_C WORD WINAPI ExtractIconResInfoA (_In_ HANDLE hHandle, _In_ LPCSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
 
EXTERN_C LPWSTR WINAPI ShortSizeFormatW (_In_ DWORD dwNumber, _Out_writes_(0x8FFF) LPWSTR pszBuffer)
 
EXTERN_C BOOL WINAPI SHOpenEffectiveToken (_Out_ LPHANDLE phToken)
 
EXTERN_C DWORD WINAPI SHGetUserSessionId (_In_opt_ HANDLE hToken)
 
EXTERN_C HRESULT WINAPI SHInvokePrivilegedFunctionW (_In_ LPCWSTR pszName, _In_ PRIVILEGED_FUNCTION fn, _In_opt_ LPARAM lParam)
 
EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW (_In_opt_ HANDLE hToken, _In_ LPCWSTR lpName)
 
BOOL IsShutdownAllowed (VOID)
 
BOOL WINAPI IsSuspendAllowed (VOID)
 
EXTERN_C HINSTANCE WINAPI SHGetShellStyleHInstance (VOID)
 
EXTERN_C HRESULT WINAPI SHCreatePropertyBag (_In_ REFIID riid, _Out_ void **ppvObj)
 
EXTERN_C LPSTR WINAPI SheRemoveQuotesA (LPSTR psz)
 
EXTERN_C LPWSTR WINAPI SheRemoveQuotesW (LPWSTR psz)
 
EXTERN_C BOOL WINAPI SHFindComputer (LPCITEMIDLIST pidlRoot, LPCITEMIDLIST pidlSavedSearch)
 
static HRESULT Int64ToStr (_In_ LONGLONG llValue, _Out_writes_(cchValue) LPWSTR pszValue, _In_ UINT cchValue)
 
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)
 
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)
 
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)
 
EXTERN_C HRESULT WINAPI CopyStreamUI (_In_ IStream *pSrc, _Out_ IStream *pDst, _Inout_opt_ IProgressDialog *pProgress, _In_opt_ DWORDLONG dwlSize)
 
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)
 
EXTERN_C BOOL WINAPI Activate_RunDLL (_In_ HWND hwnd, _In_ HINSTANCE hinst, _In_ LPCWSTR cmdline, _In_ INT cmdshow)
 
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogA (_In_ HWND hwnd, _In_ LPCSTR pszRemoteName, _In_ DWORD dwType)
 
static INT DynamicPathCommonPrefixW (_In_ LPCWSTR lpszPath1, _In_ LPCWSTR lpszPath2, _Out_ CStringW &strPath)
 
EXTERN_C HRESULT WINAPI SHGetPathCchFromIDListW (LPCITEMIDLIST pidl, LPWSTR pszPath, SIZE_T cchPathMax)
 
static HRESULT DynamicSHGetPathFromIDListW (_In_ LPCITEMIDLIST pidl, _Out_ CStringW &strPath)
 
static HRESULT DynamicSHGetSpecialFolderPathW (_In_ HWND hwndOwner, _Out_ CStringW &strPath, _In_ INT nCSIDL, _In_ BOOL bCreate)
 
static VOID DynamicPathRemoveBackslashW (_Out_ CStringW &strPath)
 
EXTERN_C BOOL WINAPI PathIsEqualOrSubFolder (_In_ LPCWSTR pszPath1OrCSIDL, _In_ LPCWSTR pszPath2)
 

Macro Definition Documentation

◆ COPY_STREAM_DEFAULT_BUFFER_SIZE

#define COPY_STREAM_DEFAULT_BUFFER_SIZE   0x4000

◆ PATH_VALID_ELEMENT

#define PATH_VALID_ELEMENT
Value:
( \
)
#define PATH_CHAR_CLASS_OTHER_VALID
Definition: path.c:4326
#define PATH_CHAR_CLASS_SPACE
Definition: path.c:4325
#define PATH_CHAR_CLASS_SEMICOLON
Definition: path.c:4323
#define PATH_CHAR_CLASS_COMMA
Definition: path.c:4324
#define PATH_CHAR_CLASS_DOT
Definition: path.c:4320

Definition at line 19 of file utils.cpp.

Function Documentation

◆ Activate_RunDLL()

EXTERN_C BOOL WINAPI Activate_RunDLL ( _In_ HWND  hwnd,
_In_ HINSTANCE  hinst,
_In_ LPCWSTR  cmdline,
_In_ INT  cmdshow 
)

Definition at line 1084 of file utils.cpp.

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}
unsigned long DWORD
Definition: ntddk_ex.h:95
#define debugstr_w
Definition: kernel32.h:32
static HINSTANCE hinst
Definition: edit.c:551
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define TRACE(s)
Definition: solgame.cpp:4
TCHAR * cmdline
Definition: stretchblt.cpp:32
HWND WINAPI GetShellWindow(VOID)
Definition: desktop.c:651
BOOL WINAPI AllowSetForegroundWindow(DWORD dwProcessId)
Definition: window.c:49
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ BindCtx_ContainsObject()

BOOL BindCtx_ContainsObject ( _In_ IBindCtx pBindCtx,
_In_ LPCWSTR  pszName 
)

Definition at line 106 of file utils.cpp.

107{
109 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam(const_cast<LPWSTR>(pszName), &punk)))
110 return FALSE;
111 return TRUE;
112}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define FAILED(hr)
Definition: intsafe.h:51
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CDesktopFolder::_ParseDisplayNameByParent(), CDesktopFolder::ParseDisplayName(), and CDesktopFolder::ShellUrlParseDisplayName().

◆ BindCtx_GetMode()

DWORD BindCtx_GetMode ( _In_ IBindCtx pbc,
_In_ DWORD  dwDefault 
)

Definition at line 114 of file utils.cpp.

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}
HRESULT hr
Definition: shlfolder.c:183

Referenced by CDrivesFolder::ParseDisplayName(), CFSFolder::ParseDisplayName(), and CRegFolder::ParseDisplayName().

◆ BindCtx_GetUIWindow()

EXTERN_C HWND BindCtx_GetUIWindow ( _In_ IBindCtx pBindCtx)

Definition at line 313 of file utils.cpp.

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}
HWND hWnd
Definition: settings.c:17
#define NULL
Definition: types.h:112
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1332
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define L(x)
Definition: ntvdm.h:50

Referenced by SHParseDisplayName().

◆ BindCtx_RegisterObjectParam()

EXTERN_C HRESULT BindCtx_RegisterObjectParam ( _In_ IBindCtx pBindCtx,
_In_ LPOLESTR  pszKey,
_In_opt_ IUnknown punk,
_Out_ LPBC ppbc 
)

Definition at line 373 of file utils.cpp.

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}
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
ULONG Release()
#define S_OK
Definition: intsafe.h:52
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556

Referenced by SHParseDisplayName().

◆ CopyStreamUI()

EXTERN_C HRESULT WINAPI CopyStreamUI ( _In_ IStream pSrc,
_Out_ IStream pDst,
_Inout_opt_ IProgressDialog *  pProgress,
_In_opt_ DWORDLONG  dwlSize 
)

Definition at line 928 of file utils.cpp.

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}
bool AllocateBytes(_In_ size_t nBytes)
Definition: atlalloc.h:127
#define E_FAIL
Definition: ddrawi.h:102
#define COPY_STREAM_DEFAULT_BUFFER_SIZE
unsigned long long DWORDLONG
Definition: intsafe.h:93
#define Stat
Definition: syshdrs.h:78
#define min(a, b)
Definition: monoChain.cc:55
#define DWORD
Definition: nt_native.h:44
int zero
Definition: sehframes.cpp:29
$ULONG LowPart
Definition: ntbasedef.h:569
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:570
#define ZeroMemory
Definition: winbase.h:1712
#define INVALID_FILE_SIZE
Definition: winbase.h:548
#define ERROR_CANCELLED
Definition: winerror.h:726
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
unsigned char BYTE
Definition: xxhash.c:193

◆ DynamicPathCommonPrefixW()

static INT DynamicPathCommonPrefixW ( _In_ LPCWSTR  lpszPath1,
_In_ LPCWSTR  lpszPath2,
_Out_ CStringW strPath 
)
static

Definition at line 1134 of file utils.cpp.

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}
int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPath)
Definition: path.c:2806
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define max(a, b)
Definition: svc.c:63
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
int ret

Referenced by PathIsEqualOrSubFolder().

◆ DynamicPathRemoveBackslashW()

static VOID DynamicPathRemoveBackslashW ( _Out_ CStringW strPath)
static

Definition at line 1206 of file utils.cpp.

1208{
1209 INT nLength = strPath.GetLength();
1210 if (nLength > 0 && strPath[nLength - 1] == L'\\')
1211 strPath = strPath.Left(nLength - 1);
1212}
_In_ DWORD nLength
Definition: wincon.h:473

Referenced by PathIsEqualOrSubFolder().

◆ DynamicSHGetPathFromIDListW()

static HRESULT DynamicSHGetPathFromIDListW ( _In_ LPCITEMIDLIST  pidl,
_Out_ CStringW strPath 
)
static

Definition at line 1151 of file utils.cpp.

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}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define MAX_PATH
Definition: compat.h:34
EXTERN_C HRESULT WINAPI SHGetPathCchFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath, SIZE_T cchPathMax)
unsigned int UINT
Definition: ndis.h:50
#define E_NOT_SUFFICIENT_BUFFER
Definition: winerror.h:2345

Referenced by DynamicSHGetSpecialFolderPathW().

◆ DynamicSHGetSpecialFolderPathW()

static HRESULT DynamicSHGetSpecialFolderPathW ( _In_ HWND  hwndOwner,
_Out_ CStringW strPath,
_In_ INT  nCSIDL,
_In_ BOOL  bCreate 
)
static

Definition at line 1183 of file utils.cpp.

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}
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
static HRESULT DynamicSHGetPathFromIDListW(_In_ LPCITEMIDLIST pidl, _Out_ CStringW &strPath)
Definition: utils.cpp:1151
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3225
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1511
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41

Referenced by PathIsEqualOrSubFolder().

◆ ExtractIconResInfoA()

EXTERN_C WORD WINAPI ExtractIconResInfoA ( _In_ HANDLE  hHandle,
_In_ LPCSTR  lpFileName,
_In_ WORD  wIndex,
_Out_ LPWORD  lpSize,
_Out_ LPHANDLE  lpIcon 
)

Definition at line 451 of file utils.cpp.

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}
EXTERN_C WORD WINAPI ExtractIconResInfoW(_In_ HANDLE hHandle, _In_ LPCWSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
Definition: stubs.cpp:789
#define debugstr_a
Definition: kernel32.h:31
_In_ LPCSTR lpFileName
Definition: winbase.h:3071

◆ Int64GetNumFormat()

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 
)
static

Definition at line 811 of file utils.cpp.

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}
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:411
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:1108
#define LOCALE_USER_DEFAULT
#define _countof(array)
Definition: sndvol32.h:68
#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
#define FMT_USE_DECIMAL
Definition: undocshell.h:744
#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
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by Int64ToString().

◆ Int64ToStr()

static HRESULT Int64ToStr ( _In_ LONGLONG  llValue,
_Out_writes_(cchValue) LPWSTR  pszValue,
_In_ UINT  cchValue 
)
static

Definition at line 766 of file utils.cpp.

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}
unsigned int BOOL
Definition: ntddk_ex.h:94
#define UNICODE_NULL

Referenced by Int64ToString().

◆ Int64ToString()

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 at line 871 of file utils.cpp.

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}
#define lstrlenW
Definition: compat.h:750
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
static HRESULT Int64ToStr(_In_ LONGLONG llValue, _Out_writes_(cchValue) LPWSTR pszValue, _In_ UINT cchValue)
Definition: utils.cpp:766
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1212
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149

Referenced by DoTestEntry(), LargeIntegerToString(), and Test_Int64ToString().

◆ IsShutdownAllowed()

BOOL IsShutdownAllowed ( VOID  )

Definition at line 618 of file utils.cpp.

619{
621}
EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW(_In_opt_ HANDLE hToken, _In_ LPCWSTR lpName)
Definition: utils.cpp:562
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:384

Referenced by IsSuspendAllowed().

◆ IsSuspendAllowed()

BOOL WINAPI IsSuspendAllowed ( VOID  )

Definition at line 626 of file utils.cpp.

627{
628 TRACE("()\n");
630}
BOOL IsShutdownAllowed(VOID)
Definition: utils.cpp:618
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488

◆ LargeIntegerToString()

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 at line 909 of file utils.cpp.

916{
917 return Int64ToString(pLargeInt->QuadPart, pszOut, cchOut, bUseFormat,
918 pNumberFormat, dwNumberFlags);
919}
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

Referenced by DoTestEntry(), and Test_LargeIntegerToString().

◆ OpenEffectiveToken()

static BOOL OpenEffectiveToken ( _In_ DWORD  DesiredAccess,
_Out_ HANDLE phToken 
)
static

Definition at line 75 of file utils.cpp.

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}
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
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define GetCurrentProcess()
Definition: compat.h:759
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_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
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148
#define ERROR_NO_TOKEN
Definition: winerror.h:587

Referenced by SHOpenEffectiveToken().

◆ PathIsDosDevice()

BOOL PathIsDosDevice ( _In_ LPCWSTR  pszName)

Definition at line 38 of file utils.cpp.

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}
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
LPCWSTR szPath
Definition: env.c:37
_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)

Referenced by CFSFolder::_CreateIDListFromName().

◆ PathIsDotOrDotDotW()

BOOL PathIsDotOrDotDotW ( _In_ LPCWSTR  pszPath)

Definition at line 12 of file utils.cpp.

13{
14 if (pszPath[0] != L'.')
15 return FALSE;
16 return !pszPath[1] || (pszPath[1] == L'.' && !pszPath[2]);
17}

Referenced by PathIsValidElement().

◆ PathIsEqualOrSubFolder()

EXTERN_C BOOL WINAPI PathIsEqualOrSubFolder ( _In_ LPCWSTR  pszPath1OrCSIDL,
_In_ LPCWSTR  pszPath2 
)

Definition at line 1219 of file utils.cpp.

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}
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:743
static VOID DynamicPathRemoveBackslashW(_Out_ CStringW &strPath)
Definition: utils.cpp:1206
static INT DynamicPathCommonPrefixW(_In_ LPCWSTR lpszPath1, _In_ LPCWSTR lpszPath2, _Out_ CStringW &strPath)
Definition: utils.cpp:1134
static HRESULT DynamicSHGetSpecialFolderPathW(_In_ HWND hwndOwner, _Out_ CStringW &strPath, _In_ INT nCSIDL, _In_ BOOL bCreate)
Definition: utils.cpp:1183
#define LOWORD(l)
Definition: pedump.c:82
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2219
#define IS_INTRESOURCE(i)
Definition: winuser.h:580

Referenced by PathIsTemporaryW(), and START_TEST().

◆ PathIsSlowA()

EXTERN_C BOOL WINAPI PathIsSlowA ( _In_ LPCSTR  pszFile,
_In_ DWORD  dwAttr 
)

Definition at line 437 of file utils.cpp.

440{
441 TRACE("(%s, 0x%X)\n", debugstr_a(pszFile), dwAttr);
442 CStringW strFileW(pszFile);
443 return PathIsSlowW(strFileW, dwAttr);
444}
EXTERN_C BOOL WINAPI PathIsSlowW(_In_ LPCWSTR pszFile, _In_ DWORD dwAttr)
Definition: stubs.cpp:912

◆ PathIsValidElement()

BOOL PathIsValidElement ( _In_ LPCWSTR  pszPath)

Definition at line 24 of file utils.cpp.

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}
#define PATH_VALID_ELEMENT
Definition: utils.cpp:19
BOOL PathIsDotOrDotDotW(_In_ LPCWSTR pszPath)
Definition: utils.cpp:12
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
Definition: path.c:4419
#define pch(ap)
Definition: match.c:418
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by Shell_NextElement().

◆ SHBindToObject()

HRESULT SHBindToObject ( _In_opt_ IShellFolder psf,
_In_ LPCITEMIDLIST  pidl,
_In_ REFIID  riid,
_Out_ void **  ppvObj 
)

Definition at line 205 of file utils.cpp.

210{
211 return SHBindToObjectEx(psf, pidl, NULL, riid, ppvObj);
212}
HRESULT SHBindToObjectEx(_In_opt_ IShellFolder *pShellFolder, _In_ LPCITEMIDLIST pidl, _In_opt_ IBindCtx *pBindCtx, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:173
REFIID riid
Definition: atlbase.h:39

Referenced by CDesktopFolder::_ParseDisplayNameByParent(), and CDesktopFolder::ShellUrlParseDisplayName().

◆ SHBindToObjectEx()

HRESULT SHBindToObjectEx ( _In_opt_ IShellFolder pShellFolder,
_In_ LPCITEMIDLIST  pidl,
_In_opt_ IBindCtx pBindCtx,
_In_ REFIID  riid,
_Out_ void **  ppvObj 
)

Definition at line 173 of file utils.cpp.

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}
BOOL _ILIsDesktop(LPCITEMIDLIST pidl)
Definition: CBandSite.h:24
HRESULT WINAPI SHGetDesktopFolder(IShellFolder **psf)
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)

Referenced by SHBindToObject().

◆ SHCoInitializeAnyApartment()

HRESULT SHCoInitializeAnyApartment ( VOID  )

Definition at line 270 of file utils.cpp.

271{
273 if (FAILED(hr))
275 return hr;
276}
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
@ COINIT_DISABLE_OLE1DDE
Definition: objbase.h:280

Referenced by SHGetNameAndFlagsW().

◆ SHCreatePropertyBag()

EXTERN_C HRESULT WINAPI SHCreatePropertyBag ( _In_ REFIID  riid,
_Out_ void **  ppvObj 
)

Definition at line 679 of file utils.cpp.

680{
682}
#define STGM_READWRITE
Definition: objbase.h:919
EXTERN_C HRESULT WINAPI SHCreatePropertyBagOnMemory(_In_ DWORD dwMode, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: propbag.cpp:254

◆ Shell_DisplayNameOf()

HRESULT Shell_DisplayNameOf ( _In_ IShellFolder psf,
_In_ LPCITEMIDLIST  pidl,
_In_ DWORD  dwFlags,
_Out_ LPWSTR  pszBuf,
_In_ UINT  cchBuf 
)

Definition at line 215 of file utils.cpp.

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}
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1530
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by SHGetNameAndFlagsW().

◆ Shell_FailForceReturn()

BOOL Shell_FailForceReturn ( _In_ HRESULT  hr)

Definition at line 156 of file utils.cpp.

157{
159
160 switch (code)
161 {
164 case ERROR_CANCELLED:
165 return TRUE;
166
167 default:
169 }
170}
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
Definition: inflate.c:139
#define ERROR_BAD_NETPATH
Definition: winerror.h:145
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define HRESULT_CODE(hr)
Definition: winerror.h:76
#define ERROR_BAD_NET_NAME
Definition: winerror.h:159

Referenced by CDesktopFolder::ParseDisplayName(), and CDesktopFolder::ShellUrlParseDisplayName().

◆ Shell_TranslateIDListAlias()

HRESULT Shell_TranslateIDListAlias ( _In_ LPCITEMIDLIST  pidl,
_In_ HANDLE  hToken,
_Out_ LPITEMIDLIST ppidlAlias,
_In_ DWORD  dwFlags 
)

Definition at line 97 of file utils.cpp.

102{
103 return E_FAIL; //FIXME
104}

Referenced by CDesktopFolder::ParseDisplayName().

◆ SheRemoveQuotesA()

EXTERN_C LPSTR WINAPI SheRemoveQuotesA ( LPSTR  psz)

Definition at line 689 of file utils.cpp.

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}
#define ANSI_NULL
char * PCHAR
Definition: typedefs.h:51

◆ SheRemoveQuotesW()

EXTERN_C LPWSTR WINAPI SheRemoveQuotesW ( LPWSTR  psz)

Definition at line 714 of file utils.cpp.

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}
uint16_t * PWCHAR
Definition: typedefs.h:56

◆ SHFindComputer()

EXTERN_C BOOL WINAPI SHFindComputer ( LPCITEMIDLIST  pidlRoot,
LPCITEMIDLIST  pidlSavedSearch 
)

Definition at line 740 of file utils.cpp.

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}
#define ERR(fmt,...)
Definition: debug.h:110
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT InvokeCommand([in] LPCMINVOKECOMMANDINFO lpici)
#define SW_SHOWNORMAL
Definition: winuser.h:770

Referenced by CTrayWindow::HandleCommand(), CTrayWindow::HandleHotKey(), and StartMenuHandler::ShowSearchComputer().

◆ SHGetAttributes()

DWORD SHGetAttributes ( _In_ IShellFolder psf,
_In_ LPCITEMIDLIST  pidl,
_In_ DWORD  dwAttributes 
)

Definition at line 231 of file utils.cpp.

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}
DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
Definition: ordinal.c:6278
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1361
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
DWORD dwAttributes
Definition: vdmdbg.h:34
#define IID_PPV_ARG(Itype, ppType)

Referenced by SHGetNameAndFlagsW().

◆ SHGetNameAndFlagsW()

HRESULT SHGetNameAndFlagsW ( _In_ LPCITEMIDLIST  pidl,
_In_ DWORD  dwFlags,
_Out_opt_ LPWSTR  pszText,
_In_ UINT  cchBuf,
_Inout_opt_ DWORD pdwAttributes 
)

Definition at line 279 of file utils.cpp.

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}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
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
HRESULT SHCoInitializeAnyApartment(VOID)
Definition: utils.cpp:270

Referenced by CDesktopFolder::ShellUrlParseDisplayName().

◆ SHGetPathCchFromIDListW()

EXTERN_C HRESULT WINAPI SHGetPathCchFromIDListW ( LPCITEMIDLIST  pidl,
LPWSTR  pszPath,
SIZE_T  cchPathMax 
)

◆ SHGetShellStyleHInstance()

EXTERN_C HINSTANCE WINAPI SHGetShellStyleHInstance ( VOID  )

Definition at line 637 of file utils.cpp.

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}
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
Definition: loader.c:288
BOOL WINAPI PathRemoveFileSpecW(LPWSTR lpszPath)
Definition: path.c:629
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
HINSTANCE hInst
Definition: dxdiag.c:13
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342

◆ SHGetUserSessionId()

EXTERN_C DWORD WINAPI SHGetUserSessionId ( _In_opt_ HANDLE  hToken)

Definition at line 492 of file utils.cpp.

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}
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
#define CloseHandle
Definition: compat.h:739
static DWORD DWORD * dwLength
Definition: fusion.c:86
EXTERN_C BOOL WINAPI SHOpenEffectiveToken(_Out_ LPHANDLE phToken)
Definition: utils.cpp:483
@ TokenSessionId
Definition: setypes.h:977

◆ SHILAppend()

HRESULT SHILAppend ( _Inout_ LPITEMIDLIST  pidl,
_Inout_ LPITEMIDLIST ppidl 
)

Definition at line 59 of file utils.cpp.

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}
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:938

Referenced by CFSFolder::_ParseSimple(), and CFSFolder::ParseDisplayName().

◆ SHInvokePrivilegedFunctionW()

EXTERN_C HRESULT WINAPI SHInvokePrivilegedFunctionW ( _In_ LPCWSTR  pszName,
_In_ PRIVILEGED_FUNCTION  fn,
_In_opt_ LPARAM  lParam 
)

Definition at line 519 of file utils.cpp.

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}
LPARAM lParam
Definition: combotst.c:139
#define E_INVALIDARG
Definition: ddrawi.h:101
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
$ULONG PrivilegeCount
Definition: setypes.h:1023
LUID_AND_ATTRIBUTES Privileges[ANYSIZE_ARRAY]
Definition: setypes.h:1024
static GLenum _GLUfuncptr fn
Definition: wgl_font.c:159
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

◆ SHIsFileSysBindCtx()

HRESULT SHIsFileSysBindCtx ( _In_ IBindCtx pBindCtx,
_Out_opt_ WIN32_FIND_DATAW pFindData 
)

Definition at line 139 of file utils.cpp.

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}
#define S_FALSE
Definition: winerror.h:2357

Referenced by CDesktopFolder::ParseDisplayName(), CDrivesFolder::ParseDisplayName(), and CFSFolder::ParseDisplayName().

◆ SHOpenEffectiveToken()

EXTERN_C BOOL WINAPI SHOpenEffectiveToken ( _Out_ LPHANDLE  phToken)

Definition at line 483 of file utils.cpp.

484{
485 TRACE("%p\n", phToken);
487}
static BOOL OpenEffectiveToken(_In_ DWORD DesiredAccess, _Out_ HANDLE *phToken)
Definition: utils.cpp:75
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:930
#define TOKEN_QUERY
Definition: setypes.h:928

Referenced by SHGetUserSessionId(), SHInvokePrivilegedFunctionW(), and SHTestTokenPrivilegeW().

◆ SHOpenPropSheetA()

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 at line 1045 of file utils.cpp.

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}
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

◆ ShortSizeFormatW()

EXTERN_C LPWSTR WINAPI ShortSizeFormatW ( _In_ DWORD  dwNumber,
_Out_writes_(0x8FFF) LPWSTR  pszBuffer 
)

Definition at line 472 of file utils.cpp.

475{
476 TRACE("(%lu, %p)\n", dwNumber, pszBuffer);
477 return StrFormatByteSizeW(dwNumber, pszBuffer, 0x8FFF);
478}
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2388

◆ SHSetFolderPathA()

EXTERN_C HRESULT WINAPI SHSetFolderPathA ( _In_ INT  csidl,
_In_ HANDLE  hToken,
_In_ DWORD  dwFlags,
_In_ LPCSTR  pszPath 
)

Definition at line 419 of file utils.cpp.

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}
EXTERN_C HRESULT WINAPI SHSetFolderPathW(_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCWSTR pszPath)
Definition: stubs.cpp:864

◆ SHSkipJunctionBinding()

BOOL SHSkipJunctionBinding ( _In_ IBindCtx pbc,
_In_ CLSID pclsid 
)

Definition at line 127 of file utils.cpp.

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}
BOOL WINAPI SHSkipJunction(IBindCtx *pbc, const CLSID *pclsid)
Definition: ordinal.c:4558

Referenced by CDesktopFolder::_ParseDisplayNameByParent().

◆ SHStartNetConnectionDialogA()

EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogA ( _In_ HWND  hwnd,
_In_ LPCSTR  pszRemoteName,
_In_ DWORD  dwType 
)

Definition at line 1110 of file utils.cpp.

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}
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogW(_In_ HWND hwnd, _In_ LPCWSTR pszRemoteName, _In_ DWORD dwType)
Definition: stubs.cpp:596

Referenced by SHStartNetConnectionDialog().

◆ SHTestTokenPrivilegeW()

EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW ( _In_opt_ HANDLE  hToken,
_In_ LPCWSTR  lpName 
)

Definition at line 562 of file utils.cpp.

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}
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define LPTR
Definition: winbase.h:381
_In_ LPCSTR lpName
Definition: winbase.h:2789
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301
@ TokenPrivileges
Definition: setypes.h:968
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES

Referenced by IsShutdownAllowed().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )