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" );