[PATCH] kernel32: Consider the working directory first when launching executables with CreateProcess.

Erich E. Hoover erich.e.hoover at gmail.com
Fri Apr 26 08:08:02 CDT 2019


On Fri, Apr 26, 2019 at 5:32 AM Alexandre Julliard <julliard at winehq.org> wrote:
> Vijay Kiran Kamuju <infyquest at gmail.com> writes:
> > ...
> > -    if (!SearchPathW( NULL, name, exeW, buflen, buffer, NULL ) &&
> > +    /* The working directory takes precedence over other locations for CreateProcess unless the
> > +     * 'NoDefaultCurrentDirectoryInExePath' environment variable is set (and the executable name
> > +     * does not contain a backslash). */
> > +    if ((NeedCurrentDirectoryForExePathW( name ) && GetCurrentDirectoryW( MAX_PATH, cur_dir) &&
> > +         !SearchPathW( cur_dir, name, exeW, buflen, buffer, NULL )) &&
> > +        /* not found in the working directory, try the system search path */
> > +        !SearchPathW( NULL, name, exeW, buflen, buffer, NULL ) &&
>
> This will break the search if the variable is set.

Huh, I wonder if this got broken in a rebase at some point or if I
just messed it up in the first place.  That should be:
if (!(NeedCurrentDirectoryForExePathW( name ) && GetCurrentDirectoryW(
MAX_PATH, cur_dir) &&
         SearchPathW( cur_dir, name, exeW, buflen, buffer, NULL )) &&
...

(try the current directory first, if the
NoDefaultCurrentDirectoryInExePath flag is not set, otherwise move on
to the other search paths)

Best,
Erich



More information about the wine-devel mailing list