[FREELDR] Fix Release build

This commit is contained in:
Victor Perevertkin 2019-06-26 00:56:21 +03:00
parent f694d12f0c
commit 12542f271d
No known key found for this signature in database
GPG key ID: C750B7222E9C7830
3 changed files with 27 additions and 13 deletions

View file

@ -184,7 +184,8 @@ FrLdrHeapRelease(
PHEAP Heap = HeapHandle;
PHEAP_BLOCK Block;
PUCHAR StartAddress, EndAddress;
PFN_COUNT FreePages, AllPages, AllFreePages = 0;
PFN_COUNT FreePages, AllFreePages = 0;
TRACE("HeapRelease(%p)\n", HeapHandle);
/* Loop all heap chunks */
@ -240,13 +241,13 @@ FrLdrHeapRelease(
if (Block->Size == 0) break;
}
AllPages = Heap->MaximumSize / MM_PAGE_SIZE;
TRACE("HeapRelease() done, freed %lu of %lu pages\n", AllFreePages, AllPages);
TRACE("HeapRelease() done, freed %lu of %lu pages\n", AllFreePages, Heap->MaximumSize / MM_PAGE_SIZE);
}
VOID
FrLdrHeapCleanupAll(VOID)
{
#if DBG
PHEAP Heap;
Heap = FrLdrDefaultHeap;
@ -257,17 +258,19 @@ FrLdrHeapCleanupAll(VOID)
Heap->NumAllocs, Heap->NumFrees);
TRACE("AllocTime = %I64d, FreeTime = %I64d, sum = %I64d\n",
Heap->AllocationTime, Heap->FreeTime, Heap->AllocationTime + Heap->FreeTime);
#endif
/* Release free pages from the default heap */
FrLdrHeapRelease(FrLdrDefaultHeap);
#if DBG
Heap = FrLdrTempHeap;
TRACE("Heap statistics for temp heap:\n"
"CurrentAlloc=0x%lx, MaxAlloc=0x%lx, LargestAllocation=0x%lx\n"
"NumAllocs=%ld, NumFrees=%ld\n",
Heap->CurrentAllocBytes, Heap->MaxAllocBytes, Heap->LargestAllocation,
Heap->NumAllocs, Heap->NumFrees);
#endif
/* Destroy the temp heap */
FrLdrHeapDestroy(FrLdrTempHeap);

View file

@ -112,6 +112,7 @@ WinLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead,
ImportTable = (PIMAGE_IMPORT_DESCRIPTOR)RtlImageDirectoryEntryToData(VaToPa(ScanDTE->DllBase),
TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &ImportTableSize);
#if DBG
{
UNICODE_STRING BaseName;
BaseName.Buffer = VaToPa(ScanDTE->BaseDllName.Buffer);
@ -120,6 +121,7 @@ WinLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead,
TRACE("WinLdrScanImportDescriptorTable(): %wZ ImportTable = 0x%X\n",
&BaseName, ImportTable);
}
#endif
/* If image doesn't have any import directory - just return success */
if (ImportTable == NULL)
@ -456,17 +458,21 @@ WinLdrpCompareDllName(IN PCH DllName,
IN PUNICODE_STRING UnicodeName)
{
PWSTR Buffer;
UNICODE_STRING UnicodeNamePA;
SIZE_T i, Length;
/* First obvious check: for length of two names */
Length = strlen(DllName);
UnicodeNamePA.Length = UnicodeName->Length;
UnicodeNamePA.MaximumLength = UnicodeName->MaximumLength;
UnicodeNamePA.Buffer = VaToPa(UnicodeName->Buffer);
TRACE("WinLdrpCompareDllName: %s and %wZ, Length = %d "
"UN->Length %d\n", DllName, &UnicodeNamePA, Length, UnicodeName->Length);
#if DBG
{
UNICODE_STRING UnicodeNamePA;
UnicodeNamePA.Length = UnicodeName->Length;
UnicodeNamePA.MaximumLength = UnicodeName->MaximumLength;
UnicodeNamePA.Buffer = VaToPa(UnicodeName->Buffer);
TRACE("WinLdrpCompareDllName: %s and %wZ, Length = %d "
"UN->Length %d\n", DllName, &UnicodeNamePA, Length, UnicodeName->Length);
}
#endif
if ((Length * sizeof(WCHAR)) > UnicodeName->Length)
return FALSE;

View file

@ -36,7 +36,6 @@ static VOID
SetupLdrLoadNlsData(PLOADER_PARAMETER_BLOCK LoaderBlock, HINF InfHandle, LPCSTR SearchPath)
{
INFCONTEXT InfContext;
BOOLEAN Success;
LPCSTR AnsiName, OemName, LangName;
/* Get ANSI codepage file */
@ -76,8 +75,14 @@ SetupLdrLoadNlsData(PLOADER_PARAMETER_BLOCK LoaderBlock, HINF InfHandle, LPCSTR
TRACE("NLS data %s %s %s\n", AnsiName, OemName, LangName);
Success = WinLdrLoadNLSData(LoaderBlock, SearchPath, AnsiName, OemName, LangName);
TRACE("NLS data loading %s\n", Success ? "successful" : "failed");
#if DBG
{
BOOLEAN Success = WinLdrLoadNLSData(LoaderBlock, SearchPath, AnsiName, OemName, LangName);
TRACE("NLS data loading %s\n", Success ? "successful" : "failed");
}
#else
WinLdrLoadNLSData(LoaderBlock, SearchPath, AnsiName, OemName, LangName);
#endif
/* TODO: Load OEM HAL font */
// Value "OemHalFont"