STATIC PAGEABLE VOID messagetable_CountingCallback( _In_ PCMESSAGE_TABLE_ENTRY ptEntry, _In_opt_ PCMESSAGE_TABLE_ENTRY ptPreviousEntry, _In_ PVOID pvContext, _Out_ PBOOLEAN pbContinueEnumeration ) { NTSTATUS eStatus = STATUS_UNSUCCESSFUL; PCOUNTING_CALLBACK_CONTEXT ptContext = (PCOUNTING_CALLBACK_CONTEXT)pvContext; PAGED_CODE(); #ifndef DBG UNREFERENCED_PARAMETER(pbContinueEnumeration); #endif // !DBG ASSERT(NULL != ptEntry); ASSERT(NULL != pvContext); ASSERT(NULL != pbContinueEnumeration); ASSERT(*pbContinueEnumeration); if ((NULL == ptPreviousEntry) || (1 != ptEntry->nEntryId - ptPreviousEntry->nEntryId)) { // This is either the first time we entered the callback, // or the current ID begins a new block. eStatus = RtlULongAdd(ptContext->nBlocks, 1, &(ptContext->nBlocks)); ASSERT(NT_SUCCESS(eStatus)); } // Add the size for the current string. eStatus = RtlSIZETAdd(ptContext->cbTotalStrings, messagetable_SizeofSerializedEntry(ptEntry), &(ptContext->cbTotalStrings)); ASSERT(NT_SUCCESS(eStatus)); }
NTSTATUS DsppLoadFontFile ( _In_ PWCHAR FontFileName ) { PBL_DEVICE_DESCRIPTOR FontDevice; NTSTATUS Status; SIZE_T NameLength, DirectoryLength, TotalLength; PWCHAR FontPath, FontDirectory; BL_LIBRARY_PARAMETERS LibraryParameters; BOOLEAN CustomDirectory, CustomDevice; /* Initialize locals */ CustomDirectory = TRUE; CustomDevice = TRUE; FontDevice = NULL; FontPath = NULL; FontDirectory = NULL; /* Check if a custom font path should be used */ Status = BlGetBootOptionString(BlpApplicationEntry.BcdData, BcdLibraryString_FontPath, &FontDirectory); if (!NT_SUCCESS(Status)) { /* Nope, use the one configured by the library */ CustomDirectory = FALSE; RtlCopyMemory(&LibraryParameters, &BlpLibraryParameters, sizeof(LibraryParameters)), FontDirectory = LibraryParameters.FontBaseDirectory; } /* Do we still not have a font directory? */ if (!FontDirectory) { /* Use the boot device and boot directory */ FontDevice = BlpBootDevice; FontDirectory = L"\\EFI\\Microsoft\\Boot\\Fonts"; CustomDevice = FALSE; } else { /* Otherwise, if we have a font directory, what device is the app on? */ Status = BlGetBootOptionDevice(BlpApplicationEntry.BcdData, BcdLibraryDevice_ApplicationDevice, &FontDevice, NULL); if (!NT_SUCCESS(Status)) { /* If we don't know the device, we can't open the path */ goto Quickie; } } /* Figure out the length of the file name, and of the directory */ NameLength = wcslen(FontFileName); DirectoryLength = wcslen(FontDirectory); /* Safely add them up*/ Status = RtlSIZETAdd(NameLength, DirectoryLength, &TotalLength); if (!NT_SUCCESS(Status)) { goto Quickie; } /* Convert to bytes */ Status = RtlSIZETMult(TotalLength, sizeof(WCHAR), &TotalLength); if (!NT_SUCCESS(Status)) { goto Quickie; } /* Add a terminating NUL */ Status = RtlSIZETAdd(TotalLength, sizeof(UNICODE_NULL), &TotalLength); if (!NT_SUCCESS(Status)) { goto Quickie; } /* Allocate the final buffer for it */ FontPath = BlMmAllocateHeap(TotalLength); if (!FontPath) { Status = STATUS_NO_MEMORY; goto Quickie; } /* Concatenate the directory with the file name */ wcscpy(FontPath, FontDirectory); wcscat(FontPath, FontFileName); /* Try to load this font */ Status = BfLoadFontFile(FontDevice, FontPath); Quickie: /* Check if we had a custom font device allocated and free it */ if ((CustomDevice) && (FontDevice)) { BlMmFreeHeap(FontDevice); } /* Check if we had a custom font directory allocated and free it */ if ((FontDirectory) && (CustomDirectory)) { BlMmFreeHeap(FontDirectory); } /* Check if we had allocated a font path and free it */ if (FontPath) { BlMmFreeHeap(FontPath); } /* Return back */ return Status; }