From: Jacek Caban jacek@codeweavers.com
--- dlls/ntdll/loader.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 0a7eddfb4e5..803edec5d15 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -192,9 +192,9 @@ static LDR_DDAG_NODE *node_ntdll, *node_kernel32; static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, DWORD flags, WINE_MODREF** pwm, BOOL system ); static NTSTATUS process_attach( LDR_DDAG_NODE *node, LPVOID lpReserved ); static FARPROC find_ordinal_export( WINE_MODREF *wm, const IMAGE_EXPORT_DIRECTORY *exports, - DWORD exp_size, DWORD ordinal, LPCWSTR load_path ); + DWORD exp_size, DWORD ordinal, LPCWSTR load_path, const WCHAR *user ); static FARPROC find_named_export( WINE_MODREF *wm, const IMAGE_EXPORT_DIRECTORY *exports, - DWORD exp_size, const char *name, int hint, LPCWSTR load_path ); + DWORD exp_size, const char *name, int hint, LPCWSTR load_path, const WCHAR *user );
/* check whether the file name contains a path */ static inline BOOL contains_path( LPCWSTR name ) @@ -903,7 +903,7 @@ static NTSTATUS walk_node_dependencies( LDR_DDAG_NODE *node, void *context, * Find the final function pointer for a forwarded function. * The loader_section must be locked while calling this function. */ -static FARPROC find_forwarded_export( WINE_MODREF *imp, const char *forward, LPCWSTR load_path ) +static FARPROC find_forwarded_export( WINE_MODREF *imp, const char *forward, LPCWSTR load_path, const WCHAR *user ) { const IMAGE_EXPORT_DIRECTORY *exports; DWORD exp_size; @@ -945,10 +945,10 @@ static FARPROC find_forwarded_export( WINE_MODREF *imp, const char *forward, LPC const char *name = end + 1;
if (*name == '#') { /* ordinal */ - proc = find_ordinal_export( wm, exports, exp_size, - atoi(name+1) - exports->Base, load_path ); + proc = find_ordinal_export( wm, exports, exp_size, atoi(name+1) - exports->Base, + load_path, user ); } else - proc = find_named_export( wm, exports, exp_size, name, -1, load_path ); + proc = find_named_export( wm, exports, exp_size, name, -1, load_path, user ); }
if (!proc) @@ -970,7 +970,7 @@ static FARPROC find_forwarded_export( WINE_MODREF *imp, const char *forward, LPC * The loader_section must be locked while calling this function. */ static FARPROC find_ordinal_export( WINE_MODREF *wm, const IMAGE_EXPORT_DIRECTORY *exports, - DWORD exp_size, DWORD ordinal, LPCWSTR load_path ) + DWORD exp_size, DWORD ordinal, LPCWSTR load_path, const WCHAR *user ) { HMODULE module = wm->ldr.DllBase; FARPROC proc; @@ -988,18 +988,12 @@ static FARPROC find_ordinal_export( WINE_MODREF *wm, const IMAGE_EXPORT_DIRECTOR /* if the address falls into the export dir, it's a forward */ if (((const char *)proc >= (const char *)exports) && ((const char *)proc < (const char *)exports + exp_size)) - return find_forwarded_export( wm, (const char *)proc, load_path ); + return find_forwarded_export( wm, (const char *)proc, load_path, user );
if (TRACE_ON(snoop)) - { - const WCHAR *user = current_modref ? current_modref->ldr.BaseDllName.Buffer : NULL; proc = SNOOP_GetProcAddress( module, exports, exp_size, proc, ordinal, user ); - } if (TRACE_ON(relay)) - { - const WCHAR *user = current_modref ? current_modref->ldr.BaseDllName.Buffer : NULL; proc = RELAY_GetProcAddress( module, exports, exp_size, proc, ordinal, user ); - } return proc; }
@@ -1034,7 +1028,8 @@ static int find_name_in_exports( HMODULE module, const IMAGE_EXPORT_DIRECTORY *e * The loader_section must be locked while calling this function. */ static FARPROC find_named_export( WINE_MODREF *wm, const IMAGE_EXPORT_DIRECTORY *exports, - DWORD exp_size, const char *name, int hint, LPCWSTR load_path ) + DWORD exp_size, const char *name, int hint, LPCWSTR load_path, + const WCHAR *user ) { const HMODULE module = wm->ldr.DllBase; const WORD *ordinals = get_rva( module, exports->AddressOfNameOrdinals ); @@ -1046,12 +1041,12 @@ static FARPROC find_named_export( WINE_MODREF *wm, const IMAGE_EXPORT_DIRECTORY { char *ename = get_rva( module, names[hint] ); if (!strcmp( ename, name )) - return find_ordinal_export( wm, exports, exp_size, ordinals[hint], load_path ); + return find_ordinal_export( wm, exports, exp_size, ordinals[hint], load_path, user ); }
/* then do a binary search */ if ((ordinal = find_name_in_exports( module, exports, name )) == -1) return NULL; - return find_ordinal_export( wm, exports, exp_size, ordinal, load_path ); + return find_ordinal_export( wm, exports, exp_size, ordinal, load_path, user );
}
@@ -1175,7 +1170,8 @@ static BOOL import_dll( WINE_MODREF *wm, const IMAGE_IMPORT_DESCRIPTOR *descr, L int ordinal = IMAGE_ORDINAL(import_list->u1.Ordinal);
thunk_list->u1.Function = (ULONG_PTR)find_ordinal_export( wmImp, exports, exp_size, - ordinal - exports->Base, load_path ); + ordinal - exports->Base, load_path, + wm->ldr.BaseDllName.Buffer ); if (!thunk_list->u1.Function) { thunk_list->u1.Function = allocate_stub( name, IntToPtr(ordinal) ); @@ -1191,7 +1187,8 @@ static BOOL import_dll( WINE_MODREF *wm, const IMAGE_IMPORT_DESCRIPTOR *descr, L pe_name = get_rva( module, (DWORD)import_list->u1.AddressOfData ); thunk_list->u1.Function = (ULONG_PTR)find_named_export( wmImp, exports, exp_size, (const char*)pe_name->Name, - pe_name->Hint, load_path ); + pe_name->Hint, load_path, + wm->ldr.BaseDllName.Buffer ); if (!thunk_list->u1.Function) { thunk_list->u1.Function = allocate_stub( name, (const char*)pe_name->Name ); @@ -2038,8 +2035,8 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name, else if ((exports = RtlImageDirectoryEntryToData( module, TRUE, IMAGE_DIRECTORY_ENTRY_EXPORT, &exp_size ))) { - void *proc = name ? find_named_export( wm, exports, exp_size, name->Buffer, -1, NULL ) - : find_ordinal_export( wm, exports, exp_size, ord - exports->Base, NULL ); + void *proc = name ? find_named_export( wm, exports, exp_size, name->Buffer, -1, NULL, NULL ) + : find_ordinal_export( wm, exports, exp_size, ord - exports->Base, NULL, NULL ); if (proc) { *address = proc;