建立Test.inf,輸入以下的內容
[Defines] INF_VERSION = 0x00010005 BASE_NAME = UefiTestProtocol FILE_GUID = 7406e836-0fda-4afd-b587-0b07f367d1b1 MODULE_TYPE = UEFI_APPLICATION VERSION_STRING = 0.1 ENTRY_POINT = ShellCEntryLib [Sources] Test.c [Packages] MyPkg/MyPkg.dec MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec [LibraryClasses] LibC IoLib UefiLib [Protocols] gEfiDXETemplateProtocolGuid #需要使用所以要設定
再建立Test.c
,輸入以下的內容
#include "UefiLoadProtocol.h" #include <Library/BaseMemoryLib.h> EFI_DXE_TEMPLATE_PROTOCOL *g_Func; EFI_STATUS Initial() { EFI_STATUS Status = EFI_SUCCESS; Status = gBS->LocateProtocol(&gEfiDXETemplateProtocolGuid, NULL, (VOID**)&g_Func); if (EFI_ERROR (Status)) { Print(L"ERROR : \"gEfiDXETemplateProtocolGuid\" protocol is not exist.\n"); return Status; } return Status; } int main ( int argc, char* argv[] ) { EFI_STATUS Status = EFI_SUCCESS; CHAR16 Version[32]; Status = Initial(); if (EFI_ERROR (Status)) return Status; ZeroMem(Version, sizeof(Version)); Status = g_Func->Version(g_Func, Version); if (EFI_ERROR (Status)) return Status; Print(L"%s\n", Version); return Status; }
沒有留言:
張貼留言