Commit 7b233f30 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Map explicitly loaded apiset dlls to their target library.

parent 31e15136
...@@ -708,7 +708,6 @@ static void test_LoadLibraryEx_search_flags(void) ...@@ -708,7 +708,6 @@ static void test_LoadLibraryEx_search_flags(void)
ok( !!mod, "Got NULL module, error %u.\n", GetLastError() ); ok( !!mod, "Got NULL module, error %u.\n", GetLastError() );
ok( !!GetModuleHandleA( apiset_dll ), "Got NULL handle.\n" ); ok( !!GetModuleHandleA( apiset_dll ), "Got NULL handle.\n" );
shcore = GetModuleHandleA( "shcore.dll" ); shcore = GetModuleHandleA( "shcore.dll" );
todo_wine
ok( mod == shcore, "wrong module %p/%p\n", mod, shcore ); ok( mod == shcore, "wrong module %p/%p\n", mod, shcore );
ret = FreeLibrary( mod ); ret = FreeLibrary( mod );
ok( ret, "FreeLibrary failed, error %u.\n", GetLastError() ); ok( ret, "FreeLibrary failed, error %u.\n", GetLastError() );
...@@ -722,7 +721,6 @@ static void test_LoadLibraryEx_search_flags(void) ...@@ -722,7 +721,6 @@ static void test_LoadLibraryEx_search_flags(void)
ok( !!mod, "Got NULL module, error %u.\n", GetLastError() ); ok( !!mod, "Got NULL module, error %u.\n", GetLastError() );
ok( !!GetModuleHandleA( apiset_dll ), "Got NULL handle.\n" ); ok( !!GetModuleHandleA( apiset_dll ), "Got NULL handle.\n" );
shcore = GetModuleHandleA( "shcore.dll" ); shcore = GetModuleHandleA( "shcore.dll" );
todo_wine
ok( mod == shcore, "wrong module %p/%p\n", mod, shcore ); ok( mod == shcore, "wrong module %p/%p\n", mod, shcore );
ret = FreeLibrary( mod ); ret = FreeLibrary( mod );
ok( ret, "FreeLibrary failed, error %u.\n", GetLastError() ); ok( ret, "FreeLibrary failed, error %u.\n", GetLastError() );
...@@ -733,7 +731,6 @@ static void test_LoadLibraryEx_search_flags(void) ...@@ -733,7 +731,6 @@ static void test_LoadLibraryEx_search_flags(void)
strcpy( buffer, apiset_dll ); strcpy( buffer, apiset_dll );
buffer[strlen(buffer) - 5] = '9'; buffer[strlen(buffer) - 5] = '9';
mod = LoadLibraryExA( buffer, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR ); mod = LoadLibraryExA( buffer, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
todo_wine
ok( !!mod || broken(!mod) /* win8 */, "Got NULL module, error %u.\n", GetLastError() ); ok( !!mod || broken(!mod) /* win8 */, "Got NULL module, error %u.\n", GetLastError() );
if (mod) if (mod)
{ {
...@@ -776,9 +773,10 @@ static void test_LoadLibraryEx_search_flags(void) ...@@ -776,9 +773,10 @@ static void test_LoadLibraryEx_search_flags(void)
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() ); ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
mod = LoadLibraryExA( "ext-ms-win-ras-rasapi32-l1-1-0.dll", NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR ); mod = LoadLibraryExA( "ext-ms-win-ras-rasapi32-l1-1-0.dll", NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR );
todo_wine /* rasapi32 doesn't have interesting dependencies on wine */
ok( !mod, "rasapi32 loaded\n" ); ok( !mod, "rasapi32 loaded\n" );
ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
if (mod) FreeLibrary( mod ); if (mod) FreeLibrary( mod );
else ok( GetLastError() == ERROR_MOD_NOT_FOUND, "wrong error %u\n", GetLastError() );
mod = LoadLibraryA( "ext-ms-win-ras-rasapi32-l1-1-0.dll" ); mod = LoadLibraryA( "ext-ms-win-ras-rasapi32-l1-1-0.dll" );
ok( !!mod || broken(!mod) /* win7 */, "rasapi32 not found %u\n", GetLastError() ); ok( !!mod || broken(!mod) /* win7 */, "rasapi32 not found %u\n", GetLastError() );
if (mod) FreeLibrary( mod ); if (mod) FreeLibrary( mod );
......
...@@ -2830,6 +2830,30 @@ done: ...@@ -2830,6 +2830,30 @@ done:
} }
/******************************************************************************
* find_apiset_dll
*/
static NTSTATUS find_apiset_dll( const WCHAR *name, WCHAR **fullname )
{
const API_SET_NAMESPACE *map = NtCurrentTeb()->Peb->ApiSetMap;
const API_SET_NAMESPACE_ENTRY *entry;
UNICODE_STRING str;
ULONG len;
if (get_apiset_entry( map, name, wcslen(name), &entry )) return STATUS_APISET_NOT_PRESENT;
if (get_apiset_target( map, entry, NULL, &str )) return STATUS_DLL_NOT_FOUND;
len = wcslen( system_dir ) + str.Length / sizeof(WCHAR);
if (!(*fullname = RtlAllocateHeap( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) )))
return STATUS_NO_MEMORY;
wcscpy( *fullname, system_dir );
memcpy( *fullname + wcslen( system_dir ), str.Buffer, str.Length );
(*fullname)[len] = 0;
return STATUS_SUCCESS;
}
/*********************************************************************** /***********************************************************************
* get_env_var * get_env_var
*/ */
...@@ -2992,17 +3016,6 @@ done: ...@@ -2992,17 +3016,6 @@ done:
} }
/*********************************************************************** /***********************************************************************
* is_apiset_dll_name
*
*/
static BOOL is_apiset_dll_name( const WCHAR *name )
{
static const WCHAR name_prefix[] = L"api-ms-win-";
return !wcsnicmp( name, name_prefix, ARRAY_SIZE(name_prefix) - 1 );
}
/***********************************************************************
* find_dll_file * find_dll_file
* *
* Find the file (or already loaded module) for a given dll name. * Find the file (or already loaded module) for a given dll name.
...@@ -3024,7 +3037,11 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, UNI ...@@ -3024,7 +3037,11 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, UNI
if (!contains_path( libname )) if (!contains_path( libname ))
{ {
status = find_actctx_dll( libname, &fullname ); status = find_apiset_dll( libname, &fullname );
if (status == STATUS_DLL_NOT_FOUND) goto done;
if (status) status = find_actctx_dll( libname, &fullname );
if (status == STATUS_SUCCESS) if (status == STATUS_SUCCESS)
{ {
TRACE ("found %s for %s\n", debugstr_w(fullname), debugstr_w(libname) ); TRACE ("found %s for %s\n", debugstr_w(fullname), debugstr_w(libname) );
...@@ -3044,8 +3061,6 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, UNI ...@@ -3044,8 +3061,6 @@ static NTSTATUS find_dll_file( const WCHAR *load_path, const WCHAR *libname, UNI
if (RtlDetermineDosPathNameType_U( libname ) == RELATIVE_PATH) if (RtlDetermineDosPathNameType_U( libname ) == RELATIVE_PATH)
{ {
status = search_dll_file( load_path, libname, nt_name, pwm, mapping, image_info, id ); status = search_dll_file( load_path, libname, nt_name, pwm, mapping, image_info, id );
if (status == STATUS_DLL_NOT_FOUND && load_path && is_apiset_dll_name( libname ))
status = search_dll_file( NULL, libname, nt_name, pwm, mapping, image_info, id );
if (status == STATUS_DLL_NOT_FOUND) if (status == STATUS_DLL_NOT_FOUND)
status = find_builtin_without_file( libname, nt_name, pwm, mapping, image_info, id ); status = find_builtin_without_file( libname, nt_name, pwm, mapping, image_info, id );
} }
......
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