From 0834f08bfe48fa4c286fe9eca2367f70195b59e9 Mon Sep 17 00:00:00 2001 From: Myah Caron Date: Wed, 1 Apr 2020 14:01:53 -0700 Subject: [PATCH] ntdll: Use a cached version of LDR_MODULE flags for InitDLL. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48817 Signed-off-by: Myah Caron --- v3: The patch should hopefully apply now, thanks to Tk-Glitch. Supersedes "Don't fail if LDR_MODULE.Flags is modified during load" --- dlls/ntdll/loader.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index b946416734..c1f77e896b 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -118,6 +118,7 @@ static const WCHAR dllW[] = {'.','d','l','l',0}; typedef struct _wine_modref { LDR_MODULE ldr; + ULONG initial_flags; dev_t dev; ino_t ino; int alloc_deps; @@ -1197,6 +1198,8 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name wm->ldr.EntryPoint = (char *)hModule + nt->OptionalHeader.AddressOfEntryPoint; } + wm->initial_flags = wm->ldr.Flags; + InsertTailList(&NtCurrentTeb()->Peb->LdrData->InLoadOrderModuleList, &wm->ldr.InLoadOrderModuleList); InsertTailList(&NtCurrentTeb()->Peb->LdrData->InMemoryOrderModuleList, @@ -1307,9 +1310,9 @@ static NTSTATUS MODULE_InitDLL( WINE_MODREF *wm, UINT reason, LPVOID lpReserved /* Skip calls for modules loaded with special load flags */ - if (wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) return STATUS_SUCCESS; + if (wm->initial_flags & LDR_DONT_RESOLVE_REFS) return STATUS_SUCCESS; if (wm->ldr.TlsIndex != -1) call_tls_callbacks( wm->ldr.BaseAddress, reason ); - if (!entry || !(wm->ldr.Flags & LDR_IMAGE_IS_DLL)) return STATUS_SUCCESS; + if (!entry || !(wm->initial_flags & LDR_IMAGE_IS_DLL)) return STATUS_SUCCESS; if (TRACE_ON(relay)) { @@ -1400,6 +1403,9 @@ static NTSTATUS process_attach( WINE_MODREF *wm, LPVOID lpReserved ) if (lpReserved) wm->ldr.LoadCount = -1; /* pin it if imported by the main exe */ if (wm->ldr.ActivationContext) RtlActivateActivationContext( 0, wm->ldr.ActivationContext, &cookie ); + /* The flags can be modified by DLL dependencies */ + wm->initial_flags = wm->ldr.Flags; + /* Recursively attach all DLLs this one depends on */ for ( i = 0; i < wm->nDeps; i++ ) { -- 2.25.1