From f382315b712764d0727d91cae26890a6bfb59471 Mon Sep 17 00:00:00 2001 From: Art Yerkes Date: Thu, 30 Oct 2003 15:52:29 +0000 Subject: [PATCH] Set the lpvReserved parameter of DllMain according to whether the DLL was loaded using LoadLibrary or at start time by the system loader. DLLs use this mechanism to determine how they were loaded. svn path=/trunk/; revision=6466 --- reactos/lib/kernel32/misc/ldr.c | 7 ++++++- reactos/lib/ntdll/ldr/utils.c | 13 ++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/reactos/lib/kernel32/misc/ldr.c b/reactos/lib/kernel32/misc/ldr.c index 5327a62757b..540b350495a 100644 --- a/reactos/lib/kernel32/misc/ldr.c +++ b/reactos/lib/kernel32/misc/ldr.c @@ -1,4 +1,4 @@ -/* $Id: ldr.c,v 1.16 2003/07/10 18:50:51 chorns Exp $ +/* $Id: ldr.c,v 1.17 2003/10/30 15:52:29 arty Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT : ReactOS user mode libraries @@ -130,6 +130,11 @@ LoadLibraryExW ( if ( lpLibFileName == NULL ) return NULL; + dwFlags &= + DONT_RESOLVE_DLL_REFERENCES | + LOAD_LIBRARY_AS_DATAFILE | + LOAD_WITH_ALTERED_SEARCH_PATH; + RtlInitUnicodeString (&DllName, (LPWSTR)lpLibFileName); Status = LdrLoadDll(NULL, dwFlags, &DllName, (PVOID*)&hInst); if ( !NT_SUCCESS(Status)) diff --git a/reactos/lib/ntdll/ldr/utils.c b/reactos/lib/ntdll/ldr/utils.c index 705f9bc1f5a..a46105b665e 100644 --- a/reactos/lib/ntdll/ldr/utils.c +++ b/reactos/lib/ntdll/ldr/utils.c @@ -1,4 +1,4 @@ -/* $Id: utils.c,v 1.71 2003/09/12 17:51:47 vizzini Exp $ +/* $Id: utils.c,v 1.72 2003/10/30 15:52:29 arty Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -25,6 +25,7 @@ #include #include +#define LDRP_PROCESS_CREATION_TIME 0x8000000 #ifdef DBG_NTDLL_LDR_UTILS #define NDEBUG @@ -613,7 +614,9 @@ LdrLoadDll (IN PWSTR SearchPath OPTIONAL, DPRINT("Calling entry point at 0x%08x\n", Entrypoint); if (FALSE == Entrypoint(Module->BaseAddress, DLL_PROCESS_ATTACH, - NULL)) + (void *) + ((LoadFlags & LDRP_PROCESS_CREATION_TIME) ? + 1 : 0))) { /* Do this as a DPRINT1 for now, until clean up and fail implemented */ DPRINT1("NTDLL.LDR: DLL \"%wZ\" failed to initialize\n", @@ -820,7 +823,7 @@ LdrFixupForward(PCHAR ForwardName) if (!NT_SUCCESS(Status)) { Status = LdrLoadDll(NULL, - 0, + LDRP_PROCESS_CREATION_TIME, &DllName, &BaseAddress); if (!NT_SUCCESS(Status)) @@ -1293,7 +1296,7 @@ static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders, if (!NT_SUCCESS(Status)) { Status = LdrLoadDll(NULL, - 0, + LDRP_PROCESS_CREATION_TIME, &DllName, &BaseAddress); RtlFreeUnicodeString (&DllName); @@ -1775,7 +1778,7 @@ LdrShutdownProcess (VOID) DPRINT("Calling entry point at 0x%08x\n", Entrypoint); Entrypoint (Module->BaseAddress, DLL_PROCESS_DETACH, - NULL); + (void *)TRUE); } Entry = Entry->Blink;