Alexandre Julliard : server: Use TEB->ArbitraryUserPointer to store the loaded dll names.

Alexandre Julliard julliard at winehq.org
Thu Feb 11 15:37:14 CST 2021


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Feb 11 11:37:00 2021 +0100

server: Use TEB->ArbitraryUserPointer to store the loaded dll names.

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

---

 dlls/ntdll/loader.c | 5 +++++
 server/debugger.c   | 9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 40efd46d3c7..378b812868c 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -2641,6 +2641,7 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
     HANDLE mapping = 0;
     SECTION_IMAGE_INFORMATION image_info;
     NTSTATUS nts;
+    void *prev;
 
     TRACE( "looking for %s in %s\n", debugstr_w(libname), debugstr_w(load_path) );
 
@@ -2662,6 +2663,9 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
     main_exe = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
     loadorder = get_load_order( main_exe ? main_exe->ldr.BaseDllName.Buffer : NULL, &nt_name );
 
+    prev = NtCurrentTeb()->Tib.ArbitraryUserPointer;
+    NtCurrentTeb()->Tib.ArbitraryUserPointer = nt_name.Buffer + 4;
+
     switch (nts)
     {
     case STATUS_INVALID_IMAGE_NOT_MZ:  /* not in PE format, maybe it's a .so file */
@@ -2748,6 +2752,7 @@ static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WC
         }
         break;
     }
+    NtCurrentTeb()->Tib.ArbitraryUserPointer = prev;
 
 done:
     if (nts == STATUS_SUCCESS)
diff --git a/server/debugger.c b/server/debugger.c
index 2e3de0d41ab..9f389075b92 100644
--- a/server/debugger.c
+++ b/server/debugger.c
@@ -131,6 +131,13 @@ static const struct object_ops debug_obj_ops =
     debug_obj_destroy              /* destroy */
 };
 
+/* get a pointer to TEB->ArbitraryUserPointer in the client address space */
+static client_ptr_t get_teb_user_ptr( struct thread *thread )
+{
+    unsigned int ptr_size = (CPU_FLAG( thread->process->cpu ) & CPU_64BIT_MASK) ? 8 : 4;
+    return thread->teb + 5 * ptr_size;
+}
+
 
 /* routines to build an event according to its type */
 
@@ -181,7 +188,7 @@ static void fill_load_dll_event( struct debug_event *event, const void *arg )
 
     event->data.load_dll.dbg_offset = image_info->dbg_offset;
     event->data.load_dll.dbg_size   = image_info->dbg_size;
-    event->data.load_dll.name       = dll->name;
+    event->data.load_dll.name       = get_teb_user_ptr( event->sender );
     event->file = get_view_file( view, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE );
 }
 




More information about the wine-cvs mailing list