Commit e99811ae authored by Alexandre Julliard's avatar Alexandre Julliard

kernel32: Implement SetDefaultDllDirectories.

parent 66e302f8
...@@ -48,6 +48,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(module); ...@@ -48,6 +48,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(module);
#define NE_FFLAGS_LIBMODULE 0x8000 #define NE_FFLAGS_LIBMODULE 0x8000
static WCHAR *dll_directory; /* extra path for SetDllDirectoryW */ static WCHAR *dll_directory; /* extra path for SetDllDirectoryW */
static DWORD default_search_flags; /* default flags set by SetDefaultDllDirectories */
static CRITICAL_SECTION dlldir_section; static CRITICAL_SECTION dlldir_section;
static CRITICAL_SECTION_DEBUG critsect_debug = static CRITICAL_SECTION_DEBUG critsect_debug =
...@@ -58,6 +59,10 @@ static CRITICAL_SECTION_DEBUG critsect_debug = ...@@ -58,6 +59,10 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
}; };
static CRITICAL_SECTION dlldir_section = { &critsect_debug, -1, 0, 0, 0, 0 }; static CRITICAL_SECTION dlldir_section = { &critsect_debug, -1, 0, 0, 0, 0 };
static const DWORD load_library_search_flags = (LOAD_LIBRARY_SEARCH_APPLICATION_DIR |
LOAD_LIBRARY_SEARCH_USER_DIRS |
LOAD_LIBRARY_SEARCH_SYSTEM32 |
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
/**************************************************************************** /****************************************************************************
* GetDllDirectoryA (KERNEL32.@) * GetDllDirectoryA (KERNEL32.@)
...@@ -148,6 +153,21 @@ BOOL WINAPI SetDllDirectoryW( LPCWSTR dir ) ...@@ -148,6 +153,21 @@ BOOL WINAPI SetDllDirectoryW( LPCWSTR dir )
} }
/*************************************************************************
* SetDefaultDllDirectories (KERNEL32.@)
*/
BOOL WINAPI SetDefaultDllDirectories( DWORD flags )
{
if (!flags || (flags & ~load_library_search_flags))
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
default_search_flags = flags;
return TRUE;
}
/**************************************************************************** /****************************************************************************
* DisableThreadLibraryCalls (KERNEL32.@) * DisableThreadLibraryCalls (KERNEL32.@)
* *
...@@ -964,16 +984,14 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags ) ...@@ -964,16 +984,14 @@ static HMODULE load_library( const UNICODE_STRING *libname, DWORD flags )
NTSTATUS nts; NTSTATUS nts;
HMODULE hModule; HMODULE hModule;
WCHAR *load_path; WCHAR *load_path;
static const DWORD unsupported_flags = static const DWORD unsupported_flags = load_library_search_flags |
LOAD_IGNORE_CODE_AUTHZ_LEVEL | LOAD_IGNORE_CODE_AUTHZ_LEVEL |
LOAD_LIBRARY_AS_IMAGE_RESOURCE | LOAD_LIBRARY_AS_IMAGE_RESOURCE |
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE | LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE |
LOAD_LIBRARY_REQUIRE_SIGNED_TARGET | LOAD_LIBRARY_REQUIRE_SIGNED_TARGET |
LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR;
LOAD_LIBRARY_SEARCH_APPLICATION_DIR |
LOAD_LIBRARY_SEARCH_USER_DIRS | if (!(flags & load_library_search_flags)) flags |= default_search_flags;
LOAD_LIBRARY_SEARCH_SYSTEM32 |
LOAD_LIBRARY_SEARCH_DEFAULT_DIRS;
if( flags & unsupported_flags) if( flags & unsupported_flags)
FIXME("unsupported flag(s) used (flags: 0x%08x)\n", flags); FIXME("unsupported flag(s) used (flags: 0x%08x)\n", flags);
......
...@@ -2081,13 +2081,3 @@ BOOL WINAPI SetSearchPathMode(DWORD flags) ...@@ -2081,13 +2081,3 @@ BOOL WINAPI SetSearchPathMode(DWORD flags)
SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE; return FALSE;
} }
/*************************************************************************
* SetDefaultDllDirectories (KERNEL32.@)
*/
BOOL WINAPI SetDefaultDllDirectories(DWORD flags)
{
FIXME("(%x): stub\n", flags);
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE;
}
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
static DWORD (WINAPI *pGetDllDirectoryA)(DWORD,LPSTR); static DWORD (WINAPI *pGetDllDirectoryA)(DWORD,LPSTR);
static DWORD (WINAPI *pGetDllDirectoryW)(DWORD,LPWSTR); static DWORD (WINAPI *pGetDllDirectoryW)(DWORD,LPWSTR);
static BOOL (WINAPI *pSetDllDirectoryA)(LPCSTR); static BOOL (WINAPI *pSetDllDirectoryA)(LPCSTR);
static BOOL (WINAPI *pSetDefaultDllDirectories)(DWORD);
static BOOL (WINAPI *pGetModuleHandleExA)(DWORD,LPCSTR,HMODULE*); static BOOL (WINAPI *pGetModuleHandleExA)(DWORD,LPCSTR,HMODULE*);
static BOOL (WINAPI *pGetModuleHandleExW)(DWORD,LPCWSTR,HMODULE*); static BOOL (WINAPI *pGetModuleHandleExW)(DWORD,LPCWSTR,HMODULE*);
static BOOL (WINAPI *pK32GetModuleInformation)(HANDLE process, HMODULE module, static BOOL (WINAPI *pK32GetModuleInformation)(HANDLE process, HMODULE module,
...@@ -515,6 +516,7 @@ static void init_pointers(void) ...@@ -515,6 +516,7 @@ static void init_pointers(void)
MAKEFUNC(GetDllDirectoryA); MAKEFUNC(GetDllDirectoryA);
MAKEFUNC(GetDllDirectoryW); MAKEFUNC(GetDllDirectoryW);
MAKEFUNC(SetDllDirectoryA); MAKEFUNC(SetDllDirectoryA);
MAKEFUNC(SetDefaultDllDirectories);
MAKEFUNC(GetModuleHandleExA); MAKEFUNC(GetModuleHandleExA);
MAKEFUNC(GetModuleHandleExW); MAKEFUNC(GetModuleHandleExW);
MAKEFUNC(K32GetModuleInformation); MAKEFUNC(K32GetModuleInformation);
...@@ -739,6 +741,70 @@ static void testK32GetModuleInformation(void) ...@@ -739,6 +741,70 @@ static void testK32GetModuleInformation(void)
ok(info.EntryPoint != NULL, "Expected nonzero entrypoint\n"); ok(info.EntryPoint != NULL, "Expected nonzero entrypoint\n");
} }
static void test_SetDefaultDllDirectories(void)
{
HMODULE mod;
BOOL ret;
if (!pSetDefaultDllDirectories)
{
win_skip( "SetDefaultDllDirectories not available\n" );
return;
}
mod = LoadLibraryA( "authz.dll" );
ok( mod != NULL, "loading authz failed\n" );
FreeLibrary( mod );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_USER_DIRS );
ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
mod = LoadLibraryA( "authz.dll" );
todo_wine ok( !mod, "loading authz succeeded\n" );
FreeLibrary( mod );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_SYSTEM32 );
ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
mod = LoadLibraryA( "authz.dll" );
ok( mod != NULL, "loading authz failed\n" );
FreeLibrary( mod );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
mod = LoadLibraryA( "authz.dll" );
todo_wine ok( !mod, "loading authz succeeded\n" );
FreeLibrary( mod );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
ok( ret, "SetDefaultDllDirectories failed err %u\n", GetLastError() );
mod = LoadLibraryA( "authz.dll" );
ok( mod != NULL, "loading authz failed\n" );
FreeLibrary( mod );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( 0 );
ok( !ret, "SetDefaultDllDirectories succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( 3 );
ok( !ret, "SetDefaultDllDirectories succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_APPLICATION_DIR | 0x8000 );
ok( !ret, "SetDefaultDllDirectories succeeded\n" );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR );
ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_USER_DIRS );
ok( !ret || broken(ret) /* win7 */, "SetDefaultDllDirectories succeeded\n" );
if (!ret) ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
/* restore some sane defaults */
pSetDefaultDllDirectories( LOAD_LIBRARY_SEARCH_DEFAULT_DIRS );
}
START_TEST(module) START_TEST(module)
{ {
WCHAR filenameW[MAX_PATH]; WCHAR filenameW[MAX_PATH];
...@@ -768,4 +834,5 @@ START_TEST(module) ...@@ -768,4 +834,5 @@ START_TEST(module)
testLoadLibraryEx(); testLoadLibraryEx();
testGetModuleHandleEx(); testGetModuleHandleEx();
testK32GetModuleInformation(); testK32GetModuleInformation();
test_SetDefaultDllDirectories();
} }
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