PVOID NtDllBase;
extern LARGE_INTEGER RtlpTimeout;
BOOLEAN RtlpTimeoutDisable;
+PVOID LdrpHeap;
LIST_ENTRY LdrpHashTable[LDR_HASH_TABLE_ENTRIES];
LIST_ENTRY LdrpDllNotificationList;
HANDLE LdrpKnownDllObjectDirectory;
if (Count > 16)
{
/* Allocate space for all the entries */
- LdrRootEntry = RtlAllocateHeap(RtlGetProcessHeap(),
+ LdrRootEntry = RtlAllocateHeap(LdrpHeap,
0,
Count * sizeof(*LdrRootEntry));
if (!LdrRootEntry) return STATUS_NO_MEMORY;
if (LdrRootEntry != LocalArray)
{
/* Free the array */
- RtlFreeHeap(RtlGetProcessHeap(), 0, LdrRootEntry);
+ RtlFreeHeap(LdrpHeap, 0, LdrRootEntry);
}
/* Return to caller */
&ConfigSize);
/* Setup the Heap Parameters */
- RtlZeroMemory(&HeapParameters, sizeof(RTL_HEAP_PARAMETERS));
+ RtlZeroMemory(&HeapParameters, sizeof(HeapParameters));
HeapFlags = HEAP_GROWABLE;
- HeapParameters.Length = sizeof(RTL_HEAP_PARAMETERS);
+ HeapParameters.Length = sizeof(HeapParameters);
/* Check if we have Configuration Data */
if ((LoadConfig) && (ConfigSize == sizeof(IMAGE_LOAD_CONFIG_DIRECTORY)))
Status = RtlAllocateActivationContextStack(&Teb->ActivationContextStackPointer);
if (!NT_SUCCESS(Status)) return Status;
- // FIXME: Loader private heap is missing
- //DPRINT1("Loader private heap is missing\n");
+ RtlZeroMemory(&HeapParameters, sizeof(HeapParameters));
+ HeapFlags = HEAP_GROWABLE | HEAP_CLASS_1;
+ HeapParameters.Length = sizeof(HeapParameters);
+ LdrpHeap = RtlCreateHeap(HeapFlags, 0, 0x10000, 0x6000, 0, &HeapParameters);
+ if (!LdrpHeap)
+ {
+ DPRINT1("Failed to create loader private heap\n");
+ return STATUS_NO_MEMORY;
+ }
/* Check for Debug Heap */
if (OptionsKey)
}
/* Allocate the string*/
- StringOut->Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
+ StringOut->Buffer = RtlAllocateHeap(LdrpHeap,
0,
StringOut->Length + sizeof(WCHAR));
if (!StringOut->Buffer)
/* If Buffer is not NULL - free it */
if (StringIn->Buffer)
{
- RtlFreeHeap(RtlGetProcessHeap(), 0, StringIn->Buffer);
+ RtlFreeHeap(LdrpHeap, 0, StringIn->Buffer);
}
/* Zero it out */
ULONG BufSize = 500;
/* Allocate space for full DLL name */
- FullDllName->Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufSize + sizeof(UNICODE_NULL));
+ FullDllName->Buffer = RtlAllocateHeap(LdrpHeap, 0, BufSize + sizeof(UNICODE_NULL));
if (!FullDllName->Buffer) return FALSE;
Length = RtlDosSearchPath_U(DllPath ? DllPath : LdrpDefaultPath.Buffer,
DPRINT1("%ws from %ws\n", DllName, DllPath ? DllPath : LdrpDefaultPath.Buffer);
}
- RtlFreeUnicodeString(FullDllName);
+ LdrpFreeUnicodeString(FullDllName);
return FALSE;
}
FullDllName->MaximumLength = FullDllName->Length + sizeof(UNICODE_NULL);
/* Allocate a new buffer */
- NameBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, FullDllName->MaximumLength);
+ NameBuffer = RtlAllocateHeap(LdrpHeap, 0, FullDllName->MaximumLength);
if (!NameBuffer)
{
- RtlFreeHeap(RtlGetProcessHeap(), 0, FullDllName->Buffer);
+ RtlFreeHeap(LdrpHeap, 0, FullDllName->Buffer);
return FALSE;
}
/* Copy over the contents from the previous one and free it */
RtlCopyMemory(NameBuffer, FullDllName->Buffer, FullDllName->MaximumLength);
- RtlFreeHeap(RtlGetProcessHeap(), 0, FullDllName->Buffer);
+ RtlFreeHeap(LdrpHeap, 0, FullDllName->Buffer);
FullDllName->Buffer = NameBuffer;
/* Find last backslash */
/* Construct base DLL name */
BaseDllName->Length = (ULONG_PTR)p1 - (ULONG_PTR)p2;
BaseDllName->MaximumLength = BaseDllName->Length + sizeof(UNICODE_NULL);
- BaseDllName->Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, BaseDllName->MaximumLength);
+ BaseDllName->Buffer = RtlAllocateHeap(LdrpHeap, 0, BaseDllName->MaximumLength);
if (!BaseDllName->Buffer)
{
- RtlFreeHeap(RtlGetProcessHeap(), 0, NameBuffer);
+ RtlFreeHeap(LdrpHeap, 0, NameBuffer);
return FALSE;
}
/* Set up BaseDllName */
BaseDllName->Length = DllNameUnic.Length;
BaseDllName->MaximumLength = DllNameUnic.MaximumLength;
- BaseDllName->Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
+ BaseDllName->Buffer = RtlAllocateHeap(LdrpHeap,
0,
DllNameUnic.MaximumLength);
if (!BaseDllName->Buffer)
/* Set up FullDllName */
FullDllName->Length = LdrpKnownDllPath.Length + BaseDllName->Length + sizeof(WCHAR);
FullDllName->MaximumLength = FullDllName->Length + sizeof(UNICODE_NULL);
- FullDllName->Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, FullDllName->MaximumLength);
+ FullDllName->Buffer = RtlAllocateHeap(LdrpHeap, 0, FullDllName->MaximumLength);
if (!FullDllName->Buffer)
{
Status = STATUS_NO_MEMORY;
if (Section) NtClose(Section);
/* Free string resources */
- if (BaseDllName->Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, BaseDllName->Buffer);
- if (FullDllName->Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, FullDllName->Buffer);
+ if (BaseDllName->Buffer) RtlFreeHeap(LdrpHeap, 0, BaseDllName->Buffer);
+ if (FullDllName->Buffer) RtlFreeHeap(LdrpHeap, 0, FullDllName->Buffer);
/* Return status */
return Status;
if (!NT_SUCCESS(Status))
{
/* Free the name strings and return */
- RtlFreeUnicodeString(&FullDllName);
- RtlFreeUnicodeString(&BaseDllName);
+ LdrpFreeUnicodeString(&FullDllName);
+ LdrpFreeUnicodeString(&BaseDllName);
return Status;
}
}
RemoveEntryList(&LdrEntry->HashLinks);
/* Remove the LDR Entry */
- RtlFreeHeap(RtlGetProcessHeap(), 0, LdrEntry );
+ RtlFreeHeap(LdrpHeap, 0, LdrEntry );
/* Unmap and close section */
NtUnmapViewOfSection(NtCurrentProcess(), ViewBase);
if (NtHeader)
{
/* Allocate an entry */
- LdrEntry = RtlAllocateHeap(RtlGetProcessHeap(),
+ LdrEntry = RtlAllocateHeap(LdrpHeap,
HEAP_ZERO_MEMORY,
sizeof(LDR_DATA_TABLE_ENTRY));
if (Entry->FullDllName.Buffer) LdrpFreeUnicodeString(&Entry->FullDllName);
/* Finally free the entry's memory */
- RtlFreeHeap(RtlGetProcessHeap(), 0, Entry);
+ RtlFreeHeap(LdrpHeap, 0, Entry);
}
BOOLEAN