From: Zhiyi Zhang zzhang@codeweavers.com
--- dlls/kernel32/tests/actctx.c | 47 +++++++++++++++++++++++++++++++++++- include/winternl.h | 1 + 2 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c index fa67d37138c..469d75823f4 100644 --- a/dlls/kernel32/tests/actctx.c +++ b/dlls/kernel32/tests/actctx.c @@ -3848,8 +3848,31 @@ static void test_one_sxs_and_one_local_2(void) clean_sxs_info(&dll); }
+#define check_redirected_flag(a, b) _check_redirected_flag(__LINE__, a, b) +static void _check_redirected_flag(int line, HMODULE module, BOOL redirected) +{ + LIST_ENTRY *root = &NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList; + BOOL found_dll = FALSE; + + for (LIST_ENTRY *entry = root->Flink; entry != root; entry = entry->Flink) + { + LDR_DATA_TABLE_ENTRY *mod = CONTAINING_RECORD(entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks); + + if (mod->DllBase != module) + continue; + + if (redirected) + todo_wine + ok_(__FILE__, line)(mod->Flags & LDR_REDIRECTED, "Got unexpected flags %#lx.\n", mod->Flags); + else + ok_(__FILE__, line)(!(mod->Flags & LDR_REDIRECTED), "Got unexpected flags %#lx.\n", mod->Flags);
-/* Test if we can get a module handle from loaded normal dll while context is active */ + found_dll = TRUE; + } + ok(found_dll, "Couldn't find module %p in module list.\n", module); +} + +/* Test GetModuleHandleA() with DLL base names in different context states */ static void test_one_with_sxs_and_GetModuleHandleA(void) { sxs_info dll; @@ -3864,18 +3887,40 @@ static void test_one_with_sxs_and_GetModuleHandleA(void) extract_resource("dummy.dll", "TESTDLL", path_dll_local);
module = LoadLibraryA(path_dll_local); + check_redirected_flag(module, FALSE);
fill_sxs_info(&dll, "1", "dummy.dll", two_dll_manifest_exe, two_dll_manifest_dll, FALSE); success = ActivateActCtx(dll.handle_context, &dll.cookie); ok(success, "ActivateActCtx failed: %ld\n", GetLastError());
+ /* Loaded normal dll can't be found while context is active */ module_temp = GetModuleHandleA("sxs_dll.dll"); ok (module_temp == 0, "Expected 0, got %p\n", module_temp);
+ dll.module = LoadLibraryA("sxs_dll.dll"); + ok(dll.module != NULL && dll.module != module, "LoadLibrary failed\n"); + check_redirected_flag(dll.module, TRUE); + + /* Loaded SxS dll should be found while context is active */ + module_temp = GetModuleHandleA("sxs_dll.dll"); + ok(module_temp == dll.module, "Got unexpected module.\n"); + DeactivateActCtx(0, dll.cookie); + check_redirected_flag(dll.module, TRUE); + + /* Normal loaded dll should be found while context is inactive */ + module_temp = GetModuleHandleA("sxs_dll.dll"); + todo_wine + ok(module_temp == module, "Got unexpected module.\n");
if (module) FreeLibrary(module); + + /* Loaded SxS dll can't be found while context is inactive */ + module_temp = GetModuleHandleA("sxs_dll.dll"); + todo_wine + ok(module_temp == NULL, "Got unexpected module.\n"); + if (dll.module) FreeLibrary(dll.module); if (*path_dll_local) diff --git a/include/winternl.h b/include/winternl.h index a7ad7a9fa79..3377a418e0e 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -3947,6 +3947,7 @@ typedef void (CALLBACK *PLDR_DLL_NOTIFICATION_FUNCTION)(ULONG, LDR_DLL_NOTIFICAT #define LDR_PROCESS_ATTACHED 0x00080000 #define LDR_COR_IMAGE 0x00400000 #define LDR_COR_ILONLY 0x01000000 +#define LDR_REDIRECTED 0x10000000
/* these ones is Wine specific */ #define LDR_DONT_RESOLVE_REFS 0x40000000