Alexandre Julliard : ntdll: Add a Wine-specific NtQueryVirtualMemory() query to retrieve the Unix call table.

Alexandre Julliard julliard at winehq.org
Tue Aug 10 16:24:08 CDT 2021


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Aug 10 17:56:14 2021 +0200

ntdll: Add a Wine-specific NtQueryVirtualMemory() query to retrieve the Unix call table.

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

---

 dlls/ntdll/unix/virtual.c | 41 ++++++++++++++++++++++++++++++++++++++++-
 include/winternl.h        |  4 +++-
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index ee1f331d778..3532f5c8746 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -657,6 +657,29 @@ void *get_builtin_so_handle( void *module )
 }
 
 
+/***********************************************************************
+ *           get_builtin_unix_funcs
+ */
+NTSTATUS get_builtin_unix_funcs( void *module, BOOL wow, void **funcs )
+{
+    const char *ptr_name = wow ? "__wine_unix_call_wow64_funcs" : "__wine_unix_call_funcs";
+    sigset_t sigset;
+    NTSTATUS status = STATUS_DLL_NOT_FOUND;
+    struct builtin_module *builtin;
+
+    server_enter_uninterrupted_section( &virtual_mutex, &sigset );
+    LIST_FOR_EACH_ENTRY( builtin, &builtin_modules, struct builtin_module, entry )
+    {
+        if (builtin->module != module) continue;
+        *funcs = dlsym( builtin->unix_handle, ptr_name );
+        status = STATUS_SUCCESS;
+        break;
+    }
+    server_leave_uninterrupted_section( &virtual_mutex, &sigset );
+    return status;
+}
+
+
 /***********************************************************************
  *           get_builtin_unix_info
  */
@@ -4289,6 +4312,8 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr,
                                       MEMORY_INFORMATION_CLASS info_class,
                                       PVOID buffer, SIZE_T len, SIZE_T *res_len )
 {
+    NTSTATUS status;
+
     TRACE("(%p, %p, info_class=%d, %p, %ld, %p)\n",
           process, addr, info_class, buffer, len, res_len);
 
@@ -4311,13 +4336,27 @@ NTSTATUS WINAPI NtQueryVirtualMemory( HANDLE process, LPCVOID addr,
 
                 if (handle)
                 {
-                    NTSTATUS status = get_builtin_init_funcs( handle, buffer, len, res_len );
+                    status = get_builtin_init_funcs( handle, buffer, len, res_len );
                     release_builtin_module( module );
                     return status;
                 }
             }
             return STATUS_INVALID_HANDLE;
 
+        case MemoryWineUnixFuncs:
+        case MemoryWineUnixWow64Funcs:
+            if (len != sizeof(UINT64)) return STATUS_INFO_LENGTH_MISMATCH;
+            if (process == GetCurrentProcess())
+            {
+                void *module = (void *)addr;
+                void *funcs = NULL;
+
+                status = get_builtin_unix_funcs( module, info_class == MemoryWineUnixWow64Funcs, &funcs );
+                if (!status) *(UINT64 *)buffer = (UINT_PTR)funcs;
+                return status;
+            }
+            return STATUS_INVALID_HANDLE;
+
         default:
             FIXME("(%p,%p,info_class=%d,%p,%ld,%p) Unknown information class\n",
                   process, addr, info_class, buffer, len, res_len);
diff --git a/include/winternl.h b/include/winternl.h
index 075b1863f72..41bc56d186d 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -1919,7 +1919,9 @@ typedef enum _MEMORY_INFORMATION_CLASS {
     MemoryBasicInformationCapped,
     MemoryPhysicalContiguityInformation,
 #ifdef __WINESRC__
-    MemoryWineImageInitFuncs = 1000
+    MemoryWineImageInitFuncs = 1000,
+    MemoryWineUnixFuncs,
+    MemoryWineUnixWow64Funcs,
 #endif
 } MEMORY_INFORMATION_CLASS;
 




More information about the wine-cvs mailing list