shell32: Don't use the working directory passed into ShellExecute* functions if it isn't valid.
This commit is contained in:
parent
6c9b788fb8
commit
94074ad31e
|
@ -306,14 +306,25 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
|||
UINT gcdret = 0;
|
||||
WCHAR curdir[MAX_PATH];
|
||||
DWORD dwCreationFlags;
|
||||
const WCHAR *lpDirectory = NULL;
|
||||
|
||||
TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd), debugstr_w(psei->lpDirectory));
|
||||
|
||||
/* make sure we don't fail the CreateProcess if the calling app passes in
|
||||
* a bad working directory */
|
||||
if (psei->lpDirectory && psei->lpDirectory[0])
|
||||
{
|
||||
DWORD attr = GetFileAttributesW(psei->lpDirectory);
|
||||
if (attr != INVALID_FILE_ATTRIBUTES && attr & FILE_ATTRIBUTE_DIRECTORY)
|
||||
lpDirectory = psei->lpDirectory;
|
||||
}
|
||||
|
||||
/* ShellExecute specifies the command from psei->lpDirectory
|
||||
* if present. Not from the current dir as CreateProcess does */
|
||||
if( psei->lpDirectory && psei->lpDirectory[0] )
|
||||
if( lpDirectory )
|
||||
if( ( gcdret = GetCurrentDirectoryW( MAX_PATH, curdir)))
|
||||
if( !SetCurrentDirectoryW( psei->lpDirectory))
|
||||
ERR("cannot set directory %s\n", debugstr_w(psei->lpDirectory));
|
||||
if( !SetCurrentDirectoryW( lpDirectory))
|
||||
ERR("cannot set directory %s\n", debugstr_w(lpDirectory));
|
||||
ZeroMemory(&startup,sizeof(STARTUPINFOW));
|
||||
startup.cb = sizeof(STARTUPINFOW);
|
||||
startup.dwFlags = STARTF_USESHOWWINDOW;
|
||||
|
@ -322,8 +333,7 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
|
|||
if (psei->fMask & SEE_MASK_NO_CONSOLE)
|
||||
dwCreationFlags |= CREATE_NEW_CONSOLE;
|
||||
if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, dwCreationFlags, env,
|
||||
psei->lpDirectory && *psei->lpDirectory ? psei->lpDirectory : NULL,
|
||||
&startup, &info))
|
||||
lpDirectory, &startup, &info))
|
||||
{
|
||||
/* Give 30 seconds to the app to come up, if desired. Probably only needed
|
||||
when starting app immediately before making a DDE connection. */
|
||||
|
|
Loading…
Reference in New Issue