ReactOS 0.4.16-dev-329-g9223134
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)
 
HRESULT SHILClone (_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
 
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)
 
EXTERN_C 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 SHELL_GetIDListTarget (_In_ LPCITEMIDLIST pidl, _Out_ PIDLIST_ABSOLUTE *ppidl)
 
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)
 
EXTERN_C HRESULT WINAPI SHGetRealIDL (_In_ IShellFolder *psf, _In_ PCUITEMID_CHILD pidlSimple, _Outptr_ PITEMID_CHILD *ppidlReal)
 
EXTERN_C HRESULT IUnknown_InitializeCommand (_In_ IUnknown *pUnk, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB)
 
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)
 
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)
 
static HRESULT GetCommandStringA (_In_ IContextMenu *pCM, _In_ UINT_PTR Id, _In_ UINT GCS, _Out_writes_(cchMax) LPSTR Buf, _In_ UINT cchMax)
 
UINT GetDfmCmd (_In_ IContextMenu *pCM, _In_ LPCSTR verba)
 

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 66 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 1139 of file utils.cpp.

1144{
1145 DWORD dwProcessID;
1146
1150 UNREFERENCED_PARAMETER(cmdshow);
1151
1152 TRACE("(%p, %p, %s, %d)\n", hwnd, hinst, debugstr_w(cmdline), cmdline);
1153
1155 return AllowSetForegroundWindow(dwProcessID);
1156}
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:325
#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 153 of file utils.cpp.

154{
156 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam(const_cast<LPWSTR>(pszName), &punk)))
157 return FALSE;
158 return TRUE;
159}
#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 161 of file utils.cpp.

162{
163 if (!pbc)
164 return dwDefault;
165
166 BIND_OPTS BindOpts = { sizeof(BindOpts) };
167 HRESULT hr = pbc->GetBindOptions(&BindOpts);
168 if (FAILED(hr))
169 return dwDefault;
170
171 return BindOpts.grfMode;
172}
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 368 of file utils.cpp.

369{
370 HWND hWnd = NULL;
371
373 if (pBindCtx && SUCCEEDED(pBindCtx->GetObjectParam((LPWSTR)L"UI During Binding", &punk)))
374 IUnknown_GetWindow(punk, &hWnd);
375
376 return hWnd;
377}
HWND hWnd
Definition: settings.c:17
#define NULL
Definition: types.h:112
HRESULT WINAPI IUnknown_GetWindow(IUnknown *lpUnknown, HWND *lphWnd)
Definition: ordinal.c:1336
#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 428 of file utils.cpp.

433{
434 HRESULT hr = S_OK;
436
437 *ppbc = pBindCtx;
438
439 if (pBindCtx)
440 {
441 pBindCtx->AddRef();
442 }
443 else
444 {
445 hr = CreateBindCtx(0, ppbc);
446 if (FAILED(hr))
447 return hr;
448 }
449
450 if (!punk)
451 punk = pUnknown = new CDummyOleWindow();
452
453 hr = (*ppbc)->RegisterObjectParam(pszKey, punk);
454
455 if (pUnknown)
456 pUnknown->Release();
457
458 if (FAILED(hr))
459 {
460 (*ppbc)->Release();
461 *ppbc = NULL;
462 }
463
464 return hr;
465}
_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 983 of file utils.cpp.

988{
989 HRESULT hr = E_FAIL;
990 DWORD cbBuff, cbRead, dwSizeToWrite;
991 DWORDLONG cbDone;
992 LPVOID pBuff;
993 CComHeapPtr<BYTE> pHeapPtr;
994 STATSTG Stat;
995 BYTE abBuff[1024];
996
997 TRACE("(%p, %p, %p, %I64u)\n", pSrc, pDst, pProgress, dwlSize);
998
999 if (dwlSize == 0) // Invalid size?
1000 {
1001 // Get the stream size
1002 ZeroMemory(&Stat, sizeof(Stat));
1003 if (FAILED(pSrc->Stat(&Stat, STATFLAG_NONAME)))
1004 pProgress = NULL; // No size info. Disable progress
1005 else
1006 dwlSize = Stat.cbSize.QuadPart;
1007 }
1008
1009 if (!pProgress) // Progress is disabled?
1010 {
1011 ULARGE_INTEGER uliSize;
1012
1013 if (dwlSize > 0)
1014 uliSize.QuadPart = dwlSize;
1015 else
1016 uliSize.HighPart = uliSize.LowPart = INVALID_FILE_SIZE;
1017
1018 return pSrc->CopyTo(pDst, uliSize, NULL, NULL); // One punch
1019 }
1020
1021 // Allocate the buffer if necessary
1022 if (dwlSize > 0 && dwlSize <= sizeof(abBuff))
1023 {
1024 cbBuff = sizeof(abBuff);
1025 pBuff = abBuff;
1026 }
1027 else
1028 {
1029#define COPY_STREAM_DEFAULT_BUFFER_SIZE 0x4000
1031 if (pHeapPtr.AllocateBytes(cbBuff))
1032 {
1033 pBuff = pHeapPtr;
1034 }
1035 else // Low memory?
1036 {
1037 cbBuff = sizeof(abBuff);
1038 pBuff = abBuff;
1039 }
1040#undef COPY_STREAM_DEFAULT_BUFFER_SIZE
1041 }
1042
1043 // Start reading
1045 zero.QuadPart = 0;
1046 pSrc->Seek(zero, 0, NULL);
1047 pDst->Seek(zero, 0, NULL);
1048 cbDone = 0;
1049 pProgress->SetProgress64(cbDone, dwlSize);
1050
1051 // Repeat reading and writing until goal
1052 for (;;)
1053 {
1054 hr = pSrc->Read(pBuff, cbBuff, &cbRead);
1055 if (FAILED(hr))
1056 break;
1057
1058 // Calculate the size to write
1059 if (dwlSize > 0)
1060 dwSizeToWrite = (DWORD)min((DWORDLONG)(dwlSize - cbDone), (DWORDLONG)cbRead);
1061 else
1062 dwSizeToWrite = cbRead;
1063
1064 if (dwSizeToWrite == 0) // No need to write?
1065 {
1066 hr = S_OK;
1067 break;
1068 }
1069
1070 hr = pDst->Write(pBuff, dwSizeToWrite, NULL);
1071 if (hr != S_OK)
1072 break;
1073
1074 cbDone += dwSizeToWrite;
1075
1076 if (pProgress->HasUserCancelled()) // Cancelled?
1077 {
1079 break;
1080 }
1081 pProgress->SetProgress64(cbDone, dwlSize);
1082
1083 if (dwlSize > 0 && cbDone >= dwlSize) // Reached the goal?
1084 {
1085 hr = S_OK;
1086 break;
1087 }
1088 }
1089
1090 return hr;
1091}
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:577
ULONGLONG QuadPart
Definition: ms-dtyp.idl:185
$ULONG HighPart
Definition: ntbasedef.h:578
#define ZeroMemory
Definition: winbase.h:1737
#define INVALID_FILE_SIZE
Definition: winbase.h:574
#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 1189 of file utils.cpp.

1193{
1194 SIZE_T cchPath1 = wcslen(lpszPath1);
1195 SIZE_T cchPath2 = wcslen(lpszPath2);
1196 LPWSTR lpszPath = strPath.GetBuffer((INT)max(cchPath1, cchPath2) + 16);
1197 INT ret = PathCommonPrefixW(lpszPath1, lpszPath2, lpszPath);
1198 strPath.ReleaseBuffer();
1199 return ret;
1200}
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 1261 of file utils.cpp.

1263{
1264 INT nLength = strPath.GetLength();
1265 if (nLength > 0 && strPath[nLength - 1] == L'\\')
1266 strPath = strPath.Left(nLength - 1);
1267}
_In_ DWORD nLength
Definition: wincon.h:473

Referenced by PathIsEqualOrSubFolder().

◆ DynamicSHGetPathFromIDListW()

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

Definition at line 1206 of file utils.cpp.

1209{
1210 HRESULT hr;
1211
1212 for (UINT cchPath = MAX_PATH;; cchPath *= 2)
1213 {
1214 LPWSTR lpszPath = strPath.GetBuffer(cchPath);
1215 if (!lpszPath)
1216 return E_OUTOFMEMORY;
1217
1218 hr = SHGetPathCchFromIDListW(pidl, lpszPath, cchPath);
1219 strPath.ReleaseBuffer();
1220
1222 break;
1223
1224 if (cchPath >= MAXUINT / 2)
1225 {
1226 hr = E_FAIL;
1227 break;
1228 }
1229 }
1230
1231 if (FAILED(hr))
1232 strPath.Empty();
1233
1234 return hr;
1235}
#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 1238 of file utils.cpp.

1243{
1244 LPITEMIDLIST pidl;
1245 HRESULT hr = SHGetSpecialFolderLocation(hwndOwner, nCSIDL, &pidl);
1246 if (SUCCEEDED(hr))
1247 {
1248 hr = DynamicSHGetPathFromIDListW(pidl, strPath);
1249 CoTaskMemFree(pidl);
1250 }
1251
1252 if (FAILED(hr))
1253 strPath.Empty();
1254 else if (bCreate)
1255 CreateDirectoryW(strPath, NULL);
1256
1257 return hr;
1258}
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:1206
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3257
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1520
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 506 of file utils.cpp.

512{
513 TRACE("(%p, %s, %u, %p, %p)\n", hHandle, debugstr_a(lpFileName), wIndex, lpSize, lpIcon);
514
515 if (!lpFileName)
516 return 0;
517
518 CStringW strFileNameW(lpFileName);
519 return ExtractIconResInfoW(hHandle, strFileNameW, wIndex, lpSize, lpIcon);
520}
EXTERN_C WORD WINAPI ExtractIconResInfoW(_In_ HANDLE hHandle, _In_ LPCWSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
Definition: stubs.cpp:792
#define debugstr_a
Definition: kernel32.h:31
_In_ LPCSTR lpFileName
Definition: winbase.h:3096

◆ GetCommandStringA()

static HRESULT GetCommandStringA ( _In_ IContextMenu pCM,
_In_ UINT_PTR  Id,
_In_ UINT  GCS,
_Out_writes_(cchMax) LPSTR  Buf,
_In_ UINT  cchMax 
)
static

Definition at line 1407 of file utils.cpp.

1408{
1409 HRESULT hr = pCM->GetCommandString(Id, GCS & ~GCS_UNICODE, NULL, Buf, cchMax);
1410 if (FAILED(hr))
1411 {
1413 hr = pCM->GetCommandString(Id, GCS | GCS_UNICODE, NULL, (LPSTR)buf, _countof(buf));
1414 if (SUCCEEDED(hr))
1415 hr = SHUnicodeToAnsi(buf, Buf, cchMax) > 0 ? S_OK : E_FAIL;
1416 }
1417 return hr;
1418}
DWORD Id
UINT cchMax
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2797
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define _countof(array)
Definition: sndvol32.h:70
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by GetDfmCmd().

◆ GetDfmCmd()

UINT GetDfmCmd ( _In_ IContextMenu pCM,
_In_ LPCSTR  verba 
)

Definition at line 1421 of file utils.cpp.

1422{
1423 CHAR buf[MAX_PATH];
1424 if (IS_INTRESOURCE(verba))
1425 {
1426 if (FAILED(GetCommandStringA(pCM, LOWORD(verba), GCS_VERB, buf, _countof(buf))))
1427 return 0;
1428 verba = buf;
1429 }
1430 return MapVerbToDfmCmd(verba); // Returns DFM_CMD_* or 0
1431}
UINT MapVerbToDfmCmd(_In_ LPCSTR verba)
static HRESULT GetCommandStringA(_In_ IContextMenu *pCM, _In_ UINT_PTR Id, _In_ UINT GCS, _Out_writes_(cchMax) LPSTR Buf, _In_ UINT cchMax)
Definition: utils.cpp:1407
#define LOWORD(l)
Definition: pedump.c:82
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
char CHAR
Definition: xmlstorage.h:175

Referenced by BrFolder_OnContextMenu().

◆ 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 866 of file utils.cpp.

874{
875 WCHAR szBuff[20];
876
877 if (pSrc)
878 *pDest = *pSrc;
879 else
880 dwNumberFlags = 0;
881
882 if (!(dwNumberFlags & FMT_USE_NUMDIGITS))
883 {
885 pDest->NumDigits = StrToIntW(szBuff);
886 }
887
888 if (!(dwNumberFlags & FMT_USE_LEADZERO))
889 {
891 pDest->LeadingZero = StrToIntW(szBuff);
892 }
893
894 if (!(dwNumberFlags & FMT_USE_GROUPING))
895 {
897 pDest->Grouping = StrToIntW(szBuff);
898 }
899
900 if (!(dwNumberFlags & FMT_USE_DECIMAL))
901 {
902 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, pszDecimal, cchDecimal);
903 pDest->lpDecimalSep = pszDecimal;
904 }
905
906 if (!(dwNumberFlags & FMT_USE_THOUSAND))
907 {
908 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, pszThousand, cchThousand);
909 pDest->lpThousandSep = pszThousand;
910 }
911
912 if (!(dwNumberFlags & FMT_USE_NEGNUMBER))
913 {
915 pDest->NegativeOrder = StrToIntW(szBuff);
916 }
917}
INT WINAPI StrToIntW(LPCWSTR lpString)
Definition: string.c:407
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: locale.c:1666
#define LOCALE_USER_DEFAULT
#define FMT_USE_THOUSAND
Definition: undocshell.h:777
#define FMT_USE_GROUPING
Definition: undocshell.h:775
#define FMT_USE_NUMDIGITS
Definition: undocshell.h:773
#define FMT_USE_NEGNUMBER
Definition: undocshell.h:778
#define FMT_USE_LEADZERO
Definition: undocshell.h:774
#define FMT_USE_DECIMAL
Definition: undocshell.h:776
#define LOCALE_SGROUPING
Definition: winnls.h:46
#define LOCALE_SDECIMAL
Definition: winnls.h:44
#define LOCALE_IDIGITS
Definition: winnls.h:47
#define LOCALE_STHOUSAND
Definition: winnls.h:45
#define LOCALE_INEGNUMBER
Definition: winnls.h:49
#define LOCALE_ILZERO
Definition: winnls.h:48

Referenced by Int64ToString().

◆ Int64ToStr()

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

Definition at line 821 of file utils.cpp.

825{
826 WCHAR szBuff[40];
827 UINT ich = 0, ichValue;
828#if (WINVER >= _WIN32_WINNT_VISTA)
829 BOOL bMinus = (llValue < 0);
830
831 if (bMinus)
832 llValue = -llValue;
833#endif
834
835 if (cchValue <= 0)
836 return E_FAIL;
837
838 do
839 {
840 szBuff[ich++] = (WCHAR)(L'0' + (llValue % 10));
841 llValue /= 10;
842 } while (llValue != 0 && ich < _countof(szBuff) - 1);
843
844#if (WINVER >= _WIN32_WINNT_VISTA)
845 if (bMinus && ich < _countof(szBuff))
846 szBuff[ich++] = '-';
847#endif
848
849 for (ichValue = 0; ich > 0 && ichValue < cchValue; ++ichValue)
850 {
851 --ich;
852 pszValue[ichValue] = szBuff[ich];
853 }
854
855 if (ichValue >= cchValue)
856 {
857 pszValue[cchValue - 1] = UNICODE_NULL;
858 return E_FAIL;
859 }
860
861 pszValue[ichValue] = UNICODE_NULL;
862 return S_OK;
863}
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 926 of file utils.cpp.

933{
934 INT ret;
935 NUMBERFMTW NumFormat;
936 WCHAR szValue[80], szDecimalSep[6], szThousandSep[6];
937
938 Int64ToStr(llValue, szValue, _countof(szValue));
939
940 if (bUseFormat)
941 {
942 Int64GetNumFormat(&NumFormat, pNumberFormat, dwNumberFlags,
943 szDecimalSep, _countof(szDecimalSep),
944 szThousandSep, _countof(szThousandSep));
945 ret = GetNumberFormatW(LOCALE_USER_DEFAULT, 0, szValue, &NumFormat, pszOut, cchOut);
946 if (ret)
947 --ret;
948 return ret;
949 }
950
951 if (FAILED(StringCchCopyW(pszOut, cchOut, szValue)))
952 return 0;
953
954 return lstrlenW(pszOut);
955}
#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:866
static HRESULT Int64ToStr(_In_ LONGLONG llValue, _Out_writes_(cchValue) LPWSTR pszValue, _In_ UINT cchValue)
Definition: utils.cpp:821
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().

◆ InvokeIExecuteCommand()

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

1359{
1360 if (!pEC)
1361 return E_INVALIDARG;
1362
1363 if (pSite)
1364 IUnknown_SetSite(pEC, pSite);
1365 IUnknown_InitializeCommand(pEC, pszCommandName, pPB);
1366
1368 if (pSIA && SUCCEEDED(pEC->QueryInterface(IID_PPV_ARG(IObjectWithSelection, &pOWS))))
1369 pOWS->SetSelection(pSIA);
1370
1371 DWORD dwKeyState = 0, fMask = pICI ? pICI->fMask : 0;
1372 pEC->SetNoShowUI((fMask & CMIC_MASK_FLAG_NO_UI) != 0);
1373 pEC->SetShowWindow(pICI ? pICI->nShow : SW_SHOW);
1374 if (fMask & CMIC_MASK_SHIFT_DOWN)
1375 dwKeyState |= MK_SHIFT;
1376 if (fMask & CMIC_MASK_CONTROL_DOWN)
1377 dwKeyState |= MK_CONTROL;
1378 pEC->SetKeyState(dwKeyState);
1379 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpDirectoryW)
1380 pEC->SetDirectory(pICI->lpDirectoryW);
1381 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpParametersW)
1382 pEC->SetParameters(pICI->lpParametersW);
1383 if (fMask & CMIC_MASK_PTINVOKE)
1384 pEC->SetPosition(pICI->ptInvoke);
1385
1386 HRESULT hr = pEC->Execute();
1387 if (pSite)
1388 IUnknown_SetSite(pEC, NULL);
1389 return hr;
1390}
#define E_INVALIDARG
Definition: ddrawi.h:101
EXTERN_C HRESULT IUnknown_InitializeCommand(_In_ IUnknown *pUnk, _In_ PCWSTR pszCommandName, _In_opt_ IPropertyBag *pPB)
Definition: utils.cpp:1339
HRESULT WINAPI IUnknown_SetSite(IUnknown *obj, IUnknown *site)
Definition: ordinal.c:1411
#define MK_SHIFT
Definition: winuser.h:2372
#define MK_CONTROL
Definition: winuser.h:2373
#define SW_SHOW
Definition: winuser.h:778
#define IID_PPV_ARG(Itype, ppType)

Referenced by InvokeIExecuteCommandWithDataObject().

◆ InvokeIExecuteCommandWithDataObject()

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

1400{
1402 HRESULT hr = SHCreateShellItemArrayFromDataObject(pDO, IID_PPV_ARG(IShellItemArray, &pSIA));
1403 return SUCCEEDED(hr) ? InvokeIExecuteCommand(pEC, pszCommandName, pPB, pSIA, pICI, pSite) : hr;
1404}
EXTERN_C HRESULT WINAPI SHCreateShellItemArrayFromDataObject(_In_ IDataObject *pdo, _In_ REFIID riid, _Out_ void **ppv)
Definition: CShellItem.cpp:429
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:1352

Referenced by CDefaultContextMenu::InvokeRegVerb().

◆ IsShutdownAllowed()

BOOL IsShutdownAllowed ( VOID  )

Definition at line 673 of file utils.cpp.

674{
676}
EXTERN_C BOOL WINAPI SHTestTokenPrivilegeW(_In_opt_ HANDLE hToken, _In_ LPCWSTR lpName)
Definition: utils.cpp:617
#define SE_SHUTDOWN_NAME
Definition: winnt_old.h:413

Referenced by IsSuspendAllowed().

◆ IsSuspendAllowed()

BOOL WINAPI IsSuspendAllowed ( VOID  )

Definition at line 681 of file utils.cpp.

682{
683 TRACE("()\n");
685}
BOOL IsShutdownAllowed(VOID)
Definition: utils.cpp:673
BOOLEAN WINAPI IsPwrSuspendAllowed(VOID)
Definition: powrprof.c:488

◆ IUnknown_InitializeCommand()

EXTERN_C HRESULT IUnknown_InitializeCommand ( _In_ IUnknown pUnk,
_In_ PCWSTR  pszCommandName,
_In_opt_ IPropertyBag pPB 
)

Definition at line 1339 of file utils.cpp.

1343{
1344 HRESULT hr;
1346 if (SUCCEEDED(hr = pUnk->QueryInterface(IID_PPV_ARG(IInitializeCommand, &pIC))))
1347 hr = pIC->Initialize(pszCommandName, pPB);
1348 return hr;
1349}
static void *static void *static LPDIRECTPLAY IUnknown * pUnk
Definition: dplayx.c:30
nsresult QueryInterface(nsIIDRef riid, void **result)

Referenced by InvokeIExecuteCommand(), and CDefaultContextMenu::InvokeRegVerb().

◆ 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 964 of file utils.cpp.

971{
972 return Int64ToString(pLargeInt->QuadPart, pszOut, cchOut, bUseFormat,
973 pNumberFormat, dwNumberFlags);
974}
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:926

Referenced by DoTestEntry(), and Test_LargeIntegerToString().

◆ OpenEffectiveToken()

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

Definition at line 122 of file utils.cpp.

125{
126 BOOL ret;
127
128 if (phToken == NULL)
129 {
131 return FALSE;
132 }
133
134 *phToken = NULL;
135
137 if (!ret && GetLastError() == ERROR_NO_TOKEN)
139
140 return ret;
141}
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:2740
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 85 of file utils.cpp.

86{
90
91 if (lstrcmpiW(szPath, L"NUL") == 0 || lstrcmpiW(szPath, L"PRN") == 0 ||
92 lstrcmpiW(szPath, L"CON") == 0 || lstrcmpiW(szPath, L"AUX") == 0)
93 {
94 return TRUE;
95 }
96
97 if (_wcsnicmp(szPath, L"LPT", 3) == 0 || _wcsnicmp(szPath, L"COM", 3) == 0)
98 {
99 if ((L'0' <= szPath[3] && szPath[3] <= L'9') && szPath[4] == UNICODE_NULL)
100 return TRUE;
101 }
102
103 return FALSE;
104}
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4262
void WINAPI PathRemoveExtensionW(LPWSTR lpszPath)
Definition: path.c:823
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 59 of file utils.cpp.

60{
61 if (pszPath[0] != L'.')
62 return FALSE;
63 return !pszPath[1] || (pszPath[1] == L'.' && !pszPath[2]);
64}

Referenced by PathIsValidElement().

◆ PathIsEqualOrSubFolder()

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

Definition at line 1274 of file utils.cpp.

1277{
1278 CStringW strCommon, strPath1;
1279
1280 TRACE("(%s %s)\n", debugstr_w(pszPath1OrCSIDL), debugstr_w(pszPath2));
1281
1282 if (IS_INTRESOURCE(pszPath1OrCSIDL))
1283 {
1285 NULL, strPath1, LOWORD(pszPath1OrCSIDL) | CSIDL_FLAG_DONT_VERIFY, FALSE);
1286 }
1287 else
1288 {
1289 strPath1 = pszPath1OrCSIDL;
1290 }
1291
1293
1294 if (!DynamicPathCommonPrefixW(strPath1, pszPath2, strCommon))
1295 return FALSE;
1296
1297 return strPath1.CompareNoCase(strCommon) == 0;
1298}
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:743
static VOID DynamicPathRemoveBackslashW(_Out_ CStringW &strPath)
Definition: utils.cpp:1261
static INT DynamicPathCommonPrefixW(_In_ LPCWSTR lpszPath1, _In_ LPCWSTR lpszPath2, _Out_ CStringW &strPath)
Definition: utils.cpp:1189
static HRESULT DynamicSHGetSpecialFolderPathW(_In_ HWND hwndOwner, _Out_ CStringW &strPath, _In_ INT nCSIDL, _In_ BOOL bCreate)
Definition: utils.cpp:1238
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2234

Referenced by PathIsTemporaryW(), and START_TEST().

◆ PathIsSlowA()

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

Definition at line 492 of file utils.cpp.

495{
496 TRACE("(%s, 0x%X)\n", debugstr_a(pszFile), dwAttr);
497 CStringW strFileW(pszFile);
498 return PathIsSlowW(strFileW, dwAttr);
499}
EXTERN_C BOOL WINAPI PathIsSlowW(_In_ LPCWSTR pszFile, _In_ DWORD dwAttr)
Definition: stubs.cpp:915

◆ PathIsValidElement()

BOOL PathIsValidElement ( _In_ LPCWSTR  pszPath)

Definition at line 71 of file utils.cpp.

72{
73 if (!*pszPath || PathIsDotOrDotDotW(pszPath))
74 return FALSE;
75
76 for (LPCWSTR pch = pszPath; *pch; ++pch)
77 {
79 return FALSE;
80 }
81
82 return TRUE;
83}
#define PATH_VALID_ELEMENT
Definition: utils.cpp:66
BOOL PathIsDotOrDotDotW(_In_ LPCWSTR pszPath)
Definition: utils.cpp:59
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()

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

Definition at line 253 of file utils.cpp.

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

Referenced by _BindToObject(), CDesktopFolder::_ParseDisplayNameByParent(), BrFolder_InitTreeView(), CRegItemContextMenu_CreateInstance(), SHELL_GetIDListTarget(), Shell_ParsePrinterName(), 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 220 of file utils.cpp.

226{
227 CComPtr<IShellFolder> psfDesktop;
228
229 *ppvObj = NULL;
230
231 if (!pShellFolder)
232 {
233 SHGetDesktopFolder(&psfDesktop);
234 if (!psfDesktop)
235 return E_FAIL;
236
237 pShellFolder = psfDesktop;
238 }
239
240 HRESULT hr;
241 if (_ILIsDesktop(pidl))
242 hr = pShellFolder->QueryInterface(riid, ppvObj);
243 else
244 hr = pShellFolder->BindToObject(pidl, pBindCtx, riid, ppvObj);
245
246 if (SUCCEEDED(hr) && !*ppvObj)
247 hr = E_FAIL;
248
249 return hr;
250}
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 325 of file utils.cpp.

326{
328 if (FAILED(hr))
330 return hr;
331}
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 ShellExecuteExW(), and SHGetNameAndFlagsW().

◆ SHCreatePropertyBag()

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

Definition at line 734 of file utils.cpp.

735{
737}
#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 263 of file utils.cpp.

269{
270 *pszBuf = UNICODE_NULL;
271 STRRET sr;
272 HRESULT hr = psf->GetDisplayNameOf(pidl, dwFlags, &sr);
273 if (FAILED(hr))
274 return hr;
275 return StrRetToBufW(&sr, pidl, pszBuf, cchBuf);
276}
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 CFSDropTarget::_DoDrop(), and SHGetNameAndFlagsW().

◆ Shell_FailForceReturn()

BOOL Shell_FailForceReturn ( _In_ HRESULT  hr)

Definition at line 203 of file utils.cpp.

204{
206
207 switch (code)
208 {
211 case ERROR_CANCELLED:
212 return TRUE;
213
214 default:
216 }
217}
#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_GetIDListTarget()

HRESULT SHELL_GetIDListTarget ( _In_ LPCITEMIDLIST  pidl,
_Out_ PIDLIST_ABSOLUTE ppidl 
)

Definition at line 313 of file utils.cpp.

314{
315 IShellLink *pSL;
316 HRESULT hr = SHBindToObject(NULL, pidl, IID_PPV_ARG(IShellLink, &pSL));
317 if (SUCCEEDED(hr))
318 {
319 hr = pSL->GetIDList(ppidl); // Note: Returns S_FALSE if no target pidl
320 pSL->Release();
321 }
322 return hr;
323}
EXTERN_C HRESULT SHBindToObject(_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:253

Referenced by SHBrowseForFolderW().

◆ Shell_TranslateIDListAlias()

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

Definition at line 144 of file utils.cpp.

149{
150 return E_FAIL; //FIXME
151}

Referenced by CDesktopFolder::ParseDisplayName().

◆ SheRemoveQuotesA()

EXTERN_C LPSTR WINAPI SheRemoveQuotesA ( LPSTR  psz)

Definition at line 744 of file utils.cpp.

745{
746 PCHAR pch;
747
748 if (*psz == '"')
749 {
750 for (pch = psz + 1; *pch && *pch != '"'; ++pch)
751 {
752 *(pch - 1) = *pch;
753 }
754
755 if (*pch == '"')
756 *(pch - 1) = ANSI_NULL;
757 }
758
759 return psz;
760}
#define ANSI_NULL
char * PCHAR
Definition: typedefs.h:51

◆ SheRemoveQuotesW()

EXTERN_C LPWSTR WINAPI SheRemoveQuotesW ( LPWSTR  psz)

Definition at line 769 of file utils.cpp.

770{
771 PWCHAR pch;
772
773 if (*psz == L'"')
774 {
775 for (pch = psz + 1; *pch && *pch != L'"'; ++pch)
776 {
777 *(pch - 1) = *pch;
778 }
779
780 if (*pch == L'"')
781 *(pch - 1) = UNICODE_NULL;
782 }
783
784 return psz;
785}
uint16_t * PWCHAR
Definition: typedefs.h:56

◆ SHFindComputer()

EXTERN_C BOOL WINAPI SHFindComputer ( LPCITEMIDLIST  pidlRoot,
LPCITEMIDLIST  pidlSavedSearch 
)

Definition at line 795 of file utils.cpp.

796{
797 UNREFERENCED_PARAMETER(pidlRoot);
798 UNREFERENCED_PARAMETER(pidlSavedSearch);
799
800 TRACE("%p %p\n", pidlRoot, pidlSavedSearch);
801
802 IContextMenu *pCM;
803 HRESULT hr = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
804 IID_IContextMenu, (void **)&pCM);
805 if (FAILED(hr))
806 {
807 ERR("0x%08X\n", hr);
808 return hr;
809 }
810
811 CMINVOKECOMMANDINFO InvokeInfo = { sizeof(InvokeInfo) };
812 InvokeInfo.lpParameters = "{996E1EB1-B524-11D1-9120-00A0C98BA67D}";
813 InvokeInfo.nShow = SW_SHOWNORMAL;
814 hr = pCM->InvokeCommand(&InvokeInfo);
815 pCM->Release();
816
817 return SUCCEEDED(hr);
818}
#define ERR(fmt,...)
Definition: precomp.h:57
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:773

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

◆ SHGetAttributes()

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

Definition at line 279 of file utils.cpp.

280{
281 LPCITEMIDLIST pidlLast = pidl;
282 IShellFolder *release = NULL;
283
284 if (!psf)
285 {
286 SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlLast);
287 if (!psf)
288 return 0;
289 release = psf;
290 }
291
292 DWORD oldAttrs = dwAttributes;
293 if (FAILED(psf->GetAttributesOf(1, &pidlLast, &dwAttributes)))
294 dwAttributes = 0;
295 else
296 dwAttributes &= oldAttrs;
297
298 if ((dwAttributes & SFGAO_FOLDER) &&
299 (dwAttributes & SFGAO_STREAM) &&
300 !(dwAttributes & SFGAO_STORAGEANCESTOR) &&
301 (oldAttrs & SFGAO_STORAGEANCESTOR) &&
302 (SHGetObjectCompatFlags(psf, NULL) & 0x200))
303 {
304 dwAttributes &= ~(SFGAO_STREAM | SFGAO_STORAGEANCESTOR);
305 dwAttributes |= SFGAO_STORAGEANCESTOR;
306 }
307
308 if (release)
309 release->Release();
310 return dwAttributes;
311}
DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
Definition: ordinal.c:6294
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1460
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
DWORD dwAttributes
Definition: vdmdbg.h:34

Referenced by CFSDropTarget::_DoDrop(), BrFolder_InsertItem(), CRegItemContextMenu_CreateInstance(), and SHGetNameAndFlagsW().

◆ SHGetNameAndFlagsW()

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

Definition at line 334 of file utils.cpp.

340{
341 if (pszText)
342 *pszText = UNICODE_NULL;
343
345
346 CComPtr<IShellFolder> psfFolder;
347 LPCITEMIDLIST ppidlLast;
348 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psfFolder), &ppidlLast);
349 if (SUCCEEDED(hr))
350 {
351 if (pszText)
352 hr = Shell_DisplayNameOf(psfFolder, ppidlLast, dwFlags, pszText, cchBuf);
353
354 if (SUCCEEDED(hr))
355 {
356 if (pdwAttributes)
357 *pdwAttributes = SHGetAttributes(psfFolder, ppidlLast, *pdwAttributes);
358 }
359 }
360
361 if (SUCCEEDED(hrCoInit))
363
364 return hr;
365}
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:263
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:279
HRESULT SHCoInitializeAnyApartment(VOID)
Definition: utils.cpp:325

Referenced by DoGetFileTitle(), CShellLink::OnInitDialog(), SHELL_GetCaptionFromDataObject(), and CDesktopFolder::ShellUrlParseDisplayName().

◆ SHGetPathCchFromIDListW()

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

◆ SHGetRealIDL()

EXTERN_C HRESULT WINAPI SHGetRealIDL ( _In_ IShellFolder psf,
_In_ PCUITEMID_CHILD  pidlSimple,
_Outptr_ PITEMID_CHILD ppidlReal 
)

Definition at line 1305 of file utils.cpp.

1309{
1310 HRESULT hr;
1311 STRRET strret;
1313 SFGAOF attrs;
1314
1315 *ppidlReal = NULL;
1316
1317 hr = IShellFolder_GetDisplayNameOf(psf, pidlSimple, SHGDN_INFOLDER | SHGDN_FORPARSING,
1318 &strret, 0);
1320 return hr;
1321
1322 hr = StrRetToBufW(&strret, pidlSimple, szPath, _countof(szPath));
1324 return hr;
1325
1326 attrs = SFGAO_FILESYSTEM;
1327 hr = psf->GetAttributesOf(1, &pidlSimple, &attrs);
1328 if (SUCCEEDED(hr) && !(attrs & SFGAO_FILESYSTEM))
1329 return SHILClone(pidlSimple, ppidlReal);
1330
1331 hr = IShellFolder_ParseDisplayName(psf, NULL, NULL, szPath, NULL, ppidlReal, NULL);
1332 if (hr == E_INVALIDARG || hr == E_NOTIMPL)
1333 return SHILClone(pidlSimple, ppidlReal);
1334
1335 return hr;
1336}
#define E_NOTIMPL
Definition: ddrawi.h:99
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
HRESULT SHILClone(_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:46
#define IShellFolder_ParseDisplayName
Definition: utils.cpp:14
#define IShellFolder_GetDisplayNameOf
Definition: utils.cpp:13
static IShellFolder IShellItem **static IBindCtx LPITEMIDLIST SFGAOF
Definition: ebrowser.c:83

Referenced by CDefView::OnChangeNotify().

◆ SHGetShellStyleHInstance()

EXTERN_C HINSTANCE WINAPI SHGetShellStyleHInstance ( VOID  )

Definition at line 692 of file utils.cpp.

693{
696 HRESULT hr;
697 CStringW strShellStyle;
698
699 TRACE("SHGetShellStyleHInstance called\n");
700
701 /* First, attempt to load the shellstyle dll from the current active theme */
703 if (FAILED(hr))
704 goto DoDefault;
705
706 /* Strip the theme filename */
708
709 strShellStyle = szPath;
710 strShellStyle += L"\\Shell\\";
711 strShellStyle += szColorName;
712 strShellStyle += L"\\ShellStyle.dll";
713
715 if (hInst)
716 return hInst;
717
718 /* Otherwise, use the version stored in the System32 directory */
719DoDefault:
720 if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\System32\\ShellStyle.dll",
722 {
723 ERR("Expand failed\n");
724 return NULL;
725 }
727}
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:368

◆ SHGetUserSessionId()

EXTERN_C DWORD WINAPI SHGetUserSessionId ( _In_opt_ HANDLE  hToken)

Definition at line 547 of file utils.cpp.

548{
549 DWORD dwSessionId, dwLength;
550 BOOL bOpenToken = FALSE;
551
552 TRACE("%p\n", hToken);
553
554 if (!hToken)
555 bOpenToken = SHOpenEffectiveToken(&hToken);
556
557 if (!hToken ||
558 !GetTokenInformation(hToken, TokenSessionId, &dwSessionId, sizeof(dwSessionId), &dwLength))
559 {
560 dwSessionId = 0;
561 }
562
563 if (bOpenToken)
564 CloseHandle(hToken);
565
566 return dwSessionId;
567}
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:538
@ TokenSessionId
Definition: setypes.h:977

◆ SHILAppend()

HRESULT SHILAppend ( _Inout_ LPITEMIDLIST  pidl,
_Inout_ LPITEMIDLIST ppidl 
)

Definition at line 106 of file utils.cpp.

107{
108 LPITEMIDLIST pidlOld = *ppidl;
109 if (!pidlOld)
110 {
111 *ppidl = pidl;
112 return S_OK;
113 }
114
115 HRESULT hr = SHILCombine(*ppidl, pidl, ppidl);
116 ILFree(pidlOld);
117 ILFree(pidl);
118 return hr;
119}
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1042

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

◆ SHILClone()

HRESULT SHILClone ( _In_opt_ LPCITEMIDLIST  pidl,
_Outptr_ LPITEMIDLIST ppidl 
)

Definition at line 46 of file utils.cpp.

49{
50 if (!pidl)
51 {
52 *ppidl = NULL;
53 return S_OK;
54 }
55 *ppidl = ILClone(pidl);
56 return (*ppidl ? S_OK : E_OUTOFMEMORY);
57}
LPITEMIDLIST WINAPI ILClone(LPCITEMIDLIST pidl)
Definition: pidl.c:237

Referenced by BrFolder_Treeview_Rename(), CShellBrowser::BrowseToPath(), CCabFolder::GetCurFolder(), CShellBrowser::GetPidl(), CCopyMoveToMenu::Initialize(), CEnumIDList::Next(), CShellBrowser::OpenNewBrowserWindow(), CFSFolder::SetNameOf(), CRegFolder::SetNameOf(), and SHGetRealIDL().

◆ SHInvokePrivilegedFunctionW()

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

Definition at line 574 of file utils.cpp.

578{
579 TRACE("(%s %p %p)\n", debugstr_w(pszName), fn, lParam);
580
581 if (!pszName || !fn)
582 return E_INVALIDARG;
583
584 HANDLE hToken = NULL;
585 TOKEN_PRIVILEGES NewPriv, PrevPriv;
586 BOOL bAdjusted = FALSE;
587
588 if (SHOpenEffectiveToken(&hToken) &&
589 ::LookupPrivilegeValueW(NULL, pszName, &NewPriv.Privileges[0].Luid))
590 {
591 NewPriv.PrivilegeCount = 1;
593
594 DWORD dwReturnSize;
595 bAdjusted = ::AdjustTokenPrivileges(hToken, FALSE, &NewPriv,
596 sizeof(PrevPriv), &PrevPriv, &dwReturnSize);
597 }
598
599 HRESULT hr = fn(lParam);
600
601 if (bAdjusted)
602 ::AdjustTokenPrivileges(hToken, FALSE, &PrevPriv, 0, NULL, NULL);
603
604 if (hToken)
605 ::CloseHandle(hToken);
606
607 return hr;
608}
LPARAM lParam
Definition: combotst.c:139
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 186 of file utils.cpp.

187{
190
191 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam((LPWSTR)STR_FILE_SYS_BIND_DATA, &punk)))
192 return S_FALSE;
193
194 if (FAILED(punk->QueryInterface(IID_PPV_ARG(IFileSystemBindData, &pBindData))))
195 return S_FALSE;
196
197 if (pFindData)
198 pBindData->GetFindData(pFindData);
199
200 return S_OK;
201}
#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 538 of file utils.cpp.

539{
540 TRACE("%p\n", phToken);
542}
static BOOL OpenEffectiveToken(_In_ DWORD DesiredAccess, _Out_ HANDLE *phToken)
Definition: utils.cpp:122
#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 1100 of file utils.cpp.

1108{
1109 CStringW strStartPageW, strCaptionW;
1110 LPCWSTR pszCaptionW = NULL, pszStartPageW = NULL;
1111
1112 TRACE("(%s, %p, %u, %p, %p, %p, %s)", debugstr_a(pszCaption), ahKeys, cKeys, pclsidDefault,
1113 pDataObject, pShellBrowser, debugstr_a(pszStartPage));
1114
1115 if (pszCaption)
1116 {
1117 strStartPageW = pszCaption;
1118 pszCaptionW = strCaptionW;
1119 }
1120
1121 if (pszStartPage)
1122 {
1123 strStartPageW = pszStartPage;
1124 pszStartPageW = strStartPageW;
1125 }
1126
1127 return SHOpenPropSheetW(pszCaptionW, ahKeys, cKeys, pclsidDefault,
1128 pDataObject, pShellBrowser, pszStartPageW);
1129}
EXTERN_C 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: propsheet.cpp:169

◆ ShortSizeFormatW()

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

Definition at line 527 of file utils.cpp.

530{
531 TRACE("(%lu, %p)\n", dwNumber, pszBuffer);
532 return StrFormatByteSizeW(dwNumber, pszBuffer, 0x8FFF);
533}
LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest, UINT cchMax)
Definition: string.c:2394

◆ SHSetFolderPathA()

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

Definition at line 474 of file utils.cpp.

479{
480 TRACE("(%d, %p, 0x%X, %s)\n", csidl, hToken, dwFlags, debugstr_a(pszPath));
481 CStringW strPathW(pszPath);
482 return SHSetFolderPathW(csidl, hToken, dwFlags, strPathW);
483}
EXTERN_C HRESULT WINAPI SHSetFolderPathW(_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCWSTR pszPath)
Definition: stubs.cpp:867

◆ SHSkipJunctionBinding()

BOOL SHSkipJunctionBinding ( _In_ IBindCtx pbc,
_In_ CLSID pclsid 
)

Definition at line 174 of file utils.cpp.

175{
176 if (!pbc)
177 return FALSE;
178
179 BIND_OPTS BindOps = { sizeof(BindOps) };
180 if (SUCCEEDED(pbc->GetBindOptions(&BindOps)) && BindOps.grfFlags == OLECONTF_LINKS)
181 return TRUE;
182
183 return pclsid && SHSkipJunction(pbc, pclsid);
184}
BOOL WINAPI SHSkipJunction(IBindCtx *pbc, const CLSID *pclsid)
Definition: ordinal.c:4574

Referenced by CDesktopFolder::_ParseDisplayNameByParent().

◆ SHStartNetConnectionDialogA()

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

Definition at line 1165 of file utils.cpp.

1169{
1170 LPCWSTR pszRemoteNameW = NULL;
1171 CStringW strRemoteNameW;
1172
1173 TRACE("(%p, %s, %lu)\n", hwnd, debugstr_a(pszRemoteName), dwType);
1174
1175 if (pszRemoteName)
1176 {
1177 strRemoteNameW = pszRemoteName;
1178 pszRemoteNameW = strRemoteNameW;
1179 }
1180
1181 return SHStartNetConnectionDialogW(hwnd, pszRemoteNameW, dwType);
1182}
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogW(_In_ HWND hwnd, _In_ LPCWSTR pszRemoteName, _In_ DWORD dwType)
Definition: stubs.cpp:599

Referenced by SHStartNetConnectionDialog().

◆ SHTestTokenPrivilegeW()

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

Definition at line 617 of file utils.cpp.

620{
621 LUID Luid;
623 PTOKEN_PRIVILEGES pTokenPriv;
624 HANDLE hNewToken = NULL;
625 BOOL ret = FALSE;
626
627 TRACE("(%p, %s)\n", hToken, debugstr_w(lpName));
628
629 if (!lpName)
630 return FALSE;
631
632 if (!hToken)
633 {
634 if (!SHOpenEffectiveToken(&hNewToken))
635 goto Quit;
636
637 if (!hNewToken)
638 return FALSE;
639
640 hToken = hNewToken;
641 }
642
643 if (!LookupPrivilegeValueW(NULL, lpName, &Luid))
644 return FALSE;
645
646 dwLength = 0;
648 goto Quit;
649
651 if (!pTokenPriv)
652 goto Quit;
653
654 if (GetTokenInformation(hToken, TokenPrivileges, pTokenPriv, dwLength, &dwLength))
655 {
656 UINT iPriv, cPrivs;
657 cPrivs = pTokenPriv->PrivilegeCount;
658 for (iPriv = 0; !ret && iPriv < cPrivs; ++iPriv)
659 {
660 ret = RtlEqualLuid(&Luid, &pTokenPriv->Privileges[iPriv].Luid);
661 }
662 }
663
664 LocalFree(pTokenPriv);
665
666Quit:
667 if (hToken == hNewToken)
668 CloseHandle(hNewToken);
669
670 return ret;
671}
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:407
_In_ LPCSTR lpName
Definition: winbase.h:2814
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:304
@ TokenPrivileges
Definition: setypes.h:968
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES

Referenced by IsShutdownAllowed().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )