ReactOS 0.4.16-dev-983-g23ad936
utils.cpp File Reference
#include "precomp.h"
#include <lmcons.h>
#include <lmapibuf.h>
#include <lmaccess.h>
#include <lmserver.h>
#include <secext.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
 
#define COMPUTER_DESCRIPTIONS_KEY    L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComputerDescriptions"
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (shell)
 
static PCSTR StrEndNA (_In_ PCSTR psz, _In_ INT_PTR cch)
 
static PCWSTR StrEndNW (_In_ PCWSTR psz, _In_ INT_PTR cch)
 
EXTERN_C PSTR WINAPI StrRStrA (_In_ PCSTR pszSrc, _In_opt_ PCSTR pszLast, _In_ PCSTR pszSearch)
 
EXTERN_C PWSTR WINAPI StrRStrW (_In_ PCWSTR pszSrc, _In_opt_ PCWSTR pszLast, _In_ PCWSTR pszSearch)
 
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)
 
EXTERN_C HRESULT WINAPI SHShouldShowWizards (_In_ IUnknown *pUnknown)
 
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)
 
EXTERN_C HRESULT SHELL_GetUIObjectOfAbsoluteItem (_In_opt_ HWND hWnd, _In_ PCIDLIST_ABSOLUTE pidl, _In_ REFIID riid, _Out_ void **ppvObj)
 
EXTERN_C HRESULT WINAPI DisplayNameOfW (_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)
 
static DWORD SHELL_ReadSingleUnreadMailCount (_In_ HKEY hKey, _Out_opt_ PDWORD pdwCount, _Out_opt_ PFILETIME pFileTime, _Out_writes_opt_(cchShellExecuteCommand) LPWSTR pszShellExecuteCommand, _In_ INT cchShellExecuteCommand)
 
EXTERN_C HRESULT WINAPI SHGetUnreadMailCountW (_In_opt_ HKEY hKeyUser, _In_opt_ PCWSTR pszMailAddress, _Out_opt_ PDWORD pdwCount, _Inout_opt_ PFILETIME pFileTime, _Out_writes_opt_(cchShellExecuteCommand) PWSTR pszShellExecuteCommand, _In_ INT cchShellExecuteCommand)
 
EXTERN_C HRESULT WINAPI SHSetUnreadMailCountW (_In_ PCWSTR pszMailAddress, _In_ DWORD dwCount, _In_ PCWSTR pszShellExecuteCommand)
 
EXTERN_C LPSTR WINAPI SheRemoveQuotesA (LPSTR psz)
 
EXTERN_C LPWSTR WINAPI SheRemoveQuotesW (LPWSTR psz)
 
EXTERN_C HRESULT WINAPI SHEnumerateUnreadMailAccountsW (_In_opt_ HKEY hKeyUser, _In_ DWORD dwIndex, _Out_writes_(cchMailAddress) PWSTR pszMailAddress, _In_ INT cchMailAddress)
 
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 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)
 
HRESULT SHELL_MapContextMenuVerbToCmdId (LPCMINVOKECOMMANDINFO pICI, const CMVERBMAP *pMap)
 
static const CMVERBMAPFindVerbMapEntry (UINT_PTR CmdId, const CMVERBMAP *pMap)
 
HRESULT SHELL_GetCommandStringImpl (SIZE_T CmdId, UINT uFlags, LPSTR Buf, UINT cchBuf, const CMVERBMAP *pMap)
 
HRESULT SHELL_CreateShell32DefaultExtractIcon (int IconIndex, REFIID riid, LPVOID *ppvOut)
 
EXTERN_C BOOL WINAPI SHIsBadInterfacePtr (_In_ LPCVOID pv, _In_ UINT_PTR ucb)
 
EXTERN_C HRESULT WINAPI SHGetUserDisplayName (_Out_writes_to_(*puSize, *puSize) PWSTR pName, _Inout_ PULONG puSize)
 
static PCWSTR SHELL_SkipServerSlashes (_In_ PCWSTR pszPath)
 
static HRESULT SHELL_GetCachedComputerDescription (_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ DWORD cchDescMax, _In_ PCWSTR pszServerName)
 
static VOID SHELL_CacheComputerDescription (_In_ PCWSTR pszServerName, _In_ PCWSTR pszDesc)
 
static HRESULT SHELL_GetComputerDescription (_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ SIZE_T cchDescMax, _In_ PWSTR pszServerName)
 
static HRESULT SHELL_BuildDisplayMachineName (_Out_writes_z_(cchNameMax) PWSTR pszName, _In_ DWORD cchNameMax, _In_ PCWSTR pszServerName, _In_ PCWSTR pszDescription)
 
EXTERN_C HRESULT WINAPI SHGetComputerDisplayNameW (_In_opt_ PWSTR pszServerName, _In_ DWORD dwFlags, _Out_writes_z_(cchNameMax) PWSTR pszName, _In_ DWORD cchNameMax)
 

Macro Definition Documentation

◆ COMPUTER_DESCRIPTIONS_KEY

#define COMPUTER_DESCRIPTIONS_KEY    L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComputerDescriptions"

Definition at line 1913 of file utils.cpp.

◆ 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:4316
#define PATH_CHAR_CLASS_SPACE
Definition: path.c:4315
#define PATH_CHAR_CLASS_SEMICOLON
Definition: path.c:4313
#define PATH_CHAR_CLASS_COMMA
Definition: path.c:4314
#define PATH_CHAR_CLASS_DOT
Definition: path.c:4310

Definition at line 153 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 1454 of file utils.cpp.

1459{
1460 DWORD dwProcessID;
1461
1465 UNREFERENCED_PARAMETER(cmdshow);
1466
1467 TRACE("(%p, %p, %s, %d)\n", hwnd, hinst, debugstr_w(cmdline), cmdline);
1468
1470 return AllowSetForegroundWindow(dwProcessID);
1471}
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
BOOL WINAPI AllowSetForegroundWindow(DWORD dwProcessId)
Definition: window.c:49
HWND WINAPI GetShellWindow(void)
Definition: input.c:974
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 270 of file utils.cpp.

271{
273 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam(const_cast<LPWSTR>(pszName), &punk)))
274 return FALSE;
275 return TRUE;
276}
#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 278 of file utils.cpp.

279{
280 if (!pbc)
281 return dwDefault;
282
283 BIND_OPTS BindOpts = { sizeof(BindOpts) };
284 HRESULT hr = pbc->GetBindOptions(&BindOpts);
285 if (FAILED(hr))
286 return dwDefault;
287
288 return BindOpts.grfMode;
289}
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 514 of file utils.cpp.

515{
516 HWND hWnd = NULL;
517
519 if (pBindCtx && SUCCEEDED(pBindCtx->GetObjectParam((LPWSTR)L"UI During Binding", &punk)))
520 IUnknown_GetWindow(punk, &hWnd);
521
522 return hWnd;
523}
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 574 of file utils.cpp.

579{
580 HRESULT hr = S_OK;
582
583 *ppbc = pBindCtx;
584
585 if (pBindCtx)
586 {
587 pBindCtx->AddRef();
588 }
589 else
590 {
591 hr = CreateBindCtx(0, ppbc);
592 if (FAILED(hr))
593 return hr;
594 }
595
596 if (!punk)
597 punk = pUnknown = new CDummyOleWindow();
598
599 hr = (*ppbc)->RegisterObjectParam(pszKey, punk);
600
601 if (pUnknown)
602 pUnknown->Release();
603
604 if (FAILED(hr))
605 {
606 (*ppbc)->Release();
607 *ppbc = NULL;
608 }
609
610 return hr;
611}
_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 1336 of file utils.cpp.

1341{
1342 HRESULT hr = E_FAIL;
1343 DWORD cbBuff, cbRead, dwSizeToWrite;
1344 DWORDLONG cbDone;
1345 LPVOID pBuff;
1346 CComHeapPtr<BYTE> pHeapPtr;
1347 STATSTG Stat;
1348 BYTE abBuff[1024];
1349
1350 TRACE("(%p, %p, %p, %I64u)\n", pSrc, pDst, pProgress, dwlSize);
1351
1352 if (dwlSize == 0) // Invalid size?
1353 {
1354 // Get the stream size
1355 ZeroMemory(&Stat, sizeof(Stat));
1356 if (FAILED(pSrc->Stat(&Stat, STATFLAG_NONAME)))
1357 pProgress = NULL; // No size info. Disable progress
1358 else
1359 dwlSize = Stat.cbSize.QuadPart;
1360 }
1361
1362 if (!pProgress) // Progress is disabled?
1363 {
1364 ULARGE_INTEGER uliSize;
1365
1366 if (dwlSize > 0)
1367 uliSize.QuadPart = dwlSize;
1368 else
1369 uliSize.HighPart = uliSize.LowPart = INVALID_FILE_SIZE;
1370
1371 return pSrc->CopyTo(pDst, uliSize, NULL, NULL); // One punch
1372 }
1373
1374 // Allocate the buffer if necessary
1375 if (dwlSize > 0 && dwlSize <= sizeof(abBuff))
1376 {
1377 cbBuff = sizeof(abBuff);
1378 pBuff = abBuff;
1379 }
1380 else
1381 {
1382#define COPY_STREAM_DEFAULT_BUFFER_SIZE 0x4000
1384 if (pHeapPtr.AllocateBytes(cbBuff))
1385 {
1386 pBuff = pHeapPtr;
1387 }
1388 else // Low memory?
1389 {
1390 cbBuff = sizeof(abBuff);
1391 pBuff = abBuff;
1392 }
1393#undef COPY_STREAM_DEFAULT_BUFFER_SIZE
1394 }
1395
1396 // Start reading
1398 zero.QuadPart = 0;
1399 pSrc->Seek(zero, 0, NULL);
1400 pDst->Seek(zero, 0, NULL);
1401 cbDone = 0;
1402 pProgress->SetProgress64(cbDone, dwlSize);
1403
1404 // Repeat reading and writing until goal
1405 for (;;)
1406 {
1407 hr = pSrc->Read(pBuff, cbBuff, &cbRead);
1408 if (FAILED(hr))
1409 break;
1410
1411 // Calculate the size to write
1412 if (dwlSize > 0)
1413 dwSizeToWrite = (DWORD)min((DWORDLONG)(dwlSize - cbDone), (DWORDLONG)cbRead);
1414 else
1415 dwSizeToWrite = cbRead;
1416
1417 if (dwSizeToWrite == 0) // No need to write?
1418 {
1419 hr = S_OK;
1420 break;
1421 }
1422
1423 hr = pDst->Write(pBuff, dwSizeToWrite, NULL);
1424 if (hr != S_OK)
1425 break;
1426
1427 cbDone += dwSizeToWrite;
1428
1429 if (pProgress->HasUserCancelled()) // Cancelled?
1430 {
1432 break;
1433 }
1434 pProgress->SetProgress64(cbDone, dwlSize);
1435
1436 if (dwlSize > 0 && cbDone >= dwlSize) // Reached the goal?
1437 {
1438 hr = S_OK;
1439 break;
1440 }
1441 }
1442
1443 return hr;
1444}
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:1743
#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

◆ DisplayNameOfW()

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

Definition at line 409 of file utils.cpp.

415{
416 *pszBuf = UNICODE_NULL;
417 STRRET sr;
418 HRESULT hr = psf->GetDisplayNameOf(pidl, dwFlags, &sr);
419 if (FAILED(hr))
420 return hr;
421 return StrRetToBufW(&sr, pidl, pszBuf, cchBuf);
422}
HRESULT WINAPI StrRetToBufW(LPSTRRET src, const ITEMIDLIST *pidl, LPWSTR dest, UINT len)
Definition: string.c:1530
#define UNICODE_NULL
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by CFSDropTarget::_DoDrop(), CDefView::OnNotify(), and SHGetNameAndFlagsW().

◆ DynamicPathCommonPrefixW()

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

Definition at line 1504 of file utils.cpp.

1508{
1509 SIZE_T cchPath1 = wcslen(lpszPath1);
1510 SIZE_T cchPath2 = wcslen(lpszPath2);
1511 LPWSTR lpszPath = strPath.GetBuffer((INT)max(cchPath1, cchPath2) + 16);
1512 INT ret = PathCommonPrefixW(lpszPath1, lpszPath2, lpszPath);
1513 strPath.ReleaseBuffer();
1514 return ret;
1515}
int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPath)
Definition: path.c:2812
_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 1576 of file utils.cpp.

1578{
1579 INT nLength = strPath.GetLength();
1580 if (nLength > 0 && strPath[nLength - 1] == L'\\')
1581 strPath = strPath.Left(nLength - 1);
1582}
_In_ DWORD nLength
Definition: wincon.h:473

Referenced by PathIsEqualOrSubFolder().

◆ DynamicSHGetPathFromIDListW()

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

Definition at line 1521 of file utils.cpp.

1524{
1525 HRESULT hr;
1526
1527 for (UINT cchPath = MAX_PATH;; cchPath *= 2)
1528 {
1529 LPWSTR lpszPath = strPath.GetBuffer(cchPath);
1530 if (!lpszPath)
1531 return E_OUTOFMEMORY;
1532
1533 hr = SHGetPathCchFromIDListW(pidl, lpszPath, cchPath);
1534 strPath.ReleaseBuffer();
1535
1537 break;
1538
1539 if (cchPath >= MAXUINT / 2)
1540 {
1541 hr = E_FAIL;
1542 break;
1543 }
1544 }
1545
1546 if (FAILED(hr))
1547 strPath.Empty();
1548
1549 return hr;
1550}
#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 1553 of file utils.cpp.

1558{
1559 LPITEMIDLIST pidl;
1560 HRESULT hr = SHGetSpecialFolderLocation(hwndOwner, nCSIDL, &pidl);
1561 if (SUCCEEDED(hr))
1562 {
1563 hr = DynamicSHGetPathFromIDListW(pidl, strPath);
1564 CoTaskMemFree(pidl);
1565 }
1566
1567 if (FAILED(hr))
1568 strPath.Empty();
1569 else if (bCreate)
1570 CreateDirectoryW(strPath, NULL);
1571
1572 return hr;
1573}
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:1521
HRESULT WINAPI SHGetSpecialFolderLocation(HWND hwndOwner, INT nFolder, LPITEMIDLIST *ppidl)
Definition: shellpath.c:3408
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
_In_ int _In_ BOOL bCreate
Definition: shlobj.h:1528
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 652 of file utils.cpp.

658{
659 TRACE("(%p, %s, %u, %p, %p)\n", hHandle, debugstr_a(lpFileName), wIndex, lpSize, lpIcon);
660
661 if (!lpFileName)
662 return 0;
663
664 CStringW strFileNameW(lpFileName);
665 return ExtractIconResInfoW(hHandle, strFileNameW, wIndex, lpSize, lpIcon);
666}
EXTERN_C WORD WINAPI ExtractIconResInfoW(_In_ HANDLE hHandle, _In_ LPCWSTR lpFileName, _In_ WORD wIndex, _Out_ LPWORD lpSize, _Out_ LPHANDLE lpIcon)
Definition: stubs.cpp:676
#define debugstr_a
Definition: kernel32.h:31
_In_ LPCSTR lpFileName
Definition: winbase.h:3102

◆ FindVerbMapEntry()

static const CMVERBMAP * FindVerbMapEntry ( UINT_PTR  CmdId,
const CMVERBMAP pMap 
)
static

Definition at line 1772 of file utils.cpp.

1773{
1774 for (SIZE_T i = 0; pMap[i].Verb; ++i)
1775 {
1776 if (pMap[i].CmdId == CmdId)
1777 return &pMap[i];
1778 }
1779 return NULL;
1780}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
LPCSTR Verb
Definition: utils.h:74

Referenced by SHELL_GetCommandStringImpl().

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

1723{
1724 HRESULT hr = pCM->GetCommandString(Id, GCS & ~GCS_UNICODE, NULL, Buf, cchMax);
1725 if (FAILED(hr))
1726 {
1728 hr = pCM->GetCommandString(Id, GCS | GCS_UNICODE, NULL, (LPSTR)buf, _countof(buf));
1729 if (SUCCEEDED(hr))
1730 hr = SHUnicodeToAnsi(buf, Buf, cchMax) > 0 ? S_OK : E_FAIL;
1731 }
1732 return hr;
1733}
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 1736 of file utils.cpp.

1737{
1738 CHAR buf[MAX_PATH];
1739 if (IS_INTRESOURCE(verba))
1740 {
1741 if (FAILED(GetCommandStringA(pCM, LOWORD(verba), GCS_VERB, buf, _countof(buf))))
1742 return 0;
1743 verba = buf;
1744 }
1745 return MapVerbToDfmCmd(verba); // Returns DFM_CMD_* or 0
1746}
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:1722
#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 1219 of file utils.cpp.

1227{
1228 WCHAR szBuff[20];
1229
1230 if (pSrc)
1231 *pDest = *pSrc;
1232 else
1233 dwNumberFlags = 0;
1234
1235 if (!(dwNumberFlags & FMT_USE_NUMDIGITS))
1236 {
1238 pDest->NumDigits = StrToIntW(szBuff);
1239 }
1240
1241 if (!(dwNumberFlags & FMT_USE_LEADZERO))
1242 {
1244 pDest->LeadingZero = StrToIntW(szBuff);
1245 }
1246
1247 if (!(dwNumberFlags & FMT_USE_GROUPING))
1248 {
1250 pDest->Grouping = StrToIntW(szBuff);
1251 }
1252
1253 if (!(dwNumberFlags & FMT_USE_DECIMAL))
1254 {
1255 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, pszDecimal, cchDecimal);
1256 pDest->lpDecimalSep = pszDecimal;
1257 }
1258
1259 if (!(dwNumberFlags & FMT_USE_THOUSAND))
1260 {
1261 GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, pszThousand, cchThousand);
1262 pDest->lpThousandSep = pszThousand;
1263 }
1264
1265 if (!(dwNumberFlags & FMT_USE_NEGNUMBER))
1266 {
1268 pDest->NegativeOrder = StrToIntW(szBuff);
1269 }
1270}
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:835
#define FMT_USE_GROUPING
Definition: undocshell.h:833
#define FMT_USE_NUMDIGITS
Definition: undocshell.h:831
#define FMT_USE_NEGNUMBER
Definition: undocshell.h:836
#define FMT_USE_LEADZERO
Definition: undocshell.h:832
#define FMT_USE_DECIMAL
Definition: undocshell.h:834
#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 1174 of file utils.cpp.

1178{
1179 WCHAR szBuff[40];
1180 UINT ich = 0, ichValue;
1181#if (WINVER >= _WIN32_WINNT_VISTA)
1182 BOOL bMinus = (llValue < 0);
1183
1184 if (bMinus)
1185 llValue = -llValue;
1186#endif
1187
1188 if (cchValue <= 0)
1189 return E_FAIL;
1190
1191 do
1192 {
1193 szBuff[ich++] = (WCHAR)(L'0' + (llValue % 10));
1194 llValue /= 10;
1195 } while (llValue != 0 && ich < _countof(szBuff) - 1);
1196
1197#if (WINVER >= _WIN32_WINNT_VISTA)
1198 if (bMinus && ich < _countof(szBuff))
1199 szBuff[ich++] = '-';
1200#endif
1201
1202 for (ichValue = 0; ich > 0 && ichValue < cchValue; ++ichValue)
1203 {
1204 --ich;
1205 pszValue[ichValue] = szBuff[ich];
1206 }
1207
1208 if (ichValue >= cchValue)
1209 {
1210 pszValue[cchValue - 1] = UNICODE_NULL;
1211 return E_FAIL;
1212 }
1213
1214 pszValue[ichValue] = UNICODE_NULL;
1215 return S_OK;
1216}
unsigned int BOOL
Definition: ntddk_ex.h:94

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

1286{
1287 INT ret;
1288 NUMBERFMTW NumFormat;
1289 WCHAR szValue[80], szDecimalSep[6], szThousandSep[6];
1290
1291 Int64ToStr(llValue, szValue, _countof(szValue));
1292
1293 if (bUseFormat)
1294 {
1295 Int64GetNumFormat(&NumFormat, pNumberFormat, dwNumberFlags,
1296 szDecimalSep, _countof(szDecimalSep),
1297 szThousandSep, _countof(szThousandSep));
1298 ret = GetNumberFormatW(LOCALE_USER_DEFAULT, 0, szValue, &NumFormat, pszOut, cchOut);
1299 if (ret)
1300 --ret;
1301 return ret;
1302 }
1303
1304 if (FAILED(StringCchCopyW(pszOut, cchOut, szValue)))
1305 return 0;
1306
1307 return lstrlenW(pszOut);
1308}
#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:1219
static HRESULT Int64ToStr(_In_ LONGLONG llValue, _Out_writes_(cchValue) LPWSTR pszValue, _In_ UINT cchValue)
Definition: utils.cpp:1174
INT WINAPI GetNumberFormatW(LCID lcid, DWORD dwFlags, LPCWSTR lpszValue, const NUMBERFMTW *lpFormat, LPWSTR lpNumberStr, int cchOut)
Definition: lcformat.c:1208
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 1667 of file utils.cpp.

1674{
1675 if (!pEC)
1676 return E_INVALIDARG;
1677
1678 if (pSite)
1679 IUnknown_SetSite(pEC, pSite);
1680 IUnknown_InitializeCommand(pEC, pszCommandName, pPB);
1681
1683 if (pSIA && SUCCEEDED(pEC->QueryInterface(IID_PPV_ARG(IObjectWithSelection, &pOWS))))
1684 pOWS->SetSelection(pSIA);
1685
1686 DWORD dwKeyState = 0, fMask = pICI ? pICI->fMask : 0;
1687 pEC->SetNoShowUI((fMask & CMIC_MASK_FLAG_NO_UI) != 0);
1688 pEC->SetShowWindow(pICI ? pICI->nShow : SW_SHOW);
1689 if (fMask & CMIC_MASK_SHIFT_DOWN)
1690 dwKeyState |= MK_SHIFT;
1691 if (fMask & CMIC_MASK_CONTROL_DOWN)
1692 dwKeyState |= MK_CONTROL;
1693 pEC->SetKeyState(dwKeyState);
1694 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpDirectoryW)
1695 pEC->SetDirectory(pICI->lpDirectoryW);
1696 if ((fMask & CMIC_MASK_UNICODE) && pICI->lpParametersW)
1697 pEC->SetParameters(pICI->lpParametersW);
1698 if (fMask & CMIC_MASK_PTINVOKE)
1699 pEC->SetPosition(pICI->ptInvoke);
1700
1701 HRESULT hr = pEC->Execute();
1702 if (pSite)
1703 IUnknown_SetSite(pEC, NULL);
1704 return hr;
1705}
#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:1654
HRESULT WINAPI IUnknown_SetSite(IUnknown *obj, IUnknown *site)
Definition: ordinal.c:1411
#define MK_SHIFT
Definition: winuser.h:2380
#define MK_CONTROL
Definition: winuser.h:2381
#define SW_SHOW
Definition: winuser.h:786
#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 1708 of file utils.cpp.

1715{
1717 HRESULT hr = SHCreateShellItemArrayFromDataObject(pDO, IID_PPV_ARG(IShellItemArray, &pSIA));
1718 return SUCCEEDED(hr) ? InvokeIExecuteCommand(pEC, pszCommandName, pPB, pSIA, pICI, pSite) : hr;
1719}
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:1667

Referenced by CDefaultContextMenu::InvokeRegVerb().

◆ IsShutdownAllowed()

BOOL IsShutdownAllowed ( VOID  )

Definition at line 819 of file utils.cpp.

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

Referenced by IsSuspendAllowed().

◆ IsSuspendAllowed()

BOOL WINAPI IsSuspendAllowed ( VOID  )

Definition at line 827 of file utils.cpp.

828{
829 TRACE("()\n");
831}
BOOL IsShutdownAllowed(VOID)
Definition: utils.cpp:819
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 1654 of file utils.cpp.

1658{
1659 HRESULT hr;
1661 if (SUCCEEDED(hr = pUnk->QueryInterface(IID_PPV_ARG(IInitializeCommand, &pIC))))
1662 hr = pIC->Initialize(pszCommandName, pPB);
1663 return hr;
1664}
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 1317 of file utils.cpp.

1324{
1325 return Int64ToString(pLargeInt->QuadPart, pszOut, cchOut, bUseFormat,
1326 pNumberFormat, dwNumberFlags);
1327}
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:1279

Referenced by DoTestEntry(), and Test_LargeIntegerToString().

◆ OpenEffectiveToken()

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

Definition at line 239 of file utils.cpp.

242{
243 BOOL ret;
244
245 if (phToken == NULL)
246 {
248 return FALSE;
249 }
250
251 *phToken = NULL;
252
254 if (!ret && GetLastError() == ERROR_NO_TOKEN)
256
257 return ret;
258}
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:2746
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 172 of file utils.cpp.

173{
177
178 if (lstrcmpiW(szPath, L"NUL") == 0 || lstrcmpiW(szPath, L"PRN") == 0 ||
179 lstrcmpiW(szPath, L"CON") == 0 || lstrcmpiW(szPath, L"AUX") == 0)
180 {
181 return TRUE;
182 }
183
184 if (_wcsnicmp(szPath, L"LPT", 3) == 0 || _wcsnicmp(szPath, L"COM", 3) == 0)
185 {
186 if ((L'0' <= szPath[3] && szPath[3] <= L'9') && szPath[4] == UNICODE_NULL)
187 return TRUE;
188 }
189
190 return FALSE;
191}
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 146 of file utils.cpp.

147{
148 if (pszPath[0] != L'.')
149 return FALSE;
150 return !pszPath[1] || (pszPath[1] == L'.' && !pszPath[2]);
151}

Referenced by PathIsValidElement().

◆ PathIsEqualOrSubFolder()

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

Definition at line 1589 of file utils.cpp.

1592{
1593 CStringW strCommon, strPath1;
1594
1595 TRACE("(%s %s)\n", debugstr_w(pszPath1OrCSIDL), debugstr_w(pszPath2));
1596
1597 if (IS_INTRESOURCE(pszPath1OrCSIDL))
1598 {
1600 NULL, strPath1, LOWORD(pszPath1OrCSIDL) | CSIDL_FLAG_DONT_VERIFY, FALSE);
1601 }
1602 else
1603 {
1604 strPath1 = pszPath1OrCSIDL;
1605 }
1606
1608
1609 if (!DynamicPathCommonPrefixW(strPath1, pszPath2, strCommon))
1610 return FALSE;
1611
1612 return strPath1.CompareNoCase(strCommon) == 0;
1613}
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:743
static VOID DynamicPathRemoveBackslashW(_Out_ CStringW &strPath)
Definition: utils.cpp:1576
static INT DynamicPathCommonPrefixW(_In_ LPCWSTR lpszPath1, _In_ LPCWSTR lpszPath2, _Out_ CStringW &strPath)
Definition: utils.cpp:1504
static HRESULT DynamicSHGetSpecialFolderPathW(_In_ HWND hwndOwner, _Out_ CStringW &strPath, _In_ INT nCSIDL, _In_ BOOL bCreate)
Definition: utils.cpp:1553
#define CSIDL_FLAG_DONT_VERIFY
Definition: shlobj.h:2242

Referenced by PathIsTemporaryW(), and START_TEST().

◆ PathIsSlowA()

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

Definition at line 638 of file utils.cpp.

641{
642 TRACE("(%s, 0x%X)\n", debugstr_a(pszFile), dwAttr);
643 CStringW strFileW(pszFile);
644 return PathIsSlowW(strFileW, dwAttr);
645}
EXTERN_C BOOL WINAPI PathIsSlowW(_In_ LPCWSTR pszFile, _In_ DWORD dwAttr)
Definition: stubs.cpp:788

◆ PathIsValidElement()

BOOL PathIsValidElement ( _In_ LPCWSTR  pszPath)

Definition at line 158 of file utils.cpp.

159{
160 if (!*pszPath || PathIsDotOrDotDotW(pszPath))
161 return FALSE;
162
163 for (LPCWSTR pch = pszPath; *pch; ++pch)
164 {
166 return FALSE;
167 }
168
169 return TRUE;
170}
#define PATH_VALID_ELEMENT
Definition: utils.cpp:153
BOOL PathIsDotOrDotDotW(_In_ LPCWSTR pszPath)
Definition: utils.cpp:146
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
Definition: path.c:4409
#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 370 of file utils.cpp.

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

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

343{
344 CComPtr<IShellFolder> psfDesktop;
345
346 *ppvObj = NULL;
347
348 if (!pShellFolder)
349 {
350 SHGetDesktopFolder(&psfDesktop);
351 if (!psfDesktop)
352 return E_FAIL;
353
354 pShellFolder = psfDesktop;
355 }
356
357 HRESULT hr;
358 if (_ILIsDesktop(pidl))
359 hr = pShellFolder->QueryInterface(riid, ppvObj);
360 else
361 hr = pShellFolder->BindToObject(pidl, pBindCtx, riid, ppvObj);
362
363 if (SUCCEEDED(hr) && !*ppvObj)
364 hr = E_FAIL;
365
366 return hr;
367}
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 471 of file utils.cpp.

472{
474 if (FAILED(hr))
476 return hr;
477}
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 880 of file utils.cpp.

881{
883}
#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_BuildDisplayMachineName()

static HRESULT SHELL_BuildDisplayMachineName ( _Out_writes_z_(cchNameMax) PWSTR  pszName,
_In_ DWORD  cchNameMax,
_In_ PCWSTR  pszServerName,
_In_ PCWSTR  pszDescription 
)
static

Definition at line 1968 of file utils.cpp.

1973{
1974 if (!pszDescription || !*pszDescription)
1975 return E_FAIL;
1976
1977 PCWSTR pszFormat = (SHRestricted(REST_ALLOWCOMMENTTOGGLE) ? L"%2 (%1)" : L"%1 (%2)");
1978 PCWSTR args[] = { pszDescription , SHELL_SkipServerSlashes(pszServerName) };
1980 pszFormat, 0, 0, pszName, cchNameMax, (va_list *)args) ? S_OK : E_FAIL);
1981}
char * va_list
Definition: acmsvcex.h:78
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
static PCWSTR SHELL_SkipServerSlashes(_In_ PCWSTR pszPath)
Definition: utils.cpp:1903
@ REST_ALLOWCOMMENTTOGGLE
Definition: shlobj.h:1879
DWORD WINAPI SHRestricted(RESTRICTIONS rest)
Definition: shpolicy.c:150
Definition: match.c:390
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:447
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:450

Referenced by SHGetComputerDisplayNameW().

◆ SHELL_CacheComputerDescription()

static VOID SHELL_CacheComputerDescription ( _In_ PCWSTR  pszServerName,
_In_ PCWSTR  pszDesc 
)
static

Definition at line 1931 of file utils.cpp.

1934{
1935 if (!pszDesc)
1936 return;
1937
1938 SIZE_T cbDesc = (wcslen(pszDesc) + 1) * sizeof(WCHAR);
1940 SHELL_SkipServerSlashes(pszServerName), REG_SZ, pszDesc, (DWORD)cbDesc);
1941}
#define COMPUTER_DESCRIPTIONS_KEY
Definition: utils.cpp:1913
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
#define REG_SZ
Definition: layer.c:22
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by SHGetComputerDisplayNameW().

◆ SHELL_CreateShell32DefaultExtractIcon()

HRESULT SHELL_CreateShell32DefaultExtractIcon ( int  IconIndex,
REFIID  riid,
LPVOID ppvOut 
)

Definition at line 1806 of file utils.cpp.

1807{
1811 return hr;
1812 initIcon->SetNormalIcon(swShell32Name, IconIndex);
1813 return initIcon->QueryInterface(riid, ppvOut);
1814}
HRESULT WINAPI SHCreateDefaultExtractIcon(REFIID riid, void **ppv)
#define FAILED_UNEXPECTEDLY(hr)
Definition: precomp.h:121
static const WCHAR IconIndex[]
Definition: install.c:52
WCHAR swShell32Name[MAX_PATH]
Definition: folders.cpp:22

Referenced by SHELL_CreateFallbackExtractIconForFolder(), and SHELL_CreateFallbackExtractIconForNoAssocFile().

◆ Shell_FailForceReturn()

BOOL Shell_FailForceReturn ( _In_ HRESULT  hr)

Definition at line 320 of file utils.cpp.

321{
323
324 switch (code)
325 {
328 case ERROR_CANCELLED:
329 return TRUE;
330
331 default:
333 }
334}
#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_GetCachedComputerDescription()

static HRESULT SHELL_GetCachedComputerDescription ( _Out_writes_z_(cchDescMax) PWSTR  pszDesc,
_In_ DWORD  cchDescMax,
_In_ PCWSTR  pszServerName 
)
static

Definition at line 1918 of file utils.cpp.

1922{
1923 cchDescMax *= sizeof(WCHAR);
1925 SHELL_SkipServerSlashes(pszServerName), NULL, pszDesc, &cchDescMax);
1926 return HRESULT_FROM_WIN32(error);
1927}
DWORD WINAPI SHGetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1236
#define error(str)
Definition: mkdosfs.c:1605

Referenced by SHGetComputerDisplayNameW().

◆ SHELL_GetCommandStringImpl()

HRESULT SHELL_GetCommandStringImpl ( SIZE_T  CmdId,
UINT  uFlags,
LPSTR  Buf,
UINT  cchBuf,
const CMVERBMAP pMap 
)

Definition at line 1783 of file utils.cpp.

1784{
1785 const CMVERBMAP* pEntry;
1786 switch (uFlags | GCS_UNICODE)
1787 {
1788 case GCS_VALIDATEW:
1789 case GCS_VERBW:
1790 pEntry = FindVerbMapEntry(CmdId, pMap);
1791 if ((uFlags | GCS_UNICODE) == GCS_VERBW)
1792 {
1793 if (!pEntry)
1794 return E_INVALIDARG;
1795 else if (uFlags & GCS_UNICODE)
1796 return SHAnsiToUnicode(pEntry->Verb, (LPWSTR)Buf, cchBuf) ? S_OK : E_FAIL;
1797 else
1798 return StringCchCopyA(Buf, cchBuf, pEntry->Verb);
1799 }
1800 return pEntry ? S_OK : S_FALSE; // GCS_VALIDATE
1801 }
1802 return E_NOTIMPL;
1803}
#define E_NOTIMPL
Definition: ddrawi.h:99
UINT uFlags
Definition: api.c:59
static const CMVERBMAP * FindVerbMapEntry(UINT_PTR CmdId, const CMVERBMAP *pMap)
Definition: utils.cpp:1772
DWORD WINAPI SHAnsiToUnicode(LPCSTR lpSrcStr, LPWSTR lpDstStr, int iLen)
Definition: string.c:2673
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
STRSAFEAPI StringCchCopyA(STRSAFE_LPSTR pszDest, size_t cchDest, STRSAFE_LPCSTR pszSrc)
Definition: strsafe.h:145
#define S_FALSE
Definition: winerror.h:2357

Referenced by CCopyAsPathMenu::GetCommandString(), COpenWithMenu::GetCommandString(), CRecycleBinItemContextMenu::GetCommandString(), and CRecycleBin::GetCommandString().

◆ SHELL_GetComputerDescription()

static HRESULT SHELL_GetComputerDescription ( _Out_writes_z_(cchDescMax) PWSTR  pszDesc,
_In_ SIZE_T  cchDescMax,
_In_ PWSTR  pszServerName 
)
static

Definition at line 1945 of file utils.cpp.

1949{
1951 NET_API_STATUS error = NetServerGetInfo(pszServerName, 101, (PBYTE*)&bufptr);
1954 return hr;
1955
1956 PCWSTR comment = bufptr->sv101_comment;
1957 if (comment && comment[0])
1958 StringCchCopyW(pszDesc, cchDescMax, comment);
1959 else
1960 hr = E_FAIL;
1961
1963 return hr;
1964}
NET_API_STATUS WINAPI NetApiBufferFree(LPVOID Buffer)
Definition: apibuf.c:43
NET_API_STATUS WINAPI NetServerGetInfo(LMSTR servername, DWORD level, LPBYTE *bufptr)
Definition: srvsvc.c:369
#define comment(fmt, arg1)
Definition: rebar.c:847
DWORD NET_API_STATUS
Definition: ms-dtyp.idl:91
BYTE * PBYTE
Definition: pedump.c:66
static unsigned int bufptr
Definition: tncon.cpp:77

Referenced by SHGetComputerDisplayNameW().

◆ SHELL_GetIDListTarget()

HRESULT SHELL_GetIDListTarget ( _In_ LPCITEMIDLIST  pidl,
_Out_ PIDLIST_ABSOLUTE ppidl 
)

Definition at line 459 of file utils.cpp.

460{
461 IShellLink *pSL;
462 HRESULT hr = SHBindToObject(NULL, pidl, IID_PPV_ARG(IShellLink, &pSL));
463 if (SUCCEEDED(hr))
464 {
465 hr = pSL->GetIDList(ppidl); // Note: Returns S_FALSE if no target pidl
466 pSL->Release();
467 }
468 return hr;
469}
EXTERN_C HRESULT SHBindToObject(_In_opt_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ REFIID riid, _Out_ void **ppvObj)
Definition: utils.cpp:370

Referenced by SHBrowseForFolderW().

◆ SHELL_GetUIObjectOfAbsoluteItem()

EXTERN_C HRESULT SHELL_GetUIObjectOfAbsoluteItem ( _In_opt_ HWND  hWnd,
_In_ PCIDLIST_ABSOLUTE  pidl,
_In_ REFIID  riid,
_Out_ void **  ppvObj 
)

Definition at line 380 of file utils.cpp.

384{
385 if (!ppvObj)
386 return E_INVALIDARG;
387 *ppvObj = NULL;
388 IShellFolder *psf;
389 PCUITEMID_CHILD pidlChild;
390 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlChild);
391 if (SUCCEEDED(hr))
392 {
393 hr = psf->GetUIObjectOf(hWnd, 1, &pidlChild, riid, NULL, ppvObj);
394 psf->Release();
395 if (SUCCEEDED(hr))
396 {
397 if (*ppvObj)
398 return hr;
399 hr = E_FAIL;
400 }
401 }
402 return hr;
403}
HRESULT GetUIObjectOf([in] HWND hwndOwner, [in] UINT cidl, [in, size_is(cidl)] PCUITEMID_CHILD_ARRAY apidl, [in] REFIID riid, [in, out, unique] UINT *prgfInOut, [out, iid_is(riid)] void **ppvOut)
HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCITEMIDLIST *ppidlLast)
Definition: pidl.c:1462
const ITEMID_CHILD UNALIGNED * PCUITEMID_CHILD
Definition: shtypes.idl:70

Referenced by CShellLink::DragEnter(), CSendToMenu::GetUIObjectFromPidl(), CFolderItemVerbs::Init(), SHELL_PidlGetIconLocationW(), and shellex_get_dataobj().

◆ SHELL_MapContextMenuVerbToCmdId()

HRESULT SHELL_MapContextMenuVerbToCmdId ( LPCMINVOKECOMMANDINFO  pICI,
const CMVERBMAP pMap 
)

Definition at line 1749 of file utils.cpp.

1750{
1751 LPCSTR pVerbA = pICI->lpVerb;
1752 CHAR buf[MAX_PATH];
1753 LPCMINVOKECOMMANDINFOEX pICIX = (LPCMINVOKECOMMANDINFOEX)pICI;
1754 if (IsUnicode(*pICIX) && !IS_INTRESOURCE(pICIX->lpVerbW))
1755 {
1756 if (SHUnicodeToAnsi(pICIX->lpVerbW, buf, _countof(buf)))
1757 pVerbA = buf;
1758 }
1759
1760 if (IS_INTRESOURCE(pVerbA))
1761 return LOWORD(pVerbA);
1762 for (SIZE_T i = 0; pMap[i].Verb; ++i)
1763 {
1764 assert(SUCCEEDED((int)(pMap[i].CmdId))); // The id must be >= 0 and ideally in the 0..0x7fff range
1765 if (!lstrcmpiA(pMap[i].Verb, pVerbA) && pVerbA[0])
1766 return pMap[i].CmdId;
1767 }
1768 return E_FAIL;
1769}
int WINAPI lstrcmpiA(LPCSTR str1, LPCSTR str2)
Definition: locale.c:4224
#define assert(x)
Definition: debug.h:53
WORD CmdId
Definition: utils.h:75
const char * LPCSTR
Definition: xmlstorage.h:183

Referenced by CCopyAsPathMenu::InvokeCommand(), COpenWithMenu::InvokeCommand(), CRecycleBinItemContextMenu::InvokeCommand(), and CRecycleBin::InvokeCommand().

◆ SHELL_ReadSingleUnreadMailCount()

static DWORD SHELL_ReadSingleUnreadMailCount ( _In_ HKEY  hKey,
_Out_opt_ PDWORD  pdwCount,
_Out_opt_ PFILETIME  pFileTime,
_Out_writes_opt_(cchShellExecuteCommand) LPWSTR  pszShellExecuteCommand,
_In_ INT  cchShellExecuteCommand 
)
static

Definition at line 887 of file utils.cpp.

893{
894 DWORD dwType, dwCount, cbSize = sizeof(dwCount);
895 DWORD error = SHQueryValueExW(hKey, L"MessageCount", 0, &dwType, &dwCount, &cbSize);
896 if (error)
897 return error;
898 if (pdwCount && dwType == REG_DWORD)
899 *pdwCount = dwCount;
900
901 FILETIME FileTime;
902 cbSize = sizeof(FileTime);
903 error = SHQueryValueExW(hKey, L"TimeStamp", 0, &dwType, &FileTime, &cbSize);
904 if (error)
905 return error;
906 if (pFileTime && dwType == REG_BINARY)
907 *pFileTime = FileTime;
908
909 WCHAR szName[2 * MAX_PATH];
910 cbSize = sizeof(szName);
911 error = SHQueryValueExW(hKey, L"Application", 0, &dwType, szName, &cbSize);
912 if (error)
913 return error;
914
915 if (pszShellExecuteCommand && dwType == REG_SZ &&
916 FAILED(StringCchCopyW(pszShellExecuteCommand, cchShellExecuteCommand, szName)))
917 {
919 }
920
921 return ERROR_SUCCESS;
922}
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI SHQueryValueExW(HKEY hKey, LPCWSTR lpszValue, LPDWORD lpReserved, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData)
Definition: reg.c:1461
FxAutoRegKey hKey
#define REG_BINARY
Definition: nt_native.h:1496
static const WCHAR szName[]
Definition: powrprof.c:45
#define REG_DWORD
Definition: sdbapi.c:596

Referenced by SHGetUnreadMailCountW().

◆ SHELL_SkipServerSlashes()

static PCWSTR SHELL_SkipServerSlashes ( _In_ PCWSTR  pszPath)
static

Definition at line 1903 of file utils.cpp.

1905{
1906 PCWSTR pch;
1907 for (pch = pszPath; *pch == L'\\'; ++pch)
1908 ;
1909 return pch;
1910}

Referenced by SHELL_BuildDisplayMachineName(), SHELL_CacheComputerDescription(), SHELL_GetCachedComputerDescription(), and SHGetComputerDisplayNameW().

◆ Shell_TranslateIDListAlias()

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

Definition at line 261 of file utils.cpp.

266{
267 return E_FAIL; //FIXME
268}

Referenced by CDesktopFolder::ParseDisplayName().

◆ SHEnumerateUnreadMailAccountsW()

EXTERN_C HRESULT WINAPI SHEnumerateUnreadMailAccountsW ( _In_opt_ HKEY  hKeyUser,
_In_ DWORD  dwIndex,
_Out_writes_(cchMailAddress) PWSTR  pszMailAddress,
_In_ INT  cchMailAddress 
)

Definition at line 1114 of file utils.cpp.

1119{
1120 if (!hKeyUser)
1121 hKeyUser = HKEY_CURRENT_USER;
1122
1123 HKEY hKey;
1124 LSTATUS error = RegOpenKeyExW(hKeyUser,
1125 L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail",
1127 if (error)
1128 return HRESULT_FROM_WIN32(error);
1129
1130 FILETIME FileTime;
1131 error = RegEnumKeyExW(hKey, dwIndex, pszMailAddress, (PDWORD)&cchMailAddress, NULL, NULL,
1132 NULL, &FileTime);
1133 if (error)
1134 *pszMailAddress = UNICODE_NULL;
1135
1137 return error ? HRESULT_FROM_WIN32(error) : S_OK;
1138}
#define RegCloseKey(hKey)
Definition: registry.h:49
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumKeyExW(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPWSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpReserved, _Out_opt_ LPWSTR lpClass, _Inout_opt_ LPDWORD lpcbClass, _Out_opt_ PFILETIME lpftLastWriteTime)
Definition: reg.c:2504
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
DWORD * PDWORD
Definition: pedump.c:68

Referenced by START_TEST().

◆ SheRemoveQuotesA()

EXTERN_C LPSTR WINAPI SheRemoveQuotesA ( LPSTR  psz)

Definition at line 1064 of file utils.cpp.

1065{
1066 PCHAR pch;
1067
1068 if (*psz == '"')
1069 {
1070 for (pch = psz + 1; *pch && *pch != '"'; ++pch)
1071 {
1072 *(pch - 1) = *pch;
1073 }
1074
1075 if (*pch == '"')
1076 *(pch - 1) = ANSI_NULL;
1077 }
1078
1079 return psz;
1080}
#define ANSI_NULL
char * PCHAR
Definition: typedefs.h:51

◆ SheRemoveQuotesW()

EXTERN_C LPWSTR WINAPI SheRemoveQuotesW ( LPWSTR  psz)

Definition at line 1089 of file utils.cpp.

1090{
1091 PWCHAR pch;
1092
1093 if (*psz == L'"')
1094 {
1095 for (pch = psz + 1; *pch && *pch != L'"'; ++pch)
1096 {
1097 *(pch - 1) = *pch;
1098 }
1099
1100 if (*pch == L'"')
1101 *(pch - 1) = UNICODE_NULL;
1102 }
1103
1104 return psz;
1105}
uint16_t * PWCHAR
Definition: typedefs.h:56

◆ SHFindComputer()

EXTERN_C BOOL WINAPI SHFindComputer ( LPCITEMIDLIST  pidlRoot,
LPCITEMIDLIST  pidlSavedSearch 
)

Definition at line 1148 of file utils.cpp.

1149{
1150 UNREFERENCED_PARAMETER(pidlRoot);
1151 UNREFERENCED_PARAMETER(pidlSavedSearch);
1152
1153 TRACE("%p %p\n", pidlRoot, pidlSavedSearch);
1154
1155 IContextMenu *pCM;
1156 HRESULT hr = CoCreateInstance(CLSID_ShellSearchExt, NULL, CLSCTX_INPROC_SERVER,
1157 IID_IContextMenu, (void **)&pCM);
1158 if (FAILED(hr))
1159 {
1160 ERR("0x%08X\n", hr);
1161 return hr;
1162 }
1163
1164 CMINVOKECOMMANDINFO InvokeInfo = { sizeof(InvokeInfo) };
1165 InvokeInfo.lpParameters = "{996E1EB1-B524-11D1-9120-00A0C98BA67D}";
1166 InvokeInfo.nShow = SW_SHOWNORMAL;
1167 hr = pCM->InvokeCommand(&InvokeInfo);
1168 pCM->Release();
1169
1170 return SUCCEEDED(hr);
1171}
#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:781

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

◆ SHGetAttributes()

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

Definition at line 425 of file utils.cpp.

426{
427 LPCITEMIDLIST pidlLast = pidl;
428 IShellFolder *release = NULL;
429
430 if (!psf)
431 {
432 SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psf), &pidlLast);
433 if (!psf)
434 return 0;
435 release = psf;
436 }
437
438 DWORD oldAttrs = dwAttributes;
439 if (FAILED(psf->GetAttributesOf(1, &pidlLast, &dwAttributes)))
440 dwAttributes = 0;
441 else
442 dwAttributes &= oldAttrs;
443
444 if ((dwAttributes & SFGAO_FOLDER) &&
445 (dwAttributes & SFGAO_STREAM) &&
446 !(dwAttributes & SFGAO_STORAGEANCESTOR) &&
447 (oldAttrs & SFGAO_STORAGEANCESTOR) &&
448 (SHGetObjectCompatFlags(psf, NULL) & 0x200))
449 {
450 dwAttributes &= ~(SFGAO_STREAM | SFGAO_STORAGEANCESTOR);
451 dwAttributes |= SFGAO_STORAGEANCESTOR;
452 }
453
454 if (release)
455 release->Release();
456 return dwAttributes;
457}
DWORD WINAPI SHGetObjectCompatFlags(IUnknown *pUnk, const CLSID *clsid)
Definition: ordinal.c:6315
const ITEMIDLIST UNALIGNED * LPCITEMIDLIST
Definition: shtypes.idl:42
DWORD dwAttributes
Definition: vdmdbg.h:34

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

◆ SHGetComputerDisplayNameW()

EXTERN_C HRESULT WINAPI SHGetComputerDisplayNameW ( _In_opt_ PWSTR  pszServerName,
_In_ DWORD  dwFlags,
_Out_writes_z_(cchNameMax) PWSTR  pszName,
_In_ DWORD  cchNameMax 
)

Definition at line 1988 of file utils.cpp.

1993{
1994 WCHAR szDesc[256], szCompName[MAX_COMPUTERNAME_LENGTH + 1];
1995
1996 // If no server name is specified, retrieve the local computer name
1997 if (!pszServerName)
1998 {
1999 // Use computer name as server name
2000 DWORD cchCompName = _countof(szCompName);
2001 if (!GetComputerNameW(szCompName, &cchCompName))
2002 return E_FAIL;
2003 pszServerName = szCompName;
2004
2005 // Don't use the cache for the local machine
2007 }
2008
2009 // Get computer description from cache if necessary
2010 HRESULT hr = E_FAIL;
2011 if (!(dwFlags & SHGCDN_NOCACHE))
2012 hr = SHELL_GetCachedComputerDescription(szDesc, _countof(szDesc), pszServerName);
2013
2014 // Actually retrieve the computer description if it is not in the cache
2015 if (FAILED(hr))
2016 {
2017 hr = SHELL_GetComputerDescription(szDesc, _countof(szDesc), pszServerName);
2018 if (FAILED(hr))
2019 szDesc[0] = UNICODE_NULL;
2020
2021 // Cache the description if necessary
2022 if (!(dwFlags & SHGCDN_NOCACHE))
2023 SHELL_CacheComputerDescription(pszServerName, szDesc);
2024 }
2025
2026 // If getting the computer description failed, store the server name only
2027 if (FAILED(hr) || !szDesc[0])
2028 {
2030 return hr; // Bail out if no server name is requested
2031
2032 StringCchCopyW(pszName, cchNameMax, SHELL_SkipServerSlashes(pszServerName));
2033 return S_OK;
2034 }
2035
2036 // If no server name is requested, store the description only
2038 {
2039 StringCchCopyW(pszName, cchNameMax, szDesc);
2040 return S_OK;
2041 }
2042
2043 // Build a string like "Description (SERVERNAME)"
2044 return SHELL_BuildDisplayMachineName(pszName, cchNameMax, pszServerName, szDesc);
2045}
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
static HRESULT SHELL_GetComputerDescription(_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ SIZE_T cchDescMax, _In_ PWSTR pszServerName)
Definition: utils.cpp:1945
static HRESULT SHELL_BuildDisplayMachineName(_Out_writes_z_(cchNameMax) PWSTR pszName, _In_ DWORD cchNameMax, _In_ PCWSTR pszServerName, _In_ PCWSTR pszDescription)
Definition: utils.cpp:1968
static VOID SHELL_CacheComputerDescription(_In_ PCWSTR pszServerName, _In_ PCWSTR pszDesc)
Definition: utils.cpp:1931
static HRESULT SHELL_GetCachedComputerDescription(_Out_writes_z_(cchDescMax) PWSTR pszDesc, _In_ DWORD cchDescMax, _In_ PCWSTR pszServerName)
Definition: utils.cpp:1918
#define SHGCDN_NOSERVERNAME
Definition: undocshell.h:988
#define SHGCDN_NOCACHE
Definition: undocshell.h:987
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:269

◆ SHGetNameAndFlagsW()

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

Definition at line 480 of file utils.cpp.

486{
487 if (pszText)
488 *pszText = UNICODE_NULL;
489
491
492 CComPtr<IShellFolder> psfFolder;
493 LPCITEMIDLIST ppidlLast;
494 HRESULT hr = SHBindToParent(pidl, IID_PPV_ARG(IShellFolder, &psfFolder), &ppidlLast);
495 if (SUCCEEDED(hr))
496 {
497 if (pszText)
498 hr = DisplayNameOfW(psfFolder, ppidlLast, dwFlags, pszText, cchBuf);
499
500 if (SUCCEEDED(hr))
501 {
502 if (pdwAttributes)
503 *pdwAttributes = SHGetAttributes(psfFolder, ppidlLast, *pdwAttributes);
504 }
505 }
506
507 if (SUCCEEDED(hrCoInit))
509
510 return hr;
511}
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
DWORD SHGetAttributes(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwAttributes)
Definition: utils.cpp:425
EXTERN_C HRESULT WINAPI DisplayNameOfW(_In_ IShellFolder *psf, _In_ LPCITEMIDLIST pidl, _In_ DWORD dwFlags, _Out_ LPWSTR pszBuf, _In_ UINT cchBuf)
Definition: utils.cpp:409
HRESULT SHCoInitializeAnyApartment(VOID)
Definition: utils.cpp:471

Referenced by CDrvDefExt::AddMainPage(), DoGetFileTitle(), CShellLink::OnInitDialog(), SHELL_execute(), 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 1620 of file utils.cpp.

1624{
1625 HRESULT hr;
1626 STRRET strret;
1628 SFGAOF attrs;
1629
1630 *ppidlReal = NULL;
1631
1632 hr = IShellFolder_GetDisplayNameOf(psf, pidlSimple, SHGDN_INFOLDER | SHGDN_FORPARSING,
1633 &strret, 0);
1635 return hr;
1636
1637 hr = StrRetToBufW(&strret, pidlSimple, szPath, _countof(szPath));
1639 return hr;
1640
1641 attrs = SFGAO_FILESYSTEM;
1642 hr = psf->GetAttributesOf(1, &pidlSimple, &attrs);
1643 if (SUCCEEDED(hr) && !(attrs & SFGAO_FILESYSTEM))
1644 return SHILClone(pidlSimple, ppidlReal);
1645
1646 hr = IShellFolder_ParseDisplayName(psf, NULL, NULL, szPath, NULL, ppidlReal, NULL);
1647 if (hr == E_INVALIDARG || hr == E_NOTIMPL)
1648 return SHILClone(pidlSimple, ppidlReal);
1649
1650 return hr;
1651}
HRESULT SHILClone(_In_opt_ LPCITEMIDLIST pidl, _Outptr_ LPITEMIDLIST *ppidl)
Definition: utils.cpp:133
#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 838 of file utils.cpp.

839{
842 HRESULT hr;
843 CStringW strShellStyle;
844
845 TRACE("SHGetShellStyleHInstance called\n");
846
847 /* First, attempt to load the shellstyle dll from the current active theme */
849 if (FAILED(hr))
850 goto DoDefault;
851
852 /* Strip the theme filename */
854
855 strShellStyle = szPath;
856 strShellStyle += L"\\Shell\\";
857 strShellStyle += szColorName;
858 strShellStyle += L"\\ShellStyle.dll";
859
861 if (hInst)
862 return hInst;
863
864 /* Otherwise, use the version stored in the System32 directory */
865DoDefault:
866 if (!ExpandEnvironmentStringsW(L"%SystemRoot%\\System32\\ShellStyle.dll",
868 {
869 ERR("Expand failed\n");
870 return NULL;
871 }
873}
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:909
static const WCHAR szColorName[]
Definition: system.c:42
HINSTANCE hInst
Definition: dxdiag.c:13
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:368

◆ SHGetUnreadMailCountW()

EXTERN_C HRESULT WINAPI SHGetUnreadMailCountW ( _In_opt_ HKEY  hKeyUser,
_In_opt_ PCWSTR  pszMailAddress,
_Out_opt_ PDWORD  pdwCount,
_Inout_opt_ PFILETIME  pFileTime,
_Out_writes_opt_(cchShellExecuteCommand) PWSTR  pszShellExecuteCommand,
_In_ INT  cchShellExecuteCommand 
)

Definition at line 931 of file utils.cpp.

938{
940 HKEY hKey;
941
942 if (!hKeyUser)
943 hKeyUser = HKEY_CURRENT_USER;
944
945 if (pszMailAddress)
946 {
947 CStringW strKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail";
948 strKey += L'\\';
949 strKey += pszMailAddress;
950
951 error = RegOpenKeyExW(hKeyUser, strKey, 0, KEY_QUERY_VALUE, &hKey);
952 if (error)
954
955 error = SHELL_ReadSingleUnreadMailCount(hKey, pdwCount, pFileTime,
956 pszShellExecuteCommand, cchShellExecuteCommand);
957 }
958 else
959 {
960 if (pszShellExecuteCommand || cchShellExecuteCommand)
961 return E_INVALIDARG;
962
963 *pdwCount = 0;
964
965 error = RegOpenKeyExW(hKeyUser, L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail",
967 if (error)
969
970 for (DWORD dwIndex = 0; !error; ++dwIndex)
971 {
972 WCHAR Name[2 * MAX_PATH];
974 FILETIME LastWritten;
975 error = RegEnumKeyExW(hKey, dwIndex, Name, &cchName, NULL, NULL, NULL, &LastWritten);
976 if (error)
977 break;
978
979 HKEY hSubKey;
980 error = RegOpenKeyExW(hKey, Name, 0, KEY_QUERY_VALUE, &hSubKey);
981 if (error)
982 break;
983
984 FILETIME FileTime;
985 DWORD dwCount;
986 error = SHELL_ReadSingleUnreadMailCount(hSubKey, &dwCount, &FileTime, NULL, 0);
987 if (!error && (!pFileTime || CompareFileTime(&FileTime, pFileTime) >= 0))
988 *pdwCount += dwCount;
989
990 RegCloseKey(hSubKey);
991 }
992
995 }
996
998
1000}
LPWSTR Name
Definition: desk.c:124
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
Definition: time.c:106
static DWORD SHELL_ReadSingleUnreadMailCount(_In_ HKEY hKey, _Out_opt_ PDWORD pdwCount, _Out_opt_ PFILETIME pFileTime, _Out_writes_opt_(cchShellExecuteCommand) LPWSTR pszShellExecuteCommand, _In_ INT cchShellExecuteCommand)
Definition: utils.cpp:887
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
_In_ PSID _Out_writes_to_opt_ cchName LPSTR _Inout_ LPDWORD cchName
Definition: winbase.h:2798

Referenced by START_TEST().

◆ SHGetUserDisplayName()

EXTERN_C HRESULT WINAPI SHGetUserDisplayName ( _Out_writes_to_ *, *puSize PWSTR  pName,
_Inout_ PULONG  puSize 
)

Definition at line 1847 of file utils.cpp.

1850{
1851 if (!pName || !puSize)
1852 return E_INVALIDARG;
1853
1854 if (GetUserNameExW(NameDisplay, pName, puSize))
1855 return S_OK;
1856
1857 LONG error = GetLastError(); // for ERROR_NONE_MAPPED
1859
1860 WCHAR UserName[MAX_PATH];
1861 DWORD cchUserName = _countof(UserName);
1862 if (!GetUserNameW(UserName, &cchUserName))
1864
1865 // Was the user name not available in the specified format (NameDisplay)?
1866 if (error == ERROR_NONE_MAPPED)
1867 {
1868 // Try to get the user name by using Network API
1869 PUSER_INFO_2 UserInfo;
1870 DWORD NetError = NetUserGetInfo(NULL, UserName, 2, (PBYTE*)&UserInfo);
1871 if (NetError)
1872 {
1873 hr = HRESULT_FROM_WIN32(NetError);
1874 }
1875 else
1876 {
1877 if (UserInfo->usri2_full_name)
1878 {
1879 hr = StringCchCopyW(pName, *puSize, UserInfo->usri2_full_name);
1880 if (SUCCEEDED(hr))
1881 {
1882 // Include the NUL-terminator
1883 *puSize = lstrlenW(UserInfo->usri2_full_name) + 1;
1884 }
1885 }
1886
1887 NetApiBufferFree(UserInfo);
1888 }
1889 }
1890
1891 if (FAILED(hr))
1892 {
1893 hr = StringCchCopyW(pName, *puSize, UserName);
1894 if (SUCCEEDED(hr))
1895 *puSize = cchUserName;
1896 }
1897
1898 return hr;
1899}
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
Definition: misc.c:291
NET_API_STATUS WINAPI NetUserGetInfo(LPCWSTR servername, LPCWSTR username, DWORD level, LPBYTE *bufptr)
Definition: user.c:3147
static LPSTR pName
Definition: security.c:75
long LONG
Definition: pedump.c:60
BOOLEAN WINAPI GetUserNameExW(EXTENDED_NAME_FORMAT NameFormat, LPWSTR lpNameBuffer, PULONG nSize)
Definition: sspi.c:1079
LPWSTR usri2_full_name
Definition: lmaccess.h:222
#define ERROR_NONE_MAPPED
Definition: winerror.h:814

Referenced by START_TEST().

◆ SHGetUserSessionId()

EXTERN_C DWORD WINAPI SHGetUserSessionId ( _In_opt_ HANDLE  hToken)

Definition at line 693 of file utils.cpp.

694{
695 DWORD dwSessionId, dwLength;
696 BOOL bOpenToken = FALSE;
697
698 TRACE("%p\n", hToken);
699
700 if (!hToken)
701 bOpenToken = SHOpenEffectiveToken(&hToken);
702
703 if (!hToken ||
704 !GetTokenInformation(hToken, TokenSessionId, &dwSessionId, sizeof(dwSessionId), &dwLength))
705 {
706 dwSessionId = 0;
707 }
708
709 if (bOpenToken)
710 CloseHandle(hToken);
711
712 return dwSessionId;
713}
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:684
@ TokenSessionId
Definition: setypes.h:977

◆ SHILAppend()

HRESULT SHILAppend ( _Inout_ LPITEMIDLIST  pidl,
_Inout_ LPITEMIDLIST ppidl 
)

Definition at line 193 of file utils.cpp.

194{
195 LPITEMIDLIST pidlOld = *ppidl;
196 if (!pidlOld)
197 {
198 *ppidl = pidl;
199 return S_OK;
200 }
201
202 HRESULT hr = SHILCombine(*ppidl, pidl, ppidl);
203 ILFree(pidlOld);
204 ILFree(pidl);
205 return hr;
206}
void WINAPI ILFree(LPITEMIDLIST pidl)
Definition: pidl.c:1044

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

◆ SHILClone()

◆ SHInvokePrivilegedFunctionW()

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

Definition at line 720 of file utils.cpp.

724{
725 TRACE("(%s %p %p)\n", debugstr_w(pszName), fn, lParam);
726
727 if (!pszName || !fn)
728 return E_INVALIDARG;
729
730 HANDLE hToken = NULL;
731 TOKEN_PRIVILEGES NewPriv, PrevPriv;
732 BOOL bAdjusted = FALSE;
733
734 if (SHOpenEffectiveToken(&hToken) &&
735 ::LookupPrivilegeValueW(NULL, pszName, &NewPriv.Privileges[0].Luid))
736 {
737 NewPriv.PrivilegeCount = 1;
739
740 DWORD dwReturnSize;
741 bAdjusted = ::AdjustTokenPrivileges(hToken, FALSE, &NewPriv,
742 sizeof(PrevPriv), &PrevPriv, &dwReturnSize);
743 }
744
745 HRESULT hr = fn(lParam);
746
747 if (bAdjusted)
748 ::AdjustTokenPrivileges(hToken, FALSE, &PrevPriv, 0, NULL, NULL);
749
750 if (hToken)
751 ::CloseHandle(hToken);
752
753 return hr;
754}
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

◆ SHIsBadInterfacePtr()

EXTERN_C BOOL WINAPI SHIsBadInterfacePtr ( _In_ LPCVOID  pv,
_In_ UINT_PTR  ucb 
)

Definition at line 1823 of file utils.cpp.

1826{
1827 struct CUnknownVtbl
1828 {
1832 };
1833 struct CUnknown { CUnknownVtbl *lpVtbl; };
1834 const CUnknown *punk = reinterpret_cast<const CUnknown *>(pv);
1835 return !punk || IsBadReadPtr(punk, sizeof(punk->lpVtbl)) ||
1836 IsBadReadPtr(punk->lpVtbl, ucb) ||
1837 IsBadCodePtr((FARPROC)punk->lpVtbl->Release);
1838}
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
_In_ BOOLEAN Release
Definition: cdrom.h:920
int(* FARPROC)()
Definition: compat.h:36
BOOL WINAPI IsBadReadPtr(IN LPCVOID lp, IN UINT_PTR ucb)
Definition: except.c:805
BOOL NTAPI IsBadCodePtr(FARPROC lpfn)
Definition: except.c:872
static HRESULT QueryInterface(REFIID, void **)
Definition: events.c:2587
static ULONG WINAPI AddRef(IStream *iface)
Definition: clist.c:90
#define REFIID
Definition: guiddef.h:118
uint32_t ULONG
Definition: typedefs.h:59
#define HRESULT
Definition: msvc.h:7

Referenced by START_TEST().

◆ SHIsFileSysBindCtx()

HRESULT SHIsFileSysBindCtx ( _In_ IBindCtx pBindCtx,
_Out_opt_ WIN32_FIND_DATAW pFindData 
)

Definition at line 303 of file utils.cpp.

304{
307
308 if (!pBindCtx || FAILED(pBindCtx->GetObjectParam((LPWSTR)STR_FILE_SYS_BIND_DATA, &punk)))
309 return S_FALSE;
310
311 if (FAILED(punk->QueryInterface(IID_PPV_ARG(IFileSystemBindData, &pBindData))))
312 return S_FALSE;
313
314 if (pFindData)
315 pBindData->GetFindData(pFindData);
316
317 return S_OK;
318}

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

◆ SHOpenEffectiveToken()

EXTERN_C BOOL WINAPI SHOpenEffectiveToken ( _Out_ LPHANDLE  phToken)

Definition at line 684 of file utils.cpp.

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

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

◆ ShortSizeFormatW()

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

Definition at line 673 of file utils.cpp.

676{
677 TRACE("(%lu, %p)\n", dwNumber, pszBuffer);
678 return StrFormatByteSizeW(dwNumber, pszBuffer, 0x8FFF);
679}
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 620 of file utils.cpp.

625{
626 TRACE("(%d, %p, 0x%X, %s)\n", csidl, hToken, dwFlags, debugstr_a(pszPath));
627 CStringW strPathW(pszPath);
628 return SHSetFolderPathW(csidl, hToken, dwFlags, strPathW);
629}
EXTERN_C HRESULT WINAPI SHSetFolderPathW(_In_ INT csidl, _In_ HANDLE hToken, _In_ DWORD dwFlags, _In_ LPCWSTR pszPath)
Definition: stubs.cpp:751

◆ SHSetUnreadMailCountW()

EXTERN_C HRESULT WINAPI SHSetUnreadMailCountW ( _In_ PCWSTR  pszMailAddress,
_In_ DWORD  dwCount,
_In_ PCWSTR  pszShellExecuteCommand 
)

Definition at line 1009 of file utils.cpp.

1013{
1014 CString strKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\";
1015 strKey += pszMailAddress;
1016
1017 HKEY hKey;
1018 DWORD dwDisposition;
1020 &hKey, &dwDisposition);
1021 if (error)
1022 return HRESULT_FROM_WIN32(error);
1023
1024 error = RegSetValueExW(hKey, L"MessageCount", 0, REG_DWORD, (PBYTE)&dwCount, sizeof(dwCount));
1025 if (error)
1026 {
1028 return HRESULT_FROM_WIN32(error);
1029 }
1030
1031 FILETIME FileTime;
1032 GetSystemTimeAsFileTime(&FileTime);
1033
1034 error = RegSetValueExW(hKey, L"TimeStamp", 0, REG_BINARY, (PBYTE)&FileTime, sizeof(FileTime));
1035 if (error)
1036 {
1038 return HRESULT_FROM_WIN32(error);
1039 }
1040
1041 WCHAR szBuff[2 * MAX_PATH];
1042 if (!PathUnExpandEnvStringsW(pszShellExecuteCommand, szBuff, _countof(szBuff)))
1043 {
1044 HRESULT hr = StringCchCopyW(szBuff, _countof(szBuff), pszShellExecuteCommand);
1046 {
1048 return hr;
1049 }
1050 }
1051
1052 DWORD cbValue = (lstrlenW(szBuff) + 1) * sizeof(WCHAR);
1053 error = RegSetValueExW(hKey, L"Application", 0, REG_SZ, (PBYTE)szBuff, cbValue);
1054
1056 return (error ? HRESULT_FROM_WIN32(error) : S_OK);
1057}
LONG WINAPI RegCreateKeyExW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey, _In_ DWORD Reserved, _In_opt_ LPWSTR lpClass, _In_ DWORD dwOptions, _In_ REGSAM samDesired, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _Out_ PHKEY phkResult, _Out_opt_ LPDWORD lpdwDisposition)
Definition: reg.c:1096
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
Definition: time.c:128
BOOL WINAPI PathUnExpandEnvStringsW(LPCWSTR path, LPWSTR buffer, UINT buf_len)
Definition: path.c:4181
#define KEY_SET_VALUE
Definition: nt_native.h:1017

Referenced by START_TEST().

◆ SHShouldShowWizards()

EXTERN_C HRESULT WINAPI SHShouldShowWizards ( _In_ IUnknown pUnknown)

Definition at line 216 of file utils.cpp.

217{
218 HRESULT hr;
219 IShellBrowser *pBrowser;
220
221 hr = IUnknown_QueryService(pUnknown, SID_STopWindow, IID_PPV_ARG(IShellBrowser, &pBrowser));
222 if (FAILED(hr))
223 return hr;
224
227 if (state.fWebView &&
228 !SHRegGetBoolUSValueW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
229 L"ShowWizardsTEST", FALSE, FALSE))
230 {
231 hr = S_FALSE;
232 }
233
234 pBrowser->Release();
235 return hr;
236}
static int state
Definition: maze.c:121
HRESULT WINAPI IUnknown_QueryService(IUnknown *, REFGUID, REFIID, LPVOID *)
Definition: ordinal.c:1501
BOOL WINAPI SHRegGetBoolUSValueW(LPCWSTR pszSubKey, LPCWSTR pszValue, BOOL fIgnoreHKCU, BOOL fDefault)
Definition: reg.c:770
VOID WINAPI SHGetSetSettings(LPSHELLSTATE lpss, DWORD dwMask, BOOL bSet)
Definition: shellord.c:225
#define SSF_WEBVIEW
Definition: shlobj.h:1628

Referenced by START_TEST().

◆ SHSkipJunctionBinding()

BOOL SHSkipJunctionBinding ( _In_ IBindCtx pbc,
_In_ CLSID pclsid 
)

Definition at line 291 of file utils.cpp.

292{
293 if (!pbc)
294 return FALSE;
295
296 BIND_OPTS BindOps = { sizeof(BindOps) };
297 if (SUCCEEDED(pbc->GetBindOptions(&BindOps)) && BindOps.grfFlags == OLECONTF_LINKS)
298 return TRUE;
299
300 return pclsid && SHSkipJunction(pbc, pclsid);
301}
BOOL WINAPI SHSkipJunction(IBindCtx *pbc, const CLSID *pclsid)
Definition: ordinal.c:4595

Referenced by CDesktopFolder::_ParseDisplayNameByParent().

◆ SHStartNetConnectionDialogA()

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

Definition at line 1480 of file utils.cpp.

1484{
1485 LPCWSTR pszRemoteNameW = NULL;
1486 CStringW strRemoteNameW;
1487
1488 TRACE("(%p, %s, %lu)\n", hwnd, debugstr_a(pszRemoteName), dwType);
1489
1490 if (pszRemoteName)
1491 {
1492 strRemoteNameW = pszRemoteName;
1493 pszRemoteNameW = strRemoteNameW;
1494 }
1495
1496 return SHStartNetConnectionDialogW(hwnd, pszRemoteNameW, dwType);
1497}
EXTERN_C HRESULT WINAPI SHStartNetConnectionDialogW(_In_ HWND hwnd, _In_ LPCWSTR pszRemoteName, _In_ DWORD dwType)
Definition: stubs.cpp:494

Referenced by SHStartNetConnectionDialog().

◆ SHTestTokenPrivilegeW()

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

Definition at line 763 of file utils.cpp.

766{
767 LUID Luid;
769 PTOKEN_PRIVILEGES pTokenPriv;
770 HANDLE hNewToken = NULL;
771 BOOL ret = FALSE;
772
773 TRACE("(%p, %s)\n", hToken, debugstr_w(lpName));
774
775 if (!lpName)
776 return FALSE;
777
778 if (!hToken)
779 {
780 if (!SHOpenEffectiveToken(&hNewToken))
781 goto Quit;
782
783 if (!hNewToken)
784 return FALSE;
785
786 hToken = hNewToken;
787 }
788
789 if (!LookupPrivilegeValueW(NULL, lpName, &Luid))
790 return FALSE;
791
792 dwLength = 0;
794 goto Quit;
795
797 if (!pTokenPriv)
798 goto Quit;
799
800 if (GetTokenInformation(hToken, TokenPrivileges, pTokenPriv, dwLength, &dwLength))
801 {
802 UINT iPriv, cPrivs;
803 cPrivs = pTokenPriv->PrivilegeCount;
804 for (iPriv = 0; !ret && iPriv < cPrivs; ++iPriv)
805 {
806 ret = RtlEqualLuid(&Luid, &pTokenPriv->Privileges[iPriv].Luid);
807 }
808 }
809
810 LocalFree(pTokenPriv);
811
812Quit:
813 if (hToken == hNewToken)
814 CloseHandle(hNewToken);
815
816 return ret;
817}
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:2820
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:304
@ TokenPrivileges
Definition: setypes.h:968
struct _TOKEN_PRIVILEGES * PTOKEN_PRIVILEGES

Referenced by IsShutdownAllowed().

◆ StrEndNA()

static PCSTR StrEndNA ( _In_ PCSTR  psz,
_In_ INT_PTR  cch 
)
static

Definition at line 17 of file utils.cpp.

18{
19 PCSTR pch, pchEnd = &psz[cch];
20 for (pch = psz; *pch && pch < pchEnd; pch = CharNextA(pch))
21 ;
22 if (pchEnd < pch) // A double-byte character detected at last?
23 pch -= 2; // The width of a double-byte character is 2
24 return pch;
25}
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
const char * PCSTR
Definition: typedefs.h:52
LPSTR WINAPI CharNextA(_In_ LPCSTR)

Referenced by StrRStrA().

◆ StrEndNW()

static PCWSTR StrEndNW ( _In_ PCWSTR  psz,
_In_ INT_PTR  cch 
)
static

Definition at line 27 of file utils.cpp.

28{
29 PCWSTR pch, pchEnd = &psz[cch];
30 for (pch = psz; *pch && pch < pchEnd; ++pch)
31 ;
32 return pch;
33}

Referenced by StrRStrW().

◆ StrRStrA()

EXTERN_C PSTR WINAPI StrRStrA ( _In_ PCSTR  pszSrc,
_In_opt_ PCSTR  pszLast,
_In_ PCSTR  pszSearch 
)

Definition at line 40 of file utils.cpp.

44{
45 INT cchSearch = lstrlenA(pszSearch);
46
47 PCSTR pchEnd = pszLast ? pszLast : &pszSrc[lstrlenA(pszSrc)];
48 if (pchEnd == pszSrc)
49 return NULL;
50
51 INT_PTR cchEnd = pchEnd - pszSrc;
52 for (;;)
53 {
54 --pchEnd;
55 --cchEnd;
56 if (!pchEnd)
57 break;
58 if (!StrCmpNA(pchEnd, pszSearch, cchSearch) && pchEnd == StrEndNA(pszSrc, cchEnd))
59 break;
60 if (pchEnd == pszSrc)
61 return NULL;
62 }
63
64 return const_cast<PSTR>(pchEnd);
65}
INT WINAPI StrCmpNA(LPCSTR lpszStr, LPCSTR lpszComp, INT iLen)
Definition: string.c:489
static PCSTR StrEndNA(_In_ PCSTR psz, _In_ INT_PTR cch)
Definition: utils.cpp:17
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
int32_t INT_PTR
Definition: typedefs.h:64
char * PSTR
Definition: typedefs.h:51

Referenced by TEST_StrRStrA().

◆ StrRStrW()

EXTERN_C PWSTR WINAPI StrRStrW ( _In_ PCWSTR  pszSrc,
_In_opt_ PCWSTR  pszLast,
_In_ PCWSTR  pszSearch 
)

Definition at line 72 of file utils.cpp.

76{
77 INT cchSearch = lstrlenW(pszSearch);
78
79 PCWSTR pchEnd = pszLast ? pszLast : &pszSrc[lstrlenW(pszSrc)];
80 if (pchEnd == pszSrc)
81 return NULL;
82
83 INT_PTR cchEnd = pchEnd - pszSrc;
84 for (;;)
85 {
86 --pchEnd;
87 --cchEnd;
88 if (!pchEnd)
89 break;
90 if (!StrCmpNW(pchEnd, pszSearch, cchSearch) && pchEnd == StrEndNW(pszSrc, cchEnd))
91 break;
92 if (pchEnd == pszSrc)
93 return NULL;
94 }
95
96 return const_cast<PWSTR>(pchEnd);
97}
INT WINAPI StrCmpNW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:500
static PCWSTR StrEndNW(_In_ PCWSTR psz, _In_ INT_PTR cch)
Definition: utils.cpp:27
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by TEST_StrRStrW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( shell  )