Skip to content

Instantly share code, notes, and snippets.

@qsniyg
Created March 28, 2020 09:24
Show Gist options
  • Select an option

  • Save qsniyg/b0c2f3f91c3924cc952112e3796655b5 to your computer and use it in GitHub Desktop.

Select an option

Save qsniyg/b0c2f3f91c3924cc952112e3796655b5 to your computer and use it in GitHub Desktop.
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 1b641f1b9d..a8f3470962 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -119,6 +119,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;
@@ -1201,6 +1202,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,
@@ -1311,9 +1314,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))
{
@@ -1404,7 +1407,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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment