Signed-off-by: Zebediah Figura z.figura12@gmail.com --- Resending this series now that MemorySectionName is implemented...
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 08936ff0ec1..b9b6a526051 100755 --- a/configure +++ b/configure @@ -21123,6 +21123,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 caff5d1fe52..b579f26902a 100644 --- a/configure.ac +++ b/configure.ac @@ -3857,6 +3857,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 8dbbb14f05d..fb2ce73c303 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -3958,6 +3958,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 @@ -4068,6 +4111,11 @@ static NTSTATUS process_init(void)
build_ntdll_module();
+#ifndef _WIN64 + if (is_wow64) + map_wow64cpu(); +#endif + if ((status = load_dll( params->DllPath.Buffer, L"C:\windows\system32\kernel32.dll", NULL, 0, &wm )) != STATUS_SUCCESS) { diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index dfa095a597b..97a8af7eb4d 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1129,6 +1129,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=86144
Your paranoid android.
=== debiant2 (32 bit WoW report) ===
ntdll: env.c:543: Test failed: wrong end ptr 001115B0/00112000
=== debiant2 (64 bit WoW report) ===
ntdll: env.c:543: Test failed: wrong end ptr 001115B0/00112000
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/kernel32/tests/loader.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c index 861fc321729..e9b209b5a0b 100644 --- a/dlls/kernel32/tests/loader.c +++ b/dlls/kernel32/tests/loader.c @@ -4003,6 +4003,29 @@ 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); + ok(!status, "got %#x\n", status); + 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; @@ -4079,6 +4102,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=86145
Your paranoid android.
=== debiant2 (32 bit report) ===
kernel32: loader.c:4022: Test failed: got 0xc0000141 loader.c:4025: Test failed: got file name L"\3a43\775c\6e69\6f64\7377\735c\7379\6574\336d\5c32\7375\7265\3233\642e\6c6c\6c00\0000\7ffc\0018\0000\0000\0000\3e29X\000c\0000\2bf8\7ffc\0000\0000\fcb8\008a\dba9\7bc4\2c00\7ffc\0018\0000\0000\0000\c41d\7b03\fca8\008a\fc98\008a\fcb0\008a\0002\0000\fd2c\008a\0002\0000\ff8c\008a\f8d0\7b07\0000"...
=== debiant2 (32 bit French report) ===
kernel32: loader.c:4022: Test failed: got 0xc0000141 loader.c:4025: Test failed: got file name L"\3a43\775c\6e69\6f64\7377\735c\7379\6574\336d\5c32\7375\7265\3233\642e\6c6c\6c00\7000\7f00\0018\0000\0000\0000\3e29X\000c\0000\2bf8\7ffc\0000\0000\fcb8\008a\dba9\7bc4\2c00\7ffc\0018\0000\0000\0000\c41d\7b03\fca8\008a\fc98\008a\fcb0\008a\0002\0000\fd2c\008a\0002\0000\ff8c\008a\f8d0\7b07\0000"...
=== debiant2 (32 bit Japanese:Japan report) ===
kernel32: loader.c:4022: Test failed: got 0xc0000141 loader.c:4025: Test failed: got file name L"\3a43\775c\6e69\6f64\7377\735c\7379\6574\336d\5c32\7375\7265\3233\642e\6c6c\6c00\0000\7ffc\0018\0000\0000\0000\3e29X\000c\0000\2bf8\7ffc\0000\0000\fcb8\008a\dba9\7bc4\2c00\7ffc\0018\0000\0000\0000\c41d\7b03\fca8\008a\fc98\008a\fcb0\008a\0002\0000\fd2c\008a\0002\0000\ff8c\008a\f8d0\7b07\0000"...
=== debiant2 (32 bit Chinese:China report) ===
kernel32: loader.c:4022: Test failed: got 0xc0000141 loader.c:4025: Test failed: got file name L"\3a43\775c\6e69\6f64\7377\735c\7379\6574\336d\5c32\7375\7265\3233\642e\6c6c\6c00\7000\7f00\0018\0000\0000\0000\3e29X\000c\0000\2bf8\7ffc\0000\0000\fcb8\008a\dba9\7bc4\2c00\7ffc\0018\0000\0000\0000\c41d\7b03\fca8\008a\fc98\008a\fcb0\008a\0002\0000\fd2c\008a\0002\0000\ff8c\008a\f8d0\7b07\0000"...
=== debiant2 (32 bit WoW report) ===
ntdll: env.c:543: Test failed: wrong end ptr 001115B0/00112000
=== debiant2 (64 bit WoW report) ===
ntdll: env.c:543: Test failed: wrong end ptr 001115B0/00112000