/** @file
Logo DXE Driver, install Edkii Platform Logo protocol.
Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/ShellCEntryLib.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/HiiImageEx.h>
#include <Protocol/PlatformLogo.h>
#include <Protocol/HiiPackageList.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/ShellLib.h>
#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
{ \
0x9042a9de, 0x23dc, 0x4a38, {0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a } \
}
static EFI_GUID GraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
//DO NOT REMOVE IMAGE_TOKEN (IMG_LOGO)
/**
Entrypoint of this module.
This function is the entrypoint of this module. It installs the Edkii
Platform Logo protocol.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
EFIAPI
UefiMain (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
EFI_HII_IMAGE_PACKAGE_HDR *ImageHeader;
UINT8 *ImageData;
UINTN FileSize;
EFI_FILE_HANDLE FileHandle;
//Step1. Get Package List Header Address
//
// Retrieve HII package list from ImageHandle
//
Status = gBS->OpenProtocol (
ImageHandle,
&gEfiHiiPackageListProtocolGuid,
(VOID **) &PackageListHeader,
ImageHandle,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
Print(L"HII Image Package with logo not found in PE/COFF resource section\n");
return Status;
}
Print(L"PackageList :\nGUID=[%g] Length=[%X]\n",
PackageListHeader->PackageListGuid,
PackageListHeader->PackageLength);
//Step2. Parser HII Image
ImageHeader=(EFI_HII_IMAGE_PACKAGE_HDR*)(PackageListHeader+1);
ImageData=(UINT8 *)(ImageHeader+1);
FileSize=ImageData[1]+(ImageData[2]<<8)+(ImageData[3]<<16)+(ImageData[4]<<24);
Print(L"Type: 0x%x Size:%d\n",ImageData[0],FileSize);
//Create a new file
Status = ShellOpenFileByName(L"dump.bin",
(SHELL_FILE_HANDLE *)&FileHandle,
EFI_FILE_MODE_READ |
EFI_FILE_MODE_WRITE|
EFI_FILE_MODE_CREATE,
0);
if(Status != RETURN_SUCCESS) {
Print(L"CreatFile failed [%r]!\n",Status);
return EFI_SUCCESS;
}
Status = ShellWriteFile(FileHandle,
&FileSize,
&ImageData[5]);
//Close the source file
ShellCloseFile(&FileHandle);
Print(L"Dump.bin is generated!\n");
return Status;
}
typedef WINBASEAPI BOOL (WINAPI *ImmDisableIMEProc) (DWORD unnamedParam1);
typedef WINBASEAPI HIMC (WINAPI *ImmAssociateContextProc) (HWND unnamedParam1, HIMC unnamedParam2);
/**
This thread simulates the end of WinMain () application. Each Window needs
to process its events. The messages are dispatched to
WinNtGopThreadWindowProc ().
Be very careful since WinNtGopThreadWinMain () and WinNtGopThreadWindowProc ()
are running in a separate thread. We have to do this to process the events.
@param lpParameter Handle of window to manage.
@return if a WM_QUIT message is returned exit.
**/
DWORD
WINAPI
WinNtGopThreadWinMain (
LPVOID lpParameter
)
{
MSG Message;
GRAPHICS_PRIVATE_DATA *Private;
RECT Rect;
//LABZ_Debug_Start
HMODULE Module;
ImmDisableIMEProc ImmDisable;
Module = LoadLibraryEx (L"imm32.dll", NULL, DONT_RESOLVE_DLL_REFERENCES);
ImmDisable = (ImmDisableIMEProc)GetProcAddress(Module, "ImmDisableIME");
if (ImmDisable)
ImmDisable(GetCurrentThreadId ());
//LABZ_Debug_End
Private = (GRAPHICS_PRIVATE_DATA *)lpParameter;
ASSERT (NULL != Private);