[PATCH v3 2/3] ntdll: Stub Wow64Transition.
Zebediah Figura
z.figura12 at gmail.com
Wed Oct 28 10:56:06 CDT 2020
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45567
Signed-off-by: Zebediah Figura <z.figura12 at 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
--
2.28.0
More information about the wine-devel
mailing list