Signed-off-by: Zebediah Figura z.figura12@gmail.com --- configure | 1 + configure.ac | 1 + dlls/wow64cpu/Makefile.in | 7 +++++++ dlls/wow64cpu/wow64cpu.spec | 9 +++++++++ dlls/wow64cpu/wow64cpu_main.c | 27 +++++++++++++++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 dlls/wow64cpu/Makefile.in create mode 100644 dlls/wow64cpu/wow64cpu.spec create mode 100644 dlls/wow64cpu/wow64cpu_main.c
diff --git a/configure b/configure index ac6a7985cc7..b7a6fcae9a8 100755 --- a/configure +++ b/configure @@ -21142,6 +21142,7 @@ wine_fn_config_makefile dlls/wmvcore enable_wmvcore wine_fn_config_makefile dlls/wmvcore/tests enable_tests wine_fn_config_makefile dlls/wnaspi32 enable_wnaspi32 wine_fn_config_makefile dlls/wow32 enable_win16 +wine_fn_config_makefile dlls/wow64cpu enable_win64 wine_fn_config_makefile dlls/wpc enable_wpc wine_fn_config_makefile dlls/wpc/tests enable_tests wine_fn_config_makefile dlls/wpcap enable_wpcap diff --git a/configure.ac b/configure.ac index 2f81fd22610..83939c85e52 100644 --- a/configure.ac +++ b/configure.ac @@ -3885,6 +3885,7 @@ WINE_CONFIG_MAKEFILE(dlls/wmvcore) WINE_CONFIG_MAKEFILE(dlls/wmvcore/tests) WINE_CONFIG_MAKEFILE(dlls/wnaspi32) WINE_CONFIG_MAKEFILE(dlls/wow32,enable_win16) +WINE_CONFIG_MAKEFILE(dlls/wow64cpu,enable_win64) WINE_CONFIG_MAKEFILE(dlls/wpc) WINE_CONFIG_MAKEFILE(dlls/wpc/tests) WINE_CONFIG_MAKEFILE(dlls/wpcap) diff --git a/dlls/wow64cpu/Makefile.in b/dlls/wow64cpu/Makefile.in new file mode 100644 index 00000000000..2ab1ca62c4a --- /dev/null +++ b/dlls/wow64cpu/Makefile.in @@ -0,0 +1,7 @@ +MODULE = wow64cpu.dll +IMPORTS = winecrt0 ntdll + +EXTRADLLFLAGS = -nodefaultlibs -mno-cygwin + +C_SRCS = \ + wow64cpu_main.c diff --git a/dlls/wow64cpu/wow64cpu.spec b/dlls/wow64cpu/wow64cpu.spec new file mode 100644 index 00000000000..bd156df1e79 --- /dev/null +++ b/dlls/wow64cpu/wow64cpu.spec @@ -0,0 +1,9 @@ +# @ stub BTCpuGetBopCode +# @ stub BTCpuGetContext +# @ stub BTCpuProcessInit +# @ stub BTCpuResetToConsistentState +# @ stub BTCpuSetContext +# @ stub BTCpuSimulate +# @ stub BTCpuTurboThunkControl +# @ stub TurboDispatchJumpAddressEnd +# @ stub TurboDispatchJumpAddressStart diff --git a/dlls/wow64cpu/wow64cpu_main.c b/dlls/wow64cpu/wow64cpu_main.c new file mode 100644 index 00000000000..4da9695230b --- /dev/null +++ b/dlls/wow64cpu/wow64cpu_main.c @@ -0,0 +1,27 @@ +/* + * Copyright 2018 Zebediah Figura + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> +#include "windef.h" +#include "winternl.h" + +BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, void *reserved ) +{ + if (reason == DLL_PROCESS_ATTACH) LdrDisableThreadCalloutsForDll( inst ); + return TRUE; +}
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45567 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ntdll/loader.c | 48 +++++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/ntdll.spec | 1 + 2 files changed, 49 insertions(+)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index a7015deeec4..8a328179c91 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -3998,6 +3998,49 @@ static void restart_winevdm( RTL_USER_PROCESS_PARAMETERS *params ) RtlInitUnicodeString( ¶ms->CommandLine, cmdline ); }
+#ifndef _WIN64 +void *Wow64Transition; + +static void map_wow64cpu(void) +{ + SIZE_T size = page_size; + OBJECT_ATTRIBUTES attr; + UNICODE_STRING string; + HANDLE file, section; + void *address = NULL; + IO_STATUS_BLOCK io; + NTSTATUS status; + + RtlInitUnicodeString( &string, L"\??\C:\windows\sysnative\wow64cpu.dll" ); + InitializeObjectAttributes( &attr, &string, 0, NULL, NULL ); + if ((status = NtOpenFile( &file, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ, + FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE ))) + { + WARN("failed to open wow64cpu, status %#x\n", status); + return; + } + + if ((status = NtCreateSection( §ion, STANDARD_RIGHTS_REQUIRED | SECTION_MAP_READ, + NULL, NULL, PAGE_READONLY, SEC_RESERVE, file ))) + { + WARN("failed to create section, status %#x\n", status); + NtClose( file ); + return; + } + + if ((status = NtMapViewOfSection( section, NtCurrentProcess(), &address, 0, + 0, NULL, &size, ViewShare, 0, PAGE_READONLY ))) + { + WARN("failed to map section, status %#x\n", status); + NtClose( section ); + NtClose( file ); + return; + } + + Wow64Transition = address; +} +#endif +
/*********************************************************************** * process_init @@ -4061,6 +4104,11 @@ static NTSTATUS process_init(void) status = build_builtin_module( params->DllPath.Buffer, &nt_name, meminfo.AllocationBase, 0, &wm ); assert( !status );
+#ifndef _WIN64 + if (is_wow64) + map_wow64cpu(); +#endif + if ((status = load_dll( params->DllPath.Buffer, kernel32W, NULL, 0, &wm )) != STATUS_SUCCESS) { MESSAGE( "wine: could not load kernel32.dll, status %x\n", status ); diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 36746d989c6..3f852639fe7 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1131,6 +1131,7 @@ @ stdcall WinSqmIsOptedIn() @ stdcall WinSqmSetDWORD(ptr long long) @ stdcall WinSqmStartSession(ptr long long) +@ extern -arch=win32 Wow64Transition @ stdcall -private -syscall ZwAcceptConnectPort(ptr long ptr long ptr ptr) NtAcceptConnectPort @ stdcall -private -syscall ZwAccessCheck(ptr long long ptr ptr ptr ptr ptr) NtAccessCheck @ stdcall -private -syscall ZwAccessCheckAndAuditAlarm(ptr long ptr ptr ptr long ptr long ptr ptr ptr) NtAccessCheckAndAuditAlarm
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=81121
Your paranoid android.
=== debiant (32 bit WoW report) ===
ntdll: threadpool.c:1904: Test failed: WaitForSingleObject returned 258
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/kernel32/tests/loader.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c index 67fd62ef6aa..eaf6e6b8b8b 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c @@ -3992,6 +3992,30 @@ static void test_LoadPackagedLibrary(void) h, GetLastError()); }
+static void test_Wow64Transition(void) +{ + char buffer[400]; + MEMORY_SECTION_NAME *name = (MEMORY_SECTION_NAME *)buffer; + const WCHAR *filepart; + void **pWow64Transition; + NTSTATUS status; + + if (!(pWow64Transition = (void *)GetProcAddress(GetModuleHandleA("ntdll"), "Wow64Transition"))) + { + skip("Wow64Transition is not present\n"); + return; + } + + status = NtQueryVirtualMemory(GetCurrentProcess(), *pWow64Transition, + MemorySectionName, name, sizeof(buffer), NULL); + todo_wine ok(!status, "got %#x\n", status); + if (status) return; + filepart = name->SectionFileName.Buffer + name->SectionFileName.Length / sizeof(WCHAR); + while (*filepart != '\') --filepart; + ok(!wcsnicmp(filepart, L"\wow64cpu.dll", wcslen(L"\wow64cpu.dll")), "got file name %s\n", + debugstr_wn(name->SectionFileName.Buffer, name->SectionFileName.Length / sizeof(WCHAR))); +} + START_TEST(loader) { int argc; @@ -4068,6 +4092,7 @@ START_TEST(loader) test_dll_file( "kernel32.dll" ); test_dll_file( "advapi32.dll" ); test_dll_file( "user32.dll" ); + test_Wow64Transition(); /* loader test must be last, it can corrupt the internal loader state on Windows */ test_Loader(); }
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=81122
Your paranoid android.
=== w10pro64 (32 bit report) ===
kernel32: loader.c:2798: Test failed: attached thread count should be 2 loader.c:3016: Test failed: expected thread exit code 196, got 259 loader.c:3016: Test failed: expected thread exit code 196, got 259 loader.c:2484: Test failed: expected thread exit code 196, got 195 loader.c:2484: Test failed: expected thread exit code 196, got 195
=== w10pro64_ar (32 bit report) ===
kernel32: loader.c:2798: Test failed: attached thread count should be 2
=== w1064v1809 (64 bit report) ===
kernel32: loader.c:704: Test failed: 1426: got test dll but expected fallback loader.c:704: Test failed: 1432: got test dll but expected fallback loader.c:704: Test failed: 1438: got test dll but expected fallback loader.c:704: Test failed: 1445: got test dll but expected fallback loader.c:704: Test failed: 1472: got test dll but expected fallback
=== debiant (32 bit report) ===
kernel32: loader.c:3964: Test failed: ntdll.dll:0: wrong OptionalHeader.AddressOfEntryPoint 5f970 / 5f730 loader.c:3968: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].VirtualAddress 76000 / 74000 loader.c:3969: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].Size 13930 / 138fa loader.c:3968: Test failed: ntdll.dll:1: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8a000 / 88000 loader.c:3968: Test failed: ntdll.dll:2: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8b000 / 89000 loader.c:3968: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8c000 / 8a000 loader.c:3969: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].Size 3b3c / 3b10 loader.c:3974: Test failed: ntdll.dll: wrong section 0 loader.c:3974: Test failed: ntdll.dll: wrong section 1 loader.c:3974: Test failed: ntdll.dll: wrong section 2 loader.c:3974: Test failed: ntdll.dll: wrong section 3 loader.c:3974: Test failed: ntdll.dll: wrong section 4 loader.c:3974: Test failed: ntdll.dll: wrong section 5 loader.c:3974: Test failed: ntdll.dll: wrong section 6 loader.c:3974: Test failed: ntdll.dll: wrong section 7 loader.c:3974: Test failed: ntdll.dll: wrong section 8 loader.c:3974: Test failed: ntdll.dll: wrong section 9 loader.c:3974: Test failed: ntdll.dll: wrong section 10 loader.c:3974: Test failed: ntdll.dll: wrong section 11 loader.c:3974: Test failed: ntdll.dll: wrong section 12 loader.c:3974: Test failed: ntdll.dll: wrong section 13 loader.c:3974: Test failed: ntdll.dll: wrong section 14 loader.c:3974: Test failed: ntdll.dll: wrong section 15
=== debiant (32 bit French report) ===
kernel32: loader.c:3964: Test failed: ntdll.dll:0: wrong OptionalHeader.AddressOfEntryPoint 5f970 / 5f730 loader.c:3968: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].VirtualAddress 76000 / 74000 loader.c:3969: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].Size 13930 / 138fa loader.c:3968: Test failed: ntdll.dll:1: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8a000 / 88000 loader.c:3968: Test failed: ntdll.dll:2: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8b000 / 89000 loader.c:3968: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8c000 / 8a000 loader.c:3969: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].Size 3b3c / 3b10 loader.c:3974: Test failed: ntdll.dll: wrong section 0 loader.c:3974: Test failed: ntdll.dll: wrong section 1 loader.c:3974: Test failed: ntdll.dll: wrong section 2 loader.c:3974: Test failed: ntdll.dll: wrong section 3 loader.c:3974: Test failed: ntdll.dll: wrong section 4 loader.c:3974: Test failed: ntdll.dll: wrong section 5 loader.c:3974: Test failed: ntdll.dll: wrong section 6 loader.c:3974: Test failed: ntdll.dll: wrong section 7 loader.c:3974: Test failed: ntdll.dll: wrong section 8 loader.c:3974: Test failed: ntdll.dll: wrong section 9 loader.c:3974: Test failed: ntdll.dll: wrong section 10 loader.c:3974: Test failed: ntdll.dll: wrong section 11 loader.c:3974: Test failed: ntdll.dll: wrong section 12 loader.c:3974: Test failed: ntdll.dll: wrong section 13 loader.c:3974: Test failed: ntdll.dll: wrong section 14 loader.c:3974: Test failed: ntdll.dll: wrong section 15
=== debiant (32 bit Japanese:Japan report) ===
kernel32: loader.c:3964: Test failed: ntdll.dll:0: wrong OptionalHeader.AddressOfEntryPoint 5f970 / 5f730 loader.c:3968: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].VirtualAddress 76000 / 74000 loader.c:3969: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].Size 13930 / 138fa loader.c:3968: Test failed: ntdll.dll:1: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8a000 / 88000 loader.c:3968: Test failed: ntdll.dll:2: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8b000 / 89000 loader.c:3968: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8c000 / 8a000 loader.c:3969: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].Size 3b3c / 3b10 loader.c:3974: Test failed: ntdll.dll: wrong section 0 loader.c:3974: Test failed: ntdll.dll: wrong section 1 loader.c:3974: Test failed: ntdll.dll: wrong section 2 loader.c:3974: Test failed: ntdll.dll: wrong section 3 loader.c:3974: Test failed: ntdll.dll: wrong section 4 loader.c:3974: Test failed: ntdll.dll: wrong section 5 loader.c:3974: Test failed: ntdll.dll: wrong section 6 loader.c:3974: Test failed: ntdll.dll: wrong section 7 loader.c:3974: Test failed: ntdll.dll: wrong section 8 loader.c:3974: Test failed: ntdll.dll: wrong section 9 loader.c:3974: Test failed: ntdll.dll: wrong section 10 loader.c:3974: Test failed: ntdll.dll: wrong section 11 loader.c:3974: Test failed: ntdll.dll: wrong section 12 loader.c:3974: Test failed: ntdll.dll: wrong section 13 loader.c:3974: Test failed: ntdll.dll: wrong section 14 loader.c:3974: Test failed: ntdll.dll: wrong section 15
=== debiant (32 bit Chinese:China report) ===
kernel32: loader.c:3964: Test failed: ntdll.dll:0: wrong OptionalHeader.AddressOfEntryPoint 5f970 / 5f730 loader.c:3968: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].VirtualAddress 76000 / 74000 loader.c:3969: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].Size 13930 / 138fa loader.c:3968: Test failed: ntdll.dll:1: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8a000 / 88000 loader.c:3968: Test failed: ntdll.dll:2: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8b000 / 89000 loader.c:3968: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8c000 / 8a000 loader.c:3969: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].Size 3b3c / 3b10 loader.c:3974: Test failed: ntdll.dll: wrong section 0 loader.c:3974: Test failed: ntdll.dll: wrong section 1 loader.c:3974: Test failed: ntdll.dll: wrong section 2 loader.c:3974: Test failed: ntdll.dll: wrong section 3 loader.c:3974: Test failed: ntdll.dll: wrong section 4 loader.c:3974: Test failed: ntdll.dll: wrong section 5 loader.c:3974: Test failed: ntdll.dll: wrong section 6 loader.c:3974: Test failed: ntdll.dll: wrong section 7 loader.c:3974: Test failed: ntdll.dll: wrong section 8 loader.c:3974: Test failed: ntdll.dll: wrong section 9 loader.c:3974: Test failed: ntdll.dll: wrong section 10 loader.c:3974: Test failed: ntdll.dll: wrong section 11 loader.c:3974: Test failed: ntdll.dll: wrong section 12 loader.c:3974: Test failed: ntdll.dll: wrong section 13 loader.c:3974: Test failed: ntdll.dll: wrong section 14 loader.c:3974: Test failed: ntdll.dll: wrong section 15
=== debiant (32 bit WoW report) ===
kernel32: loader.c:3964: Test failed: ntdll.dll:0: wrong OptionalHeader.AddressOfEntryPoint 5f970 / 5f730 loader.c:3968: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].VirtualAddress 76000 / 74000 loader.c:3969: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].Size 13930 / 138fa loader.c:3968: Test failed: ntdll.dll:1: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8a000 / 88000 loader.c:3968: Test failed: ntdll.dll:2: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8b000 / 89000 loader.c:3968: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8c000 / 8a000 loader.c:3969: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].Size 3b3c / 3b10 loader.c:3974: Test failed: ntdll.dll: wrong section 0 loader.c:3974: Test failed: ntdll.dll: wrong section 1 loader.c:3974: Test failed: ntdll.dll: wrong section 2 loader.c:3974: Test failed: ntdll.dll: wrong section 3 loader.c:3974: Test failed: ntdll.dll: wrong section 4 loader.c:3974: Test failed: ntdll.dll: wrong section 5 loader.c:3974: Test failed: ntdll.dll: wrong section 6 loader.c:3974: Test failed: ntdll.dll: wrong section 7 loader.c:3974: Test failed: ntdll.dll: wrong section 8 loader.c:3974: Test failed: ntdll.dll: wrong section 9 loader.c:3974: Test failed: ntdll.dll: wrong section 10 loader.c:3974: Test failed: ntdll.dll: wrong section 11 loader.c:3974: Test failed: ntdll.dll: wrong section 12 loader.c:3974: Test failed: ntdll.dll: wrong section 13 loader.c:3974: Test failed: ntdll.dll: wrong section 14 loader.c:3974: Test failed: ntdll.dll: wrong section 15
=== debiant (64 bit WoW report) ===
kernel32: loader.c:3964: Test failed: ntdll.dll:0: wrong OptionalHeader.AddressOfEntryPoint 5f970 / 5f730 loader.c:3968: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].VirtualAddress 76000 / 74000 loader.c:3969: Test failed: ntdll.dll:0: wrong OptionalHeader.DataDirectory[i].Size 13930 / 138fa loader.c:3968: Test failed: ntdll.dll:1: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8a000 / 88000 loader.c:3968: Test failed: ntdll.dll:2: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8b000 / 89000 loader.c:3968: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].VirtualAddress 8c000 / 8a000 loader.c:3969: Test failed: ntdll.dll:5: wrong OptionalHeader.DataDirectory[i].Size 3b3c / 3b10 loader.c:3974: Test failed: ntdll.dll: wrong section 0 loader.c:3974: Test failed: ntdll.dll: wrong section 1 loader.c:3974: Test failed: ntdll.dll: wrong section 2 loader.c:3974: Test failed: ntdll.dll: wrong section 3 loader.c:3974: Test failed: ntdll.dll: wrong section 4 loader.c:3974: Test failed: ntdll.dll: wrong section 5 loader.c:3974: Test failed: ntdll.dll: wrong section 6 loader.c:3974: Test failed: ntdll.dll: wrong section 7 loader.c:3974: Test failed: ntdll.dll: wrong section 8 loader.c:3974: Test failed: ntdll.dll: wrong section 9 loader.c:3974: Test failed: ntdll.dll: wrong section 10 loader.c:3974: Test failed: ntdll.dll: wrong section 11 loader.c:3974: Test failed: ntdll.dll: wrong section 12 loader.c:3974: Test failed: ntdll.dll: wrong section 13 loader.c:3974: Test failed: ntdll.dll: wrong section 14 loader.c:3974: Test failed: ntdll.dll: wrong section 15