From c258b5ef1100c8c238aab0a17ca743a326829aac Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sun, 20 Oct 2019 13:54:05 +0200 Subject: [PATCH] kernel32: Add the new image path to the dll path for a new process. Signed-off-by: Alexandre Julliard --- dlls/kernel32/process.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index d2682ac83ec..693179fa05a 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -1885,9 +1885,9 @@ static RTL_USER_PROCESS_PARAMETERS *create_process_params( LPCWSTR filename, LPC const STARTUPINFOW *startup ) { RTL_USER_PROCESS_PARAMETERS *params; - UNICODE_STRING imageW, curdirW, cmdlineW, titleW, desktopW, runtimeW, newdirW; + UNICODE_STRING imageW, dllpathW, curdirW, cmdlineW, titleW, desktopW, runtimeW, newdirW; WCHAR imagepath[MAX_PATH]; - WCHAR *envW = env; + WCHAR *load_path, *dummy, *envW = env; if(!GetLongPathNameW( filename, imagepath, MAX_PATH )) lstrcpynW( imagepath, filename, MAX_PATH ); @@ -1914,20 +1914,24 @@ static RTL_USER_PROCESS_PARAMETERS *create_process_params( LPCWSTR filename, LPC else cur_dir = NULL; } + LdrGetDllPath( imagepath, LOAD_WITH_ALTERED_SEARCH_PATH, &load_path, &dummy ); RtlInitUnicodeString( &imageW, imagepath ); + RtlInitUnicodeString( &dllpathW, load_path ); RtlInitUnicodeString( &curdirW, cur_dir ); RtlInitUnicodeString( &cmdlineW, cmdline ); RtlInitUnicodeString( &titleW, startup->lpTitle ? startup->lpTitle : imagepath ); RtlInitUnicodeString( &desktopW, startup->lpDesktop ); runtimeW.Buffer = (WCHAR *)startup->lpReserved2; runtimeW.Length = runtimeW.MaximumLength = startup->cbReserved2; - if (RtlCreateProcessParametersEx( ¶ms, &imageW, NULL, cur_dir ? &curdirW : NULL, + if (RtlCreateProcessParametersEx( ¶ms, &imageW, &dllpathW, cur_dir ? &curdirW : NULL, &cmdlineW, envW, &titleW, &desktopW, NULL, &runtimeW, PROCESS_PARAMS_FLAG_NORMALIZED )) { + RtlReleasePath( load_path ); if (envW != env) HeapFree( GetProcessHeap(), 0, envW ); return NULL; } + RtlReleasePath( load_path ); if (flags & CREATE_NEW_PROCESS_GROUP) params->ConsoleFlags = 1; if (flags & CREATE_NEW_CONSOLE) params->ConsoleHandle = KERNEL32_CONSOLE_ALLOC;