ntdll: Don't use current directory for libraries unless explicitly specified in the search path.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0aea7fc915
commit
6fb00db51e
|
@ -479,15 +479,13 @@ static void test_LoadLibraryEx_search_flags(void)
|
||||||
{ { 6, 5 }, 5, 0 },
|
{ { 6, 5 }, 5, 0 },
|
||||||
{ { 1, 1, 2 }, 0, 2 },
|
{ { 1, 1, 2 }, 0, 2 },
|
||||||
};
|
};
|
||||||
char *p, path[MAX_PATH], buf[MAX_PATH];
|
char *p, path[MAX_PATH], buf[MAX_PATH], curdir[MAX_PATH];
|
||||||
WCHAR bufW[MAX_PATH];
|
WCHAR bufW[MAX_PATH];
|
||||||
DLL_DIRECTORY_COOKIE cookies[4];
|
DLL_DIRECTORY_COOKIE cookies[4];
|
||||||
unsigned int i, j, k;
|
unsigned int i, j, k;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
HMODULE mod;
|
HMODULE mod;
|
||||||
|
|
||||||
if (!pAddDllDirectory || !pSetDllDirectoryA) return;
|
|
||||||
|
|
||||||
GetTempPathA( sizeof(path), path );
|
GetTempPathA( sizeof(path), path );
|
||||||
GetTempFileNameA( path, "tmp", 0, buf );
|
GetTempFileNameA( path, "tmp", 0, buf );
|
||||||
DeleteFileA( buf );
|
DeleteFileA( buf );
|
||||||
|
@ -503,6 +501,80 @@ static void test_LoadLibraryEx_search_flags(void)
|
||||||
sprintf( p, "\\%u\\winetestdll.dll", i );
|
sprintf( p, "\\%u\\winetestdll.dll", i );
|
||||||
create_test_dll( buf );
|
create_test_dll( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetCurrentDirectoryA( MAX_PATH, curdir );
|
||||||
|
*p = 0;
|
||||||
|
SetCurrentDirectoryA( buf );
|
||||||
|
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
mod = LoadLibraryA( "1\\winetestdll.dll" );
|
||||||
|
ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
|
||||||
|
FreeLibrary( mod );
|
||||||
|
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
sprintf( path, "%c:1\\winetestdll.dll", buf[0] );
|
||||||
|
mod = LoadLibraryA( path );
|
||||||
|
ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
|
||||||
|
FreeLibrary( mod );
|
||||||
|
|
||||||
|
if (pAddDllDirectory)
|
||||||
|
{
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
mod = LoadLibraryExA( "1\\winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
|
||||||
|
ok( !mod, "LoadLibrary succeeded\n" );
|
||||||
|
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
|
||||||
|
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
mod = LoadLibraryExA( path, 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
|
||||||
|
ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
|
||||||
|
FreeLibrary( mod );
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy( p, "\\1" );
|
||||||
|
SetCurrentDirectoryA( buf );
|
||||||
|
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
mod = LoadLibraryA( "winetestdll.dll" );
|
||||||
|
ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
|
||||||
|
FreeLibrary( mod );
|
||||||
|
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
sprintf( path, "%c:winetestdll.dll", buf[0] );
|
||||||
|
mod = LoadLibraryA( path );
|
||||||
|
ok( mod != NULL || broken(!mod), /* win10 disallows this but allows c:1\\winetestdll.dll */
|
||||||
|
"LoadLibrary failed err %u\n", GetLastError() );
|
||||||
|
if (!mod) ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
|
||||||
|
else FreeLibrary( mod );
|
||||||
|
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
sprintf( path, "%s\\winetestdll.dll", buf + 2 );
|
||||||
|
mod = LoadLibraryA( path );
|
||||||
|
ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
|
||||||
|
FreeLibrary( mod );
|
||||||
|
|
||||||
|
if (pAddDllDirectory)
|
||||||
|
{
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
|
||||||
|
ok( !mod, "LoadLibrary succeeded\n" );
|
||||||
|
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
|
||||||
|
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
mod = LoadLibraryExA( path, 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
|
||||||
|
ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
|
||||||
|
FreeLibrary( mod );
|
||||||
|
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
sprintf( path, "%s\\winetestdll.dll", buf + 2 );
|
||||||
|
mod = LoadLibraryExA( path, 0, LOAD_LIBRARY_SEARCH_SYSTEM32 );
|
||||||
|
ok( mod != NULL, "LoadLibrary failed err %u\n", GetLastError() );
|
||||||
|
FreeLibrary( mod );
|
||||||
|
}
|
||||||
|
|
||||||
|
SetCurrentDirectoryA( curdir );
|
||||||
|
|
||||||
|
if (!pAddDllDirectory || !pSetDllDirectoryA) goto done;
|
||||||
|
|
||||||
SetLastError( 0xdeadbeef );
|
SetLastError( 0xdeadbeef );
|
||||||
mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
|
mod = LoadLibraryExA( "winetestdll.dll", 0, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
|
||||||
ok( !mod, "LoadLibrary succeeded\n" );
|
ok( !mod, "LoadLibrary succeeded\n" );
|
||||||
|
@ -539,6 +611,11 @@ static void test_LoadLibraryEx_search_flags(void)
|
||||||
ok( !mod, "LoadLibrary succeeded\n" );
|
ok( !mod, "LoadLibrary succeeded\n" );
|
||||||
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
|
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
|
||||||
|
|
||||||
|
SetLastError( 0xdeadbeef );
|
||||||
|
mod = LoadLibraryA( "1\\winetestdll.dll" );
|
||||||
|
ok( !mod, "LoadLibrary succeeded\n" );
|
||||||
|
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
|
||||||
|
|
||||||
for (j = 0; j < ARRAY_SIZE(tests); j++)
|
for (j = 0; j < ARRAY_SIZE(tests); j++)
|
||||||
{
|
{
|
||||||
for (k = 0; tests[j].add_dirs[k]; k++)
|
for (k = 0; tests[j].add_dirs[k]; k++)
|
||||||
|
@ -575,6 +652,7 @@ static void test_LoadLibraryEx_search_flags(void)
|
||||||
for (k = 0; tests[j].add_dirs[k]; k++) pRemoveDllDirectory( cookies[k] );
|
for (k = 0; tests[j].add_dirs[k]; k++) pRemoveDllDirectory( cookies[k] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
for (i = 1; i <= 6; i++)
|
for (i = 1; i <= 6; i++)
|
||||||
{
|
{
|
||||||
sprintf( p, "\\%u\\winetestdll.dll", i );
|
sprintf( p, "\\%u\\winetestdll.dll", i );
|
||||||
|
|
|
@ -2442,23 +2442,17 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname,
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
*handle = open_dll_file( &nt_name, pwm, st );
|
*handle = open_dll_file( &nt_name, pwm, st );
|
||||||
goto found;
|
|
||||||
}
|
}
|
||||||
|
else /* not found, return the name as is, to be loaded as builtin */
|
||||||
/* not found */
|
|
||||||
|
|
||||||
if (!contains_path( libname ))
|
|
||||||
{
|
{
|
||||||
/* if libname doesn't contain a path at all, we simply return the name as is,
|
|
||||||
* to be loaded as builtin */
|
|
||||||
len = strlenW(libname) * sizeof(WCHAR);
|
len = strlenW(libname) * sizeof(WCHAR);
|
||||||
if (len >= *size) goto overflow;
|
if (len >= *size) goto overflow;
|
||||||
strcpyW( filename, libname );
|
strcpyW( filename, libname );
|
||||||
|
}
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* absolute path name, or relative path name but not found above */
|
/* absolute path name */
|
||||||
|
|
||||||
if (!RtlDosPathNameToNtPathName_U( libname, &nt_name, &file_part, NULL ))
|
if (!RtlDosPathNameToNtPathName_U( libname, &nt_name, &file_part, NULL ))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue