diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 4d15779847d..23c6e3b5b2e 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -681,6 +681,12 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename ) /* wait until init is called for inserting into this list */ wm->ldr.InInitializationOrderModuleList.Flink = NULL; wm->ldr.InInitializationOrderModuleList.Blink = NULL; + + if (!(nt->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT)) + { + WARN( "disabling no-exec because of %s\n", debugstr_w(wm->ldr.BaseDllName.Buffer) ); + VIRTUAL_SetForceExec( TRUE ); + } return wm; } @@ -2126,8 +2132,6 @@ void WINAPI LdrInitializeThunk( ULONG unknown1, ULONG unknown2, ULONG unknown3, peb->ProcessParameters->ImagePathName = wm->ldr.FullDllName; version_init( wm->ldr.FullDllName.Buffer ); - if (!(nt->OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT)) - VIRTUAL_SetForceExec( TRUE ); /* the main exe needs to be the first in the load order list */ RemoveEntryList( &wm->ldr.InLoadOrderModuleList );