Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47912 Signed-off-by: Brendan Shanks bshanks@codeweavers.com --- v2: * Use broken() for the Vista/2008 case * Use GetModuleHandle() to ensure library isn't already loaded * Test loading the path returned by GetModuleFileName() * Test wlanapi.dll instead of bcrypt.dll (bcrypt was already loaded in the process for newer Win10 versions)
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..8ad1fde299 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" );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=57927
Your paranoid android.
=== w7pro64 (32 bit report) ===
kernel32: loader: Timeout
=== w7pro64 (task log) ===
Task errors: An error occurred while waiting for the test to complete: network read timed out (wait2/connect:AgentVersion.h:0/9) The test VM has crashed, rebooted or lost connectivity (or the TestAgent server died) The previous 2 run(s) terminated abnormally
=== w8adm (32 bit report) ===
kernel32: loader.c:693: Test failed: 1261: wrong status c000007b/c000035a loader.c:693: Test failed: 1270: wrong status c000007b/c000035a loader.c:693: Test failed: 1275: wrong status c000007b/c000035a loader.c:693: Test failed: 1282: wrong status c000007b/c000035a loader.c:693: Test failed: 1289: wrong status c000007b/c000035a loader.c:693: Test failed: 1297: wrong status c000007b/c000035a loader.c:693: Test failed: 1304: wrong status c000007b/c000035a loader.c:693: Test failed: 1314: wrong status c000007b/c000035a loader.c:693: Test failed: 1319: wrong status c000007b/c000035a loader.c:693: Test failed: 1324: wrong status c000007b/c000035a loader.c:693: Test failed: 1329: wrong status c000007b/c000035a loader.c:693: Test failed: 1334: wrong status c000007b/c000035a
=== w1064v1507 (32 bit report) ===
kernel32: loader.c:2891: Test failed: inside_heap_lock is not set
=== w1064v1809_ar (32 bit report) ===
kernel32: loader.c:3181: Test failed: child process failed to terminate
=== w1064v1809_ja (32 bit report) ===
kernel32: loader.c:3209: Test failed: child process failed to terminate
=== w1064v1809_zh_CN (32 bit report) ===
kernel32: loader.c:3181: Test failed: child process failed to terminate
=== w7pro64 (64 bit report) ===
kernel32: loader: Timeout
=== w7pro64 (task log) ===
Task errors: An error occurred while waiting for the test to complete: network read timed out (wait2/connect:AgentVersion.h:0/9) The test VM has crashed, rebooted or lost connectivity (or the TestAgent server died) The previous 2 run(s) terminated abnormally
=== w1064v1809 (64 bit report) ===
kernel32: loader.c:689: Test failed: 1389: got test dll but expected fallback loader.c:689: Test failed: 1395: got test dll but expected fallback loader.c:689: Test failed: 1401: got test dll but expected fallback loader.c:689: Test failed: 1408: got test dll but expected fallback loader.c:689: Test failed: 1435: got test dll but expected fallback