Brendan Shanks : kernel32/tests: Test loading system DLLs with WoW64 redirection disabled.
Alexandre Julliard
julliard at winehq.org
Mon Oct 21 15:28:39 CDT 2019
Module: wine
Branch: master
Commit: de9406bccd100b9c09afb3cd84173f956e0aa52d
URL: https://source.winehq.org/git/wine.git/?a=commit;h=de9406bccd100b9c09afb3cd84173f956e0aa52d
Author: Brendan Shanks <bshanks at codeweavers.com>
Date: Thu Oct 17 13:23:50 2019 -0700
kernel32/tests: Test loading system DLLs with WoW64 redirection disabled.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47912
Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/tests/loader.c | 49 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 65184887b8..e5b8c3b28e 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -84,6 +84,8 @@ static BOOL (WINAPI *pFlsSetValue)(DWORD, PVOID);
static PVOID (WINAPI *pFlsGetValue)(DWORD);
static BOOL (WINAPI *pFlsFree)(DWORD);
static BOOL (WINAPI *pIsWow64Process)(HANDLE,PBOOL);
+static BOOL (WINAPI *pWow64DisableWow64FsRedirection)(void **);
+static BOOL (WINAPI *pWow64RevertWow64FsRedirection)(void *);
static PVOID RVAToAddr(DWORD_PTR rva, HMODULE module)
{
@@ -3812,6 +3814,50 @@ static void test_InMemoryOrderModuleList(void)
ok(entry2 == mark2, "expected entry2 == mark2, got %p and %p\n", entry2, mark2);
}
+static void test_wow64_redirection_for_dll(const char *libname)
+{
+ HMODULE lib;
+ char buf[256];
+
+ if (!GetModuleHandleA(libname))
+ {
+ lib = LoadLibraryExA(libname, NULL, 0);
+ todo_wine ok (broken(lib == NULL) /* Vista/2008 */ ||
+ lib != NULL, "Loading %s should succeed with WOW64 redirection disabled\n", libname);
+ if (lib)
+ {
+ /* Win 7/2008R2 return the un-redirected path (i.e. c:\windows\system32\dwrite.dll), test loading it. */
+ GetModuleFileNameA(lib, buf, sizeof(buf));
+ FreeLibrary(lib);
+ lib = LoadLibraryExA(buf, NULL, 0);
+ ok(lib != NULL, "Loading %s from full path should succeed with WOW64 redirection disabled\n", libname);
+ if (lib)
+ FreeLibrary(lib);
+ }
+ }
+ else
+ {
+ skip("%s was already loaded in the process\n", libname);
+ }
+}
+
+static void test_wow64_redirection(void)
+{
+ void *OldValue;
+
+ if (!is_wow64)
+ return;
+
+ /* Disable FS redirection, then test loading system libraries (pick ones that shouldn't
+ * already be loaded in this process).
+ */
+ ok(pWow64DisableWow64FsRedirection(&OldValue), "Disabling FS redirection failed\n");
+ test_wow64_redirection_for_dll("wlanapi.dll");
+ test_wow64_redirection_for_dll("dxgi.dll");
+ test_wow64_redirection_for_dll("dwrite.dll");
+ ok(pWow64RevertWow64FsRedirection(OldValue), "Re-enabling FS redirection failed\n");
+}
+
static void test_dll_file( const char *name )
{
HMODULE module = GetModuleHandleA( name );
@@ -3897,6 +3943,8 @@ START_TEST(loader)
pFlsGetValue = (void *)GetProcAddress(kernel32, "FlsGetValue");
pFlsFree = (void *)GetProcAddress(kernel32, "FlsFree");
pIsWow64Process = (void *)GetProcAddress(kernel32, "IsWow64Process");
+ pWow64DisableWow64FsRedirection = (void *)GetProcAddress(kernel32, "Wow64DisableWow64FsRedirection");
+ pWow64RevertWow64FsRedirection = (void *)GetProcAddress(kernel32, "Wow64RevertWow64FsRedirection");
pResolveDelayLoadedAPI = (void *)GetProcAddress(kernel32, "ResolveDelayLoadedAPI");
if (pIsWow64Process) pIsWow64Process( GetCurrentProcess(), &is_wow64 );
@@ -3930,6 +3978,7 @@ START_TEST(loader)
test_import_resolution();
test_ExitProcess();
test_InMemoryOrderModuleList();
+ test_wow64_redirection();
test_dll_file( "ntdll.dll" );
test_dll_file( "kernel32.dll" );
test_dll_file( "advapi32.dll" );
More information about the wine-cvs
mailing list