Module: wine Branch: master Commit: 55d98c572cdaa9a6554012b9820ba7ff8ccda251 URL: https://source.winehq.org/git/wine.git/?a=commit;h=55d98c572cdaa9a6554012b98...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Apr 19 15:15:26 2021 +0200
ntdll: Use the loadFrom directory to load dlls from the activation context.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50978 Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ntdll/loader.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 153b4a02769..4a5422b52ac 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -2431,6 +2431,44 @@ failed: }
+/*********************************************************************** + * build_dlldata_path + * + * Helper for find_actctx_dll. + */ +static NTSTATUS build_dlldata_path( LPCWSTR libname, ACTCTX_SECTION_KEYED_DATA *data, LPWSTR *fullname ) +{ + struct dllredirect_data *dlldata = data->lpData; + char *base = data->lpSectionBase; + SIZE_T total = dlldata->total_len + (wcslen(libname) + 1) * sizeof(WCHAR); + WCHAR *p, *buffer; + NTSTATUS status = STATUS_SUCCESS; + ULONG i; + + if (!(p = buffer = RtlAllocateHeap( GetProcessHeap(), 0, total ))) return STATUS_NO_MEMORY; + for (i = 0; i < dlldata->paths_count; i++) + { + memcpy( p, base + dlldata->paths[i].offset, dlldata->paths[i].len ); + p += dlldata->paths[i].len / sizeof(WCHAR); + } + wcscpy( p, libname ); + + if (dlldata->flags & DLL_REDIRECT_PATH_EXPAND) + { + RtlExpandEnvironmentStrings( NULL, buffer, wcslen(buffer), NULL, 0, &total ); + if ((*fullname = RtlAllocateHeap( GetProcessHeap(), 0, total * sizeof(WCHAR) ))) + RtlExpandEnvironmentStrings( NULL, buffer, wcslen(buffer), *fullname, total, NULL ); + else + status = STATUS_NO_MEMORY; + + RtlFreeHeap( GetProcessHeap(), 0, buffer ); + } + else *fullname = buffer; + + return status; +} + + /*********************************************************************** * find_actctx_dll * @@ -2440,8 +2478,9 @@ static NTSTATUS find_actctx_dll( LPCWSTR libname, LPWSTR *fullname ) { static const WCHAR winsxsW[] = {'\','w','i','n','s','x','s','\'};
- ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info; + ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION *info = NULL; ACTCTX_SECTION_KEYED_DATA data; + struct dllredirect_data *dlldata; UNICODE_STRING nameW; NTSTATUS status; SIZE_T needed, size = 1024; @@ -2454,6 +2493,18 @@ static NTSTATUS find_actctx_dll( LPCWSTR libname, LPWSTR *fullname ) &nameW, &data ); if (status != STATUS_SUCCESS) return status;
+ if (data.ulLength < offsetof( struct dllredirect_data, paths[0] )) + { + status = STATUS_SXS_KEY_NOT_FOUND; + goto done; + } + dlldata = data.lpData; + if (!(dlldata->flags & DLL_REDIRECT_PATH_OMITS_ASSEMBLY_ROOT)) + { + status = build_dlldata_path( libname, &data, fullname ); + goto done; + } + for (;;) { if (!(info = RtlAllocateHeap( GetProcessHeap(), 0, size )))