GetModuleFileName[A/W] must cope with NULL module handles

svn path=/trunk/; revision=1615
This commit is contained in:
Eric Kohl 2001-02-10 22:29:35 +00:00
parent af68ad91d4
commit 6922d2a9e5

View file

@ -1,4 +1,4 @@
/* $Id: ldr.c,v 1.10 2001/01/24 04:41:58 phreak Exp $ /* $Id: ldr.c,v 1.11 2001/02/10 22:29:35 ekohl Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT : ReactOS user mode libraries * PROJECT : ReactOS user mode libraries
@ -194,6 +194,9 @@ GetModuleFileNameA (
Peb = NtCurrentPeb (); Peb = NtCurrentPeb ();
RtlEnterCriticalSection (Peb->LoaderLock); RtlEnterCriticalSection (Peb->LoaderLock);
if (hModule == NULL)
hModule = Peb->ImageBaseAddress;
ModuleListHead = &Peb->Ldr->InLoadOrderModuleList; ModuleListHead = &Peb->Ldr->InLoadOrderModuleList;
Entry = ModuleListHead->Flink; Entry = ModuleListHead->Flink;
@ -234,7 +237,6 @@ GetModuleFileNameA (
SetLastErrorByStatus (STATUS_DLL_NOT_FOUND); SetLastErrorByStatus (STATUS_DLL_NOT_FOUND);
RtlLeaveCriticalSection (Peb->LoaderLock); RtlLeaveCriticalSection (Peb->LoaderLock);
return 0; return 0;
} }
@ -257,6 +259,9 @@ GetModuleFileNameW (
Peb = NtCurrentPeb (); Peb = NtCurrentPeb ();
RtlEnterCriticalSection (Peb->LoaderLock); RtlEnterCriticalSection (Peb->LoaderLock);
if (hModule == NULL)
hModule = Peb->ImageBaseAddress;
ModuleListHead = &Peb->Ldr->InLoadOrderModuleList; ModuleListHead = &Peb->Ldr->InLoadOrderModuleList;
Entry = ModuleListHead->Flink; Entry = ModuleListHead->Flink;
while (Entry != ModuleListHead) while (Entry != ModuleListHead)