From: "Erich E. Hoover" erich.e.hoover@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=23934 From: Erich E. Hoover erich.e.hoover@gmail.com Signed-off-by: Vijay Kiran Kamuju infyquest@gmail.com --- dlls/kernel32/process.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 09f0433deb0..39e47390558 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -439,9 +439,17 @@ static HANDLE open_exe_file( const WCHAR *name, BOOL *is_64bit ) */ static BOOL find_exe_file( const WCHAR *name, WCHAR *buffer, int buflen, HANDLE *handle ) { + WCHAR cur_dir[MAX_PATH]; + TRACE("looking for %s\n", debugstr_w(name) );
- 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 ) && /* no builtin found, try native without extension in case it is a Unix app */ !SearchPathW( NULL, name, NULL, buflen, buffer, NULL )) return FALSE;
Vijay Kiran Kamuju infyquest@gmail.com writes:
@@ -439,9 +439,17 @@ static HANDLE open_exe_file( const WCHAR *name, BOOL *is_64bit ) */ static BOOL find_exe_file( const WCHAR *name, WCHAR *buffer, int buflen, HANDLE *handle ) {
- WCHAR cur_dir[MAX_PATH];
- TRACE("looking for %s\n", debugstr_w(name) );
- 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.
On Fri, Apr 26, 2019 at 1:31 PM Alexandre Julliard julliard@winehq.org wrote:
Vijay Kiran Kamuju infyquest@gmail.com writes:
@@ -439,9 +439,17 @@ static HANDLE open_exe_file( const WCHAR *name, BOOL *is_64bit ) */ static BOOL find_exe_file( const WCHAR *name, WCHAR *buffer, int buflen, HANDLE *handle ) {
- WCHAR cur_dir[MAX_PATH];
- TRACE("looking for %s\n", debugstr_w(name) );
- 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.
Yes, it will break. But we dont have implementation for NoDefaultCurrentDirectoryInExePath function as of now. https://msdn.microsoft.com/en-us/library/windows/desktop/ms684269(v=vs.85).a... Sometimes this is also set via registry, I dont where its stored as per documentation the location varies per windows version. I dont know any applications that use this environment variable. --- Vijay
-- Alexandre Julliard julliard@winehq.org
On Fri, Apr 26, 2019 at 1:55 PM Vijay Kiran Kamuju infyquest@gmail.com wrote:
On Fri, Apr 26, 2019 at 1:31 PM Alexandre Julliard julliard@winehq.org wrote:
Vijay Kiran Kamuju infyquest@gmail.com writes:
@@ -439,9 +439,17 @@ static HANDLE open_exe_file( const WCHAR *name, BOOL *is_64bit ) */ static BOOL find_exe_file( const WCHAR *name, WCHAR *buffer, int buflen, HANDLE *handle ) {
- WCHAR cur_dir[MAX_PATH];
- TRACE("looking for %s\n", debugstr_w(name) );
- 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.
Yes, it will break. But we dont have implementation for NoDefaultCurrentDirectoryInExePath function as of now. https://msdn.microsoft.com/en-us/library/windows/desktop/ms684269(v=vs.85).a... Sometimes this is also set via registry, I dont where its stored as per documentation the location varies per windows version. I dont know any applications that use this environment variable.
Please ignore this mail. I need to investigate more on this.
Vijay
-- Alexandre Julliard julliard@winehq.org
On Fri, Apr 26, 2019 at 5:32 AM Alexandre Julliard julliard@winehq.org wrote:
Vijay Kiran Kamuju infyquest@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