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

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-02-11 11:37:00 +01:00
parent bd0a3c1a59
commit 4f2ed66a5f
2 changed files with 13 additions and 1 deletions

View File

@ -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)

View File

@ -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 );
}