From 2417bf273fabee77c652d447567ed683f66541f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Thu, 7 Sep 2006 19:16:47 +0000 Subject: [PATCH] Correctly handle optional parameters svn path=/trunk/; revision=23966 --- reactos/dll/ntdll/ldr/utils.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index 44f62fe5d17..f7a94cd4d07 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -727,7 +727,7 @@ LdrpMapDllImageFile(IN PWSTR SearchPath OPTIONAL, */ NTSTATUS NTAPI LdrLoadDll (IN PWSTR SearchPath OPTIONAL, - IN PULONG LoadFlags, + IN PULONG LoadFlags OPTIONAL, IN PUNICODE_STRING Name, OUT PVOID *BaseAddress OPTIONAL) { @@ -741,19 +741,22 @@ LdrLoadDll (IN PWSTR SearchPath OPTIONAL, if (Name == NULL) { - *BaseAddress = NtCurrentPeb()->ImageBaseAddress; + if (BaseAddress) + *BaseAddress = NtCurrentPeb()->ImageBaseAddress; return STATUS_SUCCESS; } - *BaseAddress = NULL; + if (BaseAddress) + *BaseAddress = NULL; - Status = LdrpLoadModule(SearchPath, *LoadFlags, Name, &Module, BaseAddress); - if (NT_SUCCESS(Status) && 0 == (*LoadFlags & LOAD_LIBRARY_AS_DATAFILE)) + Status = LdrpLoadModule(SearchPath, LoadFlags ? *LoadFlags : 0, Name, &Module, BaseAddress); + if (NT_SUCCESS(Status) + && (!LoadFlags || 0 == (*LoadFlags & LOAD_LIBRARY_AS_DATAFILE))) { RtlEnterCriticalSection(NtCurrentPeb()->LoaderLock); Status = LdrpAttachProcess(); RtlLeaveCriticalSection(NtCurrentPeb()->LoaderLock); - if (NT_SUCCESS(Status)) + if (NT_SUCCESS(Status) && BaseAddress) { *BaseAddress = Module->DllBase; }