[PATCH 2/3] ntdll: Stub Wow64Transition.
Zebediah Figura
z.figura12 at gmail.com
Thu Feb 25 21:38:31 CST 2021
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 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
--
2.20.1
More information about the wine-devel
mailing list