[NTDLL/LDR]

- Fix CMake build
- Don't override failure status in LdrGetDllHandleEx
- Minor improvements
Fixes loading of mshtml.tlb in 2nd stage. Patch by Thomas Faber

svn path=/trunk/; revision=52591
This commit is contained in:
Rafal Harabien 2011-07-09 21:48:59 +00:00
parent 03c817cabf
commit 2bd7185260
2 changed files with 31 additions and 49 deletions

View file

@ -20,8 +20,6 @@ list(APPEND SOURCE
ldr/ldrinit.c
ldr/ldrpe.c
ldr/ldrutils.c
ldr/startup.c
ldr/utils.c
rtl/libsupp.c
rtl/version.c
def/ntdll.rc

View file

@ -522,6 +522,10 @@ LdrGetDllHandleEx(IN ULONG Flags,
/* Unrecoverable SxS failure; */
goto Quickie;
}
else
{
ASSERT(pRedirectName == &RedirectName);
}
/* Set default failure code */
Status = STATUS_DLL_NOT_FOUND;
@ -533,29 +537,25 @@ LdrGetDllHandleEx(IN ULONG Flags,
if (RedirectedDll)
{
/* Check the flag */
if (LdrpGetModuleHandleCache->Flags & LDRP_REDIRECTED)
if (!(LdrpGetModuleHandleCache->Flags & LDRP_REDIRECTED))
{
goto DontCompare;
}
/* Use the right name */
CompareName = &LdrpGetModuleHandleCache->FullDllName;
}
else
{
/* Check the flag */
if (LdrpGetModuleHandleCache->Flags & LDRP_REDIRECTED)
{
goto DontCompare;
}
}
else
{
/* Check the flag */
if (!(LdrpGetModuleHandleCache->Flags & LDRP_REDIRECTED))
{
/* Use the right name */
CompareName = &LdrpGetModuleHandleCache->BaseDllName;
}
else
{
goto DontCompare;
}
}
/* Check if the name matches */
if (RtlEqualUnicodeString(pRedirectName,
@ -604,7 +604,6 @@ DontCompare:
/* Setup the string */
RawDllName.MaximumLength = Length;
ASSERT(Length >= sizeof(UNICODE_NULL));
RawDllName.Length = RawDllName.MaximumLength - sizeof(UNICODE_NULL);
RawDllName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
0,
RawDllName.MaximumLength);
@ -614,18 +613,9 @@ DontCompare:
goto Quickie;
}
/* Copy the buffer */
RtlMoveMemory(RawDllName.Buffer,
pRedirectName->Buffer,
pRedirectName->Length);
/* Add extension */
RtlMoveMemory((PVOID)((ULONG_PTR)RawDllName.Buffer + pRedirectName->Length),
LdrApiDefaultExtension.Buffer,
LdrApiDefaultExtension.Length);
/* Null terminate */
RawDllName.Buffer[RawDllName.Length / sizeof(WCHAR)] = UNICODE_NULL;
/* Copy the string and add extension */
RtlCopyUnicodeString(&RawDllName, pRedirectName);
RtlAppendUnicodeStringToString(&RawDllName, &LdrApiDefaultExtension);
}
else
{
@ -643,7 +633,6 @@ DontCompare:
/* Setup the string */
RawDllName.MaximumLength = pRedirectName->Length + sizeof(WCHAR);
RawDllName.Length = pRedirectName->Length;
RawDllName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
0,
RawDllName.MaximumLength);
@ -653,19 +642,14 @@ DontCompare:
goto Quickie;
}
/* Copy the buffer */
RtlMoveMemory(RawDllName.Buffer,
pRedirectName->Buffer,
pRedirectName->Length);
/* Null terminate */
RawDllName.Buffer[RawDllName.Length / sizeof(WCHAR)] = UNICODE_NULL;
/* Copy the string */
RtlCopyUnicodeString(&RawDllName, pRedirectName);
}
/* Display debug string */
if (ShowSnaps)
{
DPRINT1("LDR: LdrGetDllHandle, searching for %wZ from %ws\n",
DPRINT1("LDR: LdrGetDllHandleEx, searching for %wZ from %ws\n",
&RawDllName,
DllPath ? ((ULONG_PTR)DllPath == 1 ? L"" : DllPath) : L"");
}
@ -730,14 +714,14 @@ Quickie:
if (RawDllName.Buffer)
{
/* Free the heap-allocated buffer */
Status = RtlFreeHeap(RtlGetProcessHeap(), 0, RawDllName.Buffer);
RtlFreeHeap(RtlGetProcessHeap(), 0, RawDllName.Buffer);
RawDllName.Buffer = NULL;
}
/* Release lock */
if (Locked)
{
Status = LdrUnlockLoaderLock(LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS,
LdrUnlockLoaderLock(LDR_LOCK_LOADER_LOCK_FLAG_RAISE_ON_ERRORS,
Cookie);
}
@ -756,7 +740,7 @@ LdrGetDllHandle(IN PWSTR DllPath OPTIONAL,
OUT PVOID *DllHandle)
{
/* Call the newer API */
return LdrGetDllHandleEx(TRUE,
return LdrGetDllHandleEx(LDR_GET_DLL_HANDLE_EX_UNCHANGED_REFCOUNT,
DllPath,
DllCharacteristics,
DllName,