Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47912 Signed-off-by: Brendan Shanks bshanks@codeweavers.com --- dlls/kernel32/tests/loader.c | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c index 65184887b8..4e0c3c92e8 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,45 @@ static void test_InMemoryOrderModuleList(void) ok(entry2 == mark2, "expected entry2 == mark2, got %p and %p\n", entry2, mark2); }
+static void test_wow64_redirection(void) +{ + VOID *OldValue; + HMODULE lib; + OSVERSIONINFOEXA info; + + if (!is_wow64) + return; + + /* Only run tests on Win7/2008R2 (NT 6.1) and newer. The LoadLibrary calls fail on Vista/2008. */ + memset(&info, 0, sizeof(info)); + info.dwOSVersionInfoSize = sizeof(info); + info.dwMajorVersion = 6; + info.dwMinorVersion = 1; + if (VerifyVersionInfoA(&info, VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR, + VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0, + VER_MAJORVERSION,VER_GREATER_EQUAL), + VER_MINORVERSION,VER_GREATER_EQUAL), + VER_SERVICEPACKMAJOR,VER_GREATER_EQUAL)) == 0) + return; + + ok(pWow64DisableWow64FsRedirection(&OldValue), "Disabling FS redirection failed\n"); + + /* Use system libraries that shouldn't already be loaded in this process. */ + lib = LoadLibraryExA("bcrypt.dll", NULL, 0); + todo_wine ok (lib != NULL, "Loading bcrypt.dll should succeed with WOW64 redirection disabled\n"); + if (lib) FreeLibrary(lib); + + lib = LoadLibraryExA("dxgi.dll", NULL, 0); + todo_wine ok (lib != NULL, "Loading dxgi.dll should succeed with WOW64 redirection disabled\n"); + if (lib) FreeLibrary(lib); + + lib = LoadLibraryExA("dwrite.dll", NULL, 0); + todo_wine ok (lib != NULL, "Loading dwrite.dll should succeed with WOW64 redirection disabled\n"); + if (lib) FreeLibrary(lib); + + ok(pWow64RevertWow64FsRedirection(OldValue), "Re-enabling FS redirection failed\n"); +} + static void test_dll_file( const char *name ) { HMODULE module = GetModuleHandleA( name ); @@ -3897,6 +3938,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 +3973,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=57658
Your paranoid android.
=== wvistau64_zh_CN (32 bit report) ===
kernel32: loader.c:3113: Test failed: child process failed to terminate loader.c:3116: Test failed: expected exit code 197, got 259 loader.c:3227: Test failed: child process failed to terminate
=== wvistau64_he (32 bit report) ===
kernel32: loader.c:3113: Test failed: child process failed to terminate loader.c:3116: Test failed: expected exit code 197, got 259
=== 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
Brendan Shanks bshanks@codeweavers.com writes:
- /* Only run tests on Win7/2008R2 (NT 6.1) and newer. The LoadLibrary calls fail on Vista/2008. */
- memset(&info, 0, sizeof(info));
- info.dwOSVersionInfoSize = sizeof(info);
- info.dwMajorVersion = 6;
- info.dwMinorVersion = 1;
- if (VerifyVersionInfoA(&info, VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR,
VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0,
VER_MAJORVERSION,VER_GREATER_EQUAL),
VER_MINORVERSION,VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR,VER_GREATER_EQUAL)) == 0)
return;
Please don't do version checks in tests. You can mark results as broken instead.
- /* Use system libraries that shouldn't already be loaded in this process. */
- lib = LoadLibraryExA("bcrypt.dll", NULL, 0);
- todo_wine ok (lib != NULL, "Loading bcrypt.dll should succeed with WOW64 redirection disabled\n");
- if (lib) FreeLibrary(lib);
It would be good to confirm that it wasn't previously loaded, using GetModuleHandle(). Also testing the loaded module path with GetModuleFileNameA() may be interesting.
Hi Alexandre,
On Oct 9, 2019, at 1:00 AM, Alexandre Julliard julliard@winehq.org wrote:
Brendan Shanks bshanks@codeweavers.com writes:
- /* Only run tests on Win7/2008R2 (NT 6.1) and newer. The LoadLibrary calls fail on Vista/2008. */
- memset(&info, 0, sizeof(info));
- info.dwOSVersionInfoSize = sizeof(info);
- info.dwMajorVersion = 6;
- info.dwMinorVersion = 1;
- if (VerifyVersionInfoA(&info, VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR,
VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0,
VER_MAJORVERSION,VER_GREATER_EQUAL),
VER_MINORVERSION,VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR,VER_GREATER_EQUAL)) == 0)
return;
Please don't do version checks in tests. You can mark results as broken instead.
Thanks, will do.
- /* Use system libraries that shouldn't already be loaded in this process. */
- lib = LoadLibraryExA("bcrypt.dll", NULL, 0);
- todo_wine ok (lib != NULL, "Loading bcrypt.dll should succeed with WOW64 redirection disabled\n");
- if (lib) FreeLibrary(lib);
It would be good to confirm that it wasn't previously loaded, using GetModuleHandle(). Also testing the loaded module path with GetModuleFileNameA() may be interesting.
On Windows 10, the module path returned is “c:\windows\system32\bcrypt.dll”, i.e. what you would expect with redirection enabled. If I free the library and then re-load it using that absolute path, it succeeds. It almost seems like Windows is ignoring redirection being disabled. I’ll send another rev of the patch.
Brendan