Alexandre Julliard : ntdll: Only check the is_wow64 flag on 32-bit platforms.

Alexandre Julliard julliard at winehq.org
Mon May 17 15:45:30 CDT 2021


Module: wine
Branch: master
Commit: e40eab977aabfcffaf1505f35f59b017e9441078
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e40eab977aabfcffaf1505f35f59b017e9441078

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon May 17 10:12:01 2021 +0200

ntdll: Only check the is_wow64 flag on 32-bit platforms.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/process.c      | 15 +++++++--------
 dlls/ntdll/unix/server.c       |  4 +++-
 dlls/ntdll/unix/thread.c       |  8 +++++++-
 dlls/ntdll/unix/unix_private.h |  4 +++-
 dlls/ntdll/unix/virtual.c      | 22 ++++++++++++++--------
 5 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c
index 74e16c36fd6..54e9680699e 100644
--- a/dlls/ntdll/unix/process.c
+++ b/dlls/ntdll/unix/process.c
@@ -999,6 +999,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class
                             pbi.BasePriority = reply->priority;
                             pbi.UniqueProcessId = reply->pid;
                             pbi.InheritedFromUniqueProcessId = reply->ppid;
+#ifndef _WIN64
                             if (is_wow64)
                             {
                                 if (reply->machine != native_machine)
@@ -1006,6 +1007,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class
                                 else
                                     pbi.PebBaseAddress = NULL;
                             }
+#endif
                         }
                     }
                     SERVER_END_REQ;
@@ -1260,20 +1262,17 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class
         if (size != len) ret = STATUS_INFO_LENGTH_MISMATCH;
         else if (!info) ret = STATUS_ACCESS_VIOLATION;
         else if (!handle) ret = STATUS_INVALID_HANDLE;
+        else if (handle == GetCurrentProcess()) *(ULONG_PTR *)info = !!NtCurrentTeb()->WowTebOffset;
         else
         {
             ULONG_PTR val = 0;
 
-            if (handle == GetCurrentProcess()) val = is_wow64;
-            else if (is_win64 || is_wow64)
+            SERVER_START_REQ( get_process_info )
             {
-                SERVER_START_REQ( get_process_info )
-                {
-                    req->handle = wine_server_obj_handle( handle );
-                    if (!(ret = wine_server_call( req ))) val = (reply->machine != native_machine);
-                }
-                SERVER_END_REQ;
+                req->handle = wine_server_obj_handle( handle );
+                if (!(ret = wine_server_call( req ))) val = (reply->machine != native_machine);
             }
+            SERVER_END_REQ;
             *(ULONG_PTR *)info = val;
         }
         break;
diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c
index 33a49adb8e8..a96c91acc9c 100644
--- a/dlls/ntdll/unix/server.c
+++ b/dlls/ntdll/unix/server.c
@@ -104,8 +104,10 @@ static const char *server_dir;
 unsigned int supported_machines_count = 0;
 USHORT supported_machines[8] = { 0 };
 USHORT native_machine = 0;
-BOOL is_wow64 = FALSE;
 BOOL process_exiting = FALSE;
+#ifndef _WIN64
+BOOL is_wow64 = FALSE;
+#endif
 
 timeout_t server_start_time = 0;  /* time of server startup */
 
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index d2c14ae33c1..6455b5a449e 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -233,7 +233,9 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
     NTSTATUS status;
 
     if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3;
-    if (!is_win64 && !is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
+#ifndef _WIN64
+    if (!is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
+#endif
 
     if (process != NtCurrentProcess())
     {
@@ -950,6 +952,7 @@ BOOL get_thread_times(int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time, LA
 #endif
 }
 
+#ifndef _WIN64
 static BOOL is_process_wow64( const CLIENT_ID *id )
 {
     HANDLE handle;
@@ -965,6 +968,7 @@ static BOOL is_process_wow64( const CLIENT_ID *id )
     }
     return ret;
 }
+#endif
 
 /******************************************************************************
  *              NtQueryInformationThread  (NTDLL.@)
@@ -1000,6 +1004,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
         SERVER_END_REQ;
         if (status == STATUS_SUCCESS)
         {
+#ifndef _WIN64
             if (is_wow64)
             {
                 if (is_process_wow64( &info.ClientId ))
@@ -1007,6 +1012,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
                 else
                     info.TebBaseAddress = NULL;
             }
+#endif
             if (data) memcpy( data, &info, min( length, sizeof(info) ));
             if (ret_len) *ret_len = min( length, sizeof(info) );
         }
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index cdb36584326..464f8ca17c7 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -125,13 +125,15 @@ extern WCHAR **main_wargv DECLSPEC_HIDDEN;
 extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
 extern unsigned int supported_machines_count DECLSPEC_HIDDEN;
 extern USHORT supported_machines[8] DECLSPEC_HIDDEN;
-extern BOOL is_wow64 DECLSPEC_HIDDEN;
 extern BOOL process_exiting DECLSPEC_HIDDEN;
 extern HANDLE keyed_event DECLSPEC_HIDDEN;
 extern timeout_t server_start_time DECLSPEC_HIDDEN;
 extern sigset_t server_block_set DECLSPEC_HIDDEN;
 extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN;
 extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN;
+#ifndef _WIN64
+extern BOOL is_wow64 DECLSPEC_HIDDEN;
+#endif
 #ifdef __i386__
 extern struct ldt_copy __wine_ldt_copy DECLSPEC_HIDDEN;
 #endif
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 572ce960b77..bcab898b0fc 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -722,7 +722,9 @@ static void free_ranges_insert_view( struct file_view *view )
         (range->end == view_base && next->base >= view_end))
     {
         /* on Win64, assert that it's correctly aligned so we're not going to be in trouble later */
-        assert( (!is_win64 && !is_wow64) || view->base == view_base );
+#ifdef _WIN64
+        assert( view->base == view_base );
+#endif
         WARN( "range %p - %p is already mapped\n", view_base, view_end );
         return;
     }
@@ -2962,7 +2964,7 @@ NTSTATUS virtual_alloc_teb( TEB **ret_teb )
         NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&ptr, 0, &block_size,
                                  MEM_COMMIT, PAGE_READWRITE );
     }
-    *ret_teb = teb = init_teb( ptr, NtCurrentTeb()->Peb, is_wow64 );
+    *ret_teb = teb = init_teb( ptr, NtCurrentTeb()->Peb, !!NtCurrentTeb()->WowTebOffset );
     server_leave_uninterrupted_section( &virtual_mutex, &sigset );
 
     if ((status = signal_alloc_thread( teb )))
@@ -3674,7 +3676,9 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z
 
     if (!size) return STATUS_INVALID_PARAMETER;
     if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3;
-    if (!is_win64 && !is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
+#ifndef _WIN64
+    if (!is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
+#endif
 
     if (process != NtCurrentProcess())
     {
@@ -4344,8 +4348,6 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
     /* Check parameters */
     if (zero_bits > 21 && zero_bits < 32)
         return STATUS_INVALID_PARAMETER_4;
-    if (!is_win64 && !is_wow64 && zero_bits >= 32)
-        return STATUS_INVALID_PARAMETER_4;
 
     /* If both addr_ptr and zero_bits are passed, they have match */
     if (*addr_ptr && zero_bits && zero_bits < 32 &&
@@ -4356,10 +4358,14 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
         return STATUS_INVALID_PARAMETER_4;
 
 #ifndef _WIN64
-    if (!is_wow64 && (alloc_type & AT_ROUND_TO_PAGE))
+    if (!is_wow64)
     {
-        *addr_ptr = ROUND_ADDR( *addr_ptr, page_mask );
-        mask = page_mask;
+        if (zero_bits >= 32) return STATUS_INVALID_PARAMETER_4;
+        if (alloc_type & AT_ROUND_TO_PAGE)
+        {
+            *addr_ptr = ROUND_ADDR( *addr_ptr, page_mask );
+            mask = page_mask;
+        }
     }
 #endif
 




More information about the wine-cvs mailing list