From: Paul Gofman pgofman@codeweavers.com
--- dlls/kernel32/tests/module.c | 81 ++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c index 956595bf2a1..50ad86bd600 100644 --- a/dlls/kernel32/tests/module.c +++ b/dlls/kernel32/tests/module.c @@ -1627,6 +1627,86 @@ static void test_ddag_node(void) ok( se == node->Dependencies.Tail, "Expected end of the list.\n" ); }
+static void test_apiset_target_load(void) +{ + static const char apiset_dll[] = "api-ms-win-shcore-obsolete-l1-1-0.dll"; + HMODULE hlocal, hsystem, hapiset, h; + char system_path[MAX_PATH]; + BOOL old_behaviour; + + if (GetModuleHandleA( "shcore.dll" )) + { + skip( "shcore.dll is already loaded, skipping test.\n" ); + return; + } + + GetSystemDirectoryA( system_path, MAX_PATH ); + strcat( system_path, "\shcore.dll" ); + + create_test_dll( ".\shcore.dll" ); + + hapiset = GetModuleHandleA( apiset_dll ); + ok( !hapiset, "Got %p.\n", hapiset ); + + hsystem = LoadLibraryA( "shcore.dll" ); + ok( !!hsystem, "Got NULL.\n" ); + + hlocal = LoadLibraryA( ".\shcore.dll" ); + ok( !!hlocal, "Got NULL.\n" ); + + old_behaviour = (hsystem == hlocal); + todo_wine ok( hsystem != hlocal || broken( old_behaviour ), "Got same module.\n" ); + + hapiset = GetModuleHandleA( apiset_dll ); + todo_wine ok( hapiset == hsystem || broken( old_behaviour && !hapiset ), "Got %p, %p.\n", hapiset, hsystem ); + + h = GetModuleHandleA( "shcore.dll" ); + ok( h == hsystem, "Got %p, %p.\n", h, hapiset ); + + FreeLibrary( hsystem ); + FreeLibrary( hlocal ); + + hapiset = GetModuleHandleA( apiset_dll ); + ok( !hapiset, "Got %p.\n", hapiset ); + + hlocal = LoadLibraryA( ".\shcore.dll" ); + ok( !!hlocal, "Got NULL.\n" ); + + hapiset = GetModuleHandleA( apiset_dll ); + ok( !hapiset, "Got %p.\n", hapiset ); + + hsystem = LoadLibraryA( "shcore.dll" ); + ok( !!hsystem, "Got NULL.\n" ); + ok( hsystem == hlocal, "Got %p, %p.\n", hsystem, hlocal ); + + h = GetModuleHandleA( "shcore.dll" ); + ok( h == hlocal, "Got %p, %p.\n", h, hapiset ); + + FreeLibrary( hsystem ); + FreeLibrary( hlocal ); + + hlocal = LoadLibraryA( ".\shcore.dll" ); + ok( !!hlocal, "Got NULL.\n" ); + + hapiset = GetModuleHandleA( apiset_dll ); + ok( !hapiset, "Got %p.\n", hapiset ); + + hapiset = LoadLibraryA( apiset_dll ); + /* hapiset is NULL before Win8 and a newly loaded module from system dir after. */ + ok( hapiset != hlocal, "Got same module.\n" ); + + h = GetModuleHandleA( "shcore.dll" ); + todo_wine ok( h == hlocal, "Got %p, %p, %p.\n", h, hlocal, hapiset ); + + h = GetModuleHandleA( system_path ); + ok( h == hapiset, "Got %p, %p.\n", h, hapiset ); + + FreeLibrary( hlocal ); + FreeLibrary( hapiset ); + + DeleteFileA( ".\shcore.dll" ); +} + START_TEST(module) { WCHAR filenameW[MAX_PATH]; @@ -1663,4 +1743,5 @@ START_TEST(module) test_LdrGetDllFullName(); test_apisets(); test_ddag_node(); + test_apiset_target_load(); }