mirror of
https://github.com/reactos/reactos.git
synced 2025-02-28 19:32:59 +00:00
[SHELL32] Expand .lnk working directory string before checking if it's valid (#7710)
Handles the case where SEE_MASK_DOENVSUBST will expand it later inside ShellExeute. CORE-19987
This commit is contained in:
parent
364d6e0346
commit
e4216bd015
1 changed files with 17 additions and 1 deletions
|
@ -216,6 +216,22 @@ static LPWSTR __inline strdupW(LPCWSTR src)
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BOOL PathEnvSubstIsDirectory(LPCWSTR pszPath)
|
||||||
|
{
|
||||||
|
// Note: Don't call SHExpandEnvironmentStringsW here, we need the required length
|
||||||
|
WCHAR szStack[MAX_PATH];
|
||||||
|
DWORD cch = ExpandEnvironmentStringsW(pszPath, szStack, _countof(szStack));
|
||||||
|
if (cch <= _countof(szStack))
|
||||||
|
return cch && PathIsDirectory(szStack);
|
||||||
|
|
||||||
|
PWSTR szHeap = (PWSTR)SHAlloc(cch);
|
||||||
|
if (!szHeap)
|
||||||
|
return FALSE;
|
||||||
|
BOOL bResult = ExpandEnvironmentStringsW(pszPath, szHeap, cch) && PathIsDirectory(szHeap);
|
||||||
|
SHFree(szHeap);
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Use it for constructor & destructor too
|
// TODO: Use it for constructor & destructor too
|
||||||
VOID CShellLink::Reset()
|
VOID CShellLink::Reset()
|
||||||
{
|
{
|
||||||
|
@ -2667,7 +2683,7 @@ HRESULT CShellLink::DoOpen(LPCMINVOKECOMMANDINFO lpici)
|
||||||
sei.nShow = lpici->nShow; // Allow invoker to override .lnk show mode
|
sei.nShow = lpici->nShow; // Allow invoker to override .lnk show mode
|
||||||
|
|
||||||
// Use the invoker specified working directory if the link did not specify one
|
// Use the invoker specified working directory if the link did not specify one
|
||||||
if (StrIsNullOrEmpty(sei.lpDirectory) || !PathIsDirectoryW(sei.lpDirectory))
|
if (StrIsNullOrEmpty(sei.lpDirectory) || !PathEnvSubstIsDirectory(sei.lpDirectory))
|
||||||
{
|
{
|
||||||
LPCSTR pszDirA = lpici->lpDirectory;
|
LPCSTR pszDirA = lpici->lpDirectory;
|
||||||
if (unicode && !StrIsNullOrEmpty(iciex->lpDirectoryW))
|
if (unicode && !StrIsNullOrEmpty(iciex->lpDirectoryW))
|
||||||
|
|
Loading…
Reference in a new issue