Commit 47fed8f5 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Don't set the DllPath parameter by default.

Recent Windows versions don't set it either. Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 34884bf5
...@@ -144,9 +144,9 @@ static RTL_USER_PROCESS_PARAMETERS *create_process_params( const WCHAR *filename ...@@ -144,9 +144,9 @@ static RTL_USER_PROCESS_PARAMETERS *create_process_params( const WCHAR *filename
const STARTUPINFOW *startup ) const STARTUPINFOW *startup )
{ {
RTL_USER_PROCESS_PARAMETERS *params; RTL_USER_PROCESS_PARAMETERS *params;
UNICODE_STRING imageW, dllpathW, curdirW, cmdlineW, titleW, desktopW, runtimeW, newdirW; UNICODE_STRING imageW, curdirW, cmdlineW, titleW, desktopW, runtimeW, newdirW;
WCHAR imagepath[MAX_PATH]; WCHAR imagepath[MAX_PATH];
WCHAR *load_path, *dummy, *envW = env; WCHAR *envW = env;
if (!GetLongPathNameW( filename, imagepath, MAX_PATH )) lstrcpynW( imagepath, filename, MAX_PATH ); if (!GetLongPathNameW( filename, imagepath, MAX_PATH )) lstrcpynW( imagepath, filename, MAX_PATH );
if (!GetFullPathNameW( imagepath, MAX_PATH, imagepath, NULL )) lstrcpynW( imagepath, filename, MAX_PATH ); if (!GetFullPathNameW( imagepath, MAX_PATH, imagepath, NULL )) lstrcpynW( imagepath, filename, MAX_PATH );
...@@ -171,26 +171,22 @@ static RTL_USER_PROCESS_PARAMETERS *create_process_params( const WCHAR *filename ...@@ -171,26 +171,22 @@ static RTL_USER_PROCESS_PARAMETERS *create_process_params( const WCHAR *filename
else else
cur_dir = NULL; cur_dir = NULL;
} }
LdrGetDllPath( imagepath, LOAD_WITH_ALTERED_SEARCH_PATH, &load_path, &dummy );
RtlInitUnicodeString( &imageW, imagepath ); RtlInitUnicodeString( &imageW, imagepath );
RtlInitUnicodeString( &dllpathW, load_path );
RtlInitUnicodeString( &curdirW, cur_dir ); RtlInitUnicodeString( &curdirW, cur_dir );
RtlInitUnicodeString( &cmdlineW, cmdline ); RtlInitUnicodeString( &cmdlineW, cmdline );
RtlInitUnicodeString( &titleW, startup->lpTitle ? startup->lpTitle : imagepath ); RtlInitUnicodeString( &titleW, startup->lpTitle ? startup->lpTitle : imagepath );
RtlInitUnicodeString( &desktopW, startup->lpDesktop ); RtlInitUnicodeString( &desktopW, startup->lpDesktop );
runtimeW.Buffer = (WCHAR *)startup->lpReserved2; runtimeW.Buffer = (WCHAR *)startup->lpReserved2;
runtimeW.Length = runtimeW.MaximumLength = startup->cbReserved2; runtimeW.Length = runtimeW.MaximumLength = startup->cbReserved2;
if (RtlCreateProcessParametersEx( &params, &imageW, &dllpathW, cur_dir ? &curdirW : NULL, if (RtlCreateProcessParametersEx( &params, &imageW, NULL, cur_dir ? &curdirW : NULL,
&cmdlineW, envW, &titleW, &desktopW, &cmdlineW, envW, &titleW, &desktopW,
NULL, &runtimeW, PROCESS_PARAMS_FLAG_NORMALIZED )) NULL, &runtimeW, PROCESS_PARAMS_FLAG_NORMALIZED ))
{ {
RtlFreeUnicodeString( &newdirW ); RtlFreeUnicodeString( &newdirW );
RtlReleasePath( load_path );
if (envW != env) RtlFreeHeap( GetProcessHeap(), 0, envW ); if (envW != env) RtlFreeHeap( GetProcessHeap(), 0, envW );
return NULL; return NULL;
} }
RtlFreeUnicodeString( &newdirW ); RtlFreeUnicodeString( &newdirW );
RtlReleasePath( load_path );
if (flags & CREATE_NEW_PROCESS_GROUP) params->ConsoleFlags = 1; if (flags & CREATE_NEW_PROCESS_GROUP) params->ConsoleFlags = 1;
if (flags & CREATE_NEW_CONSOLE) params->ConsoleHandle = (HANDLE)1; /* KERNEL32_CONSOLE_ALLOC */ if (flags & CREATE_NEW_CONSOLE) params->ConsoleHandle = (HANDLE)1; /* KERNEL32_CONSOLE_ALLOC */
......
...@@ -542,7 +542,7 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu ...@@ -542,7 +542,7 @@ NTSTATUS WINAPI RtlCreateProcessParametersEx( RTL_USER_PROCESS_PARAMETERS **resu
RtlAcquirePebLock(); RtlAcquirePebLock();
cur_params = NtCurrentTeb()->Peb->ProcessParameters; cur_params = NtCurrentTeb()->Peb->ProcessParameters;
if (!DllPath) DllPath = &cur_params->DllPath; if (!DllPath) DllPath = &null_str;
if (!CurrentDirectoryName) if (!CurrentDirectoryName)
{ {
if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */ if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */
...@@ -637,46 +637,45 @@ void WINAPI RtlDestroyProcessParameters( RTL_USER_PROCESS_PARAMETERS *params ) ...@@ -637,46 +637,45 @@ void WINAPI RtlDestroyProcessParameters( RTL_USER_PROCESS_PARAMETERS *params )
*/ */
void init_user_process_params(void) void init_user_process_params(void)
{ {
WCHAR *env, *load_path, *dummy; WCHAR *env;
SIZE_T env_size; SIZE_T env_size;
RTL_USER_PROCESS_PARAMETERS *new_params, *params = NtCurrentTeb()->Peb->ProcessParameters; RTL_USER_PROCESS_PARAMETERS *new_params, *params = NtCurrentTeb()->Peb->ProcessParameters;
UNICODE_STRING curdir, dllpath; UNICODE_STRING curdir;
/* environment needs to be a separate memory block */ /* environment needs to be a separate memory block */
env_size = params->EnvironmentSize; env_size = params->EnvironmentSize;
env = params->Environment;
if ((env = RtlAllocateHeap( GetProcessHeap(), 0, max( env_size, sizeof(WCHAR) )))) if ((env = RtlAllocateHeap( GetProcessHeap(), 0, max( env_size, sizeof(WCHAR) ))))
{ {
if (env_size) memcpy( env, params->Environment, env_size ); if (env_size) memcpy( env, params->Environment, env_size );
else env[0] = 0; else env[0] = 0;
params->Environment = env;
} }
if (!params->DllPath.MaximumLength) /* not inherited from parent process */ params->Environment = NULL; /* avoid copying it */
{ if (RtlCreateProcessParametersEx( &new_params, &params->ImagePathName, &params->DllPath,
LdrGetDllPath( params->ImagePathName.Buffer, 0, &load_path, &dummy ); &params->CurrentDirectory.DosPath,
RtlInitUnicodeString( &dllpath, load_path ); &params->CommandLine, NULL, &params->WindowTitle, &params->Desktop,
&params->ShellInfo, &params->RuntimeInfo,
env = params->Environment; PROCESS_PARAMS_FLAG_NORMALIZED ))
params->Environment = NULL; /* avoid copying it */ return;
if (RtlCreateProcessParametersEx( &new_params, &params->ImagePathName, &dllpath,
&params->CurrentDirectory.DosPath, new_params->Environment = env;
&params->CommandLine, NULL, &params->ImagePathName, NULL, NULL, NULL, new_params->DebugFlags = params->DebugFlags;
PROCESS_PARAMS_FLAG_NORMALIZED )) new_params->ConsoleHandle = params->ConsoleHandle;
return; new_params->ConsoleFlags = params->ConsoleFlags;
new_params->hStdInput = params->hStdInput;
new_params->Environment = env; new_params->hStdOutput = params->hStdOutput;
new_params->hStdInput = params->hStdInput; new_params->hStdError = params->hStdError;
new_params->hStdOutput = params->hStdOutput; new_params->dwX = params->dwX;
new_params->hStdError = params->hStdError; new_params->dwY = params->dwY;
new_params->ConsoleHandle = params->ConsoleHandle; new_params->dwXSize = params->dwXSize;
new_params->dwXCountChars = params->dwXCountChars; new_params->dwYSize = params->dwYSize;
new_params->dwYCountChars = params->dwYCountChars; new_params->dwXCountChars = params->dwXCountChars;
new_params->wShowWindow = params->wShowWindow; new_params->dwYCountChars = params->dwYCountChars;
NtCurrentTeb()->Peb->ProcessParameters = params = new_params; new_params->dwFillAttribute = params->dwFillAttribute;
new_params->dwFlags = params->dwFlags;
RtlReleasePath( load_path ); new_params->wShowWindow = params->wShowWindow;
}
NtCurrentTeb()->Peb->ProcessParameters = params = new_params;
if (RtlSetCurrentDirectory_U( &params->CurrentDirectory.DosPath )) if (RtlSetCurrentDirectory_U( &params->CurrentDirectory.DosPath ))
{ {
......
...@@ -80,6 +80,7 @@ static ULONG path_safe_mode; /* path mode set by RtlSetSearchPathMode */ ...@@ -80,6 +80,7 @@ static ULONG path_safe_mode; /* path mode set by RtlSetSearchPathMode */
static ULONG dll_safe_mode = 1; /* dll search mode */ static ULONG dll_safe_mode = 1; /* dll search mode */
static UNICODE_STRING dll_directory; /* extra path for LdrSetDllDirectory */ static UNICODE_STRING dll_directory; /* extra path for LdrSetDllDirectory */
static DWORD default_search_flags; /* default flags set by LdrSetDefaultDllDirectories */ static DWORD default_search_flags; /* default flags set by LdrSetDefaultDllDirectories */
static WCHAR *default_load_path; /* default dll search path */
struct dll_dir_entry struct dll_dir_entry
{ {
...@@ -1687,9 +1688,8 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name, ...@@ -1687,9 +1688,8 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
else if ((exports = RtlImageDirectoryEntryToData( module, TRUE, else if ((exports = RtlImageDirectoryEntryToData( module, TRUE,
IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size ))) IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size )))
{ {
LPCWSTR load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer; void *proc = name ? find_named_export( module, exports, exp_size, name->Buffer, -1, NULL )
void *proc = name ? find_named_export( module, exports, exp_size, name->Buffer, -1, load_path ) : find_ordinal_export( module, exports, exp_size, ord - exports->Base, NULL );
: find_ordinal_export( module, exports, exp_size, ord - exports->Base, load_path );
if (proc) if (proc)
{ {
*address = proc; *address = proc;
...@@ -2423,6 +2423,10 @@ static void build_main_module(void) ...@@ -2423,6 +2423,10 @@ static void build_main_module(void)
RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters; RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters;
void *module = NtCurrentTeb()->Peb->ImageBaseAddress; void *module = NtCurrentTeb()->Peb->ImageBaseAddress;
default_load_path = params->DllPath.Buffer;
if (!default_load_path)
get_dll_load_path( params->ImagePathName.Buffer, NULL, dll_safe_mode, &default_load_path );
NtQueryInformationProcess( GetCurrentProcess(), ProcessImageInformation, &info, sizeof(info), NULL ); NtQueryInformationProcess( GetCurrentProcess(), ProcessImageInformation, &info, sizeof(info), NULL );
if (info.ImageCharacteristics & IMAGE_FILE_DLL) if (info.ImageCharacteristics & IMAGE_FILE_DLL)
{ {
...@@ -2438,8 +2442,7 @@ static void build_main_module(void) ...@@ -2438,8 +2442,7 @@ static void build_main_module(void)
#endif #endif
status = RtlDosPathNameToNtPathName_U_WithStatus( params->ImagePathName.Buffer, &nt_name, NULL, NULL ); status = RtlDosPathNameToNtPathName_U_WithStatus( params->ImagePathName.Buffer, &nt_name, NULL, NULL );
if (status) goto failed; if (status) goto failed;
status = build_module( params->DllPath.Buffer, &nt_name, &module, &info, status = build_module( NULL, &nt_name, &module, &info, NULL, DONT_RESOLVE_DLL_REFERENCES, &wm );
NULL, DONT_RESOLVE_DLL_REFERENCES, &wm );
RtlFreeUnicodeString( &nt_name ); RtlFreeUnicodeString( &nt_name );
if (!status) return; if (!status) return;
failed: failed:
...@@ -2561,7 +2564,10 @@ static NTSTATUS search_dll_file( LPCWSTR paths, LPCWSTR search, UNICODE_STRING * ...@@ -2561,7 +2564,10 @@ static NTSTATUS search_dll_file( LPCWSTR paths, LPCWSTR search, UNICODE_STRING *
WCHAR *name; WCHAR *name;
BOOL found_image = FALSE; BOOL found_image = FALSE;
NTSTATUS status = STATUS_DLL_NOT_FOUND; NTSTATUS status = STATUS_DLL_NOT_FOUND;
ULONG len = wcslen( paths ); ULONG len;
if (!paths) paths = default_load_path;
len = wcslen( paths );
if (len < wcslen( system_dir )) len = wcslen( system_dir ); if (len < wcslen( system_dir )) len = wcslen( system_dir );
len += wcslen( search ) + 2; len += wcslen( search ) + 2;
...@@ -2796,7 +2802,6 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags, ...@@ -2796,7 +2802,6 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
RtlEnterCriticalSection( &loader_section ); RtlEnterCriticalSection( &loader_section );
if (!path_name) path_name = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
nts = load_dll( path_name, libname->Buffer, L".dll", flags, &wm ); nts = load_dll( path_name, libname->Buffer, L".dll", flags, &wm );
if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS)) if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
...@@ -2829,8 +2834,6 @@ NTSTATUS WINAPI LdrGetDllHandle( LPCWSTR load_path, ULONG flags, const UNICODE_S ...@@ -2829,8 +2834,6 @@ NTSTATUS WINAPI LdrGetDllHandle( LPCWSTR load_path, ULONG flags, const UNICODE_S
RtlEnterCriticalSection( &loader_section ); RtlEnterCriticalSection( &loader_section );
if (!load_path) load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
status = find_dll_file( load_path, name->Buffer, L".dll", &nt_name, &wm, &mapping, &image_info, &id ); status = find_dll_file( load_path, name->Buffer, L".dll", &nt_name, &wm, &mapping, &image_info, &id );
if (wm) *base = wm->ldr.DllBase; if (wm) *base = wm->ldr.DllBase;
...@@ -3465,7 +3468,6 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR ...@@ -3465,7 +3468,6 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
ULONG_PTR cookie; ULONG_PTR cookie;
WINE_MODREF *wm; WINE_MODREF *wm;
void **entry; void **entry;
LPCWSTR load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
#ifdef __i386__ #ifdef __i386__
entry = (void **)&context->Eax; entry = (void **)&context->Eax;
...@@ -3488,9 +3490,9 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR ...@@ -3488,9 +3490,9 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
{ {
actctx_init(); actctx_init();
if (wm->ldr.Flags & LDR_COR_ILONLY) if (wm->ldr.Flags & LDR_COR_ILONLY)
status = fixup_imports_ilonly( wm, load_path, entry ); status = fixup_imports_ilonly( wm, NULL, entry );
else else
status = fixup_imports( wm, load_path ); status = fixup_imports( wm, NULL );
if (status) if (status)
{ {
...@@ -3971,7 +3973,6 @@ static void map_wow64cpu(void) ...@@ -3971,7 +3973,6 @@ static void map_wow64cpu(void)
*/ */
static NTSTATUS process_init(void) static NTSTATUS process_init(void)
{ {
RTL_USER_PROCESS_PARAMETERS *params;
WINE_MODREF *wm; WINE_MODREF *wm;
NTSTATUS status; NTSTATUS status;
ANSI_STRING func_name; ANSI_STRING func_name;
...@@ -4006,8 +4007,6 @@ static NTSTATUS process_init(void) ...@@ -4006,8 +4007,6 @@ static NTSTATUS process_init(void)
#endif #endif
init_user_process_params(); init_user_process_params();
params = peb->ProcessParameters;
load_global_options(); load_global_options();
version_init(); version_init();
build_main_module(); build_main_module();
...@@ -4032,8 +4031,7 @@ static NTSTATUS process_init(void) ...@@ -4032,8 +4031,7 @@ static NTSTATUS process_init(void)
map_wow64cpu(); map_wow64cpu();
#endif #endif
if ((status = load_dll( params->DllPath.Buffer, L"C:\\windows\\system32\\kernel32.dll", if ((status = load_dll( NULL, L"C:\\windows\\system32\\kernel32.dll", NULL, 0, &wm )) != STATUS_SUCCESS)
NULL, 0, &wm )) != STATUS_SUCCESS)
{ {
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status ); MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
NtTerminateProcess( GetCurrentProcess(), status ); NtTerminateProcess( GetCurrentProcess(), status );
......
...@@ -1767,7 +1767,6 @@ static void run_wineboot( WCHAR *env, SIZE_T size ) ...@@ -1767,7 +1767,6 @@ static void run_wineboot( WCHAR *env, SIZE_T size )
params.Environment = env; params.Environment = env;
params.EnvironmentSize = size; params.EnvironmentSize = size;
init_unicode_string( &params.CurrentDirectory.DosPath, system_dir + 4 ); init_unicode_string( &params.CurrentDirectory.DosPath, system_dir + 4 );
init_unicode_string( &params.DllPath, system_dir + 4 );
init_unicode_string( &params.ImagePathName, appnameW + 4 ); init_unicode_string( &params.ImagePathName, appnameW + 4 );
init_unicode_string( &params.CommandLine, cmdlineW ); init_unicode_string( &params.CommandLine, cmdlineW );
init_unicode_string( &params.WindowTitle, appnameW + 4 ); init_unicode_string( &params.WindowTitle, appnameW + 4 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment