From 6855439146cc1e5f6cc91bcbcc08d39b3a22cd1f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Mar 2021 10:00:43 +0800 Subject: [PATCH] Initial Commit Upload Main Code --- .gitattributes | 5 + .gitignore | 56 +++++++++ LICENSE | 21 ++++ README.md | 22 ++++ build/build_prep.bat | 22 ++++ build/cleanup.bat | 13 ++ build/compchk_uefix64.bat | 24 ++++ build/compfre_uefix64.bat | 24 ++++ src/efimain.c | 257 ++++++++++++++++++++++++++++++++++++++ src/efimain.h | 63 ++++++++++ 10 files changed, 507 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 build/build_prep.bat create mode 100644 build/cleanup.bat create mode 100644 build/compchk_uefix64.bat create mode 100644 build/compfre_uefix64.bat create mode 100644 src/efimain.c create mode 100644 src/efimain.h diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6fe2030 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +# Auto detect text files and perform LF normalization +* text=auto + +*.c linguist-language=C +*.h linguist-language=C diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1bf6c08 --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex +*.efi + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# Miscellaneous +*.cod \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8e989b1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 unknown + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4b9d684 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# UefiDiskAccess +Simple Demo of Accessing Disks with Block I/O Protocol + +## Introduction +This project is a simple demo of accessing disks using Block I/O Protocol in UEFI Environment. + +## Requirement +To run this project, a working computer with UEFI firmware is required. + +## Build +If it is your first time to build this project, you should run `build_prep.bat` to prepare for compilation.
+The required compiler for this project is Win64 LLVM. You may download it from [GitHub](https://github.com/llvm/llvm-project/releases).
+The required library for this project is TianoCore EDK II. You may download it from [GitHub](https://github.com/tianocore/edk2/releases).
+You are required to pre-compile the EDK II library. The method to compile is unofficial. You may use the script from [EDK II Library](https://github.com/MickeyMeowMeowHouse/EDK-II-Library) to build EDK II library. For detailed steps to pre-compile, consult that repository to proceed. + +## Test +Setup a USB flash stick with GUID Partition Table (GPT). Construct a partition and format it into FAT32 file system.
+Copy the compiled `bootx64.efi` to `\EFI\BOOT\bootx64.efi` in your flash stick.
+Enter your firmware settings. Set the device option prior to the operating system. Disable Secure Boot unless you can sign the executable. + +## License +This repository is under the MIT license. \ No newline at end of file diff --git a/build/build_prep.bat b/build/build_prep.bat new file mode 100644 index 0000000..ff3ff83 --- /dev/null +++ b/build/build_prep.bat @@ -0,0 +1,22 @@ +@echo off + +title Project: UefiDiskAccess, Preparation, UEFI (AMD64 Architecture) +echo Project: UefiDiskAccess +echo Platform: Unified Extensible Firmware Interface +echo Preset: Directory Build +echo Powered by zero.tangptr@gmail.com +pause. + +echo Starting Compilation Preparations +mkdir ..\bin + +echo Making Directories for UefiDiskAccess Checked Build, 64-Bit UEFI +mkdir ..\bin\compchk_uefix64 +mkdir ..\bin\compchk_uefix64\Intermediate + +echo Making Directories for UefiDiskAccess Free Build, 64-Bit UEFI +mkdir ..\bin\compfre_uefix64 +mkdir ..\bin\compfre_uefix64\Intermediate + +echo Preparation Completed! +pause. \ No newline at end of file diff --git a/build/cleanup.bat b/build/cleanup.bat new file mode 100644 index 0000000..05a248f --- /dev/null +++ b/build/cleanup.bat @@ -0,0 +1,13 @@ +@echo off + +title Project: UefiDiskAccess, Cleanup, UEFI (AMD64 Architecture) +echo Project: UefiDiskAccess +echo Platform: Unified Extensible Firmware Interface +echo Preset: Cleanup +echo Powered by zero.tangptr@gmail.com + +del ..\bin\compchk_uefix64 /q /s +del ..\bin\compfre_uefix64 /q /s + +echo Completed! +pause. \ No newline at end of file diff --git a/build/compchk_uefix64.bat b/build/compchk_uefix64.bat new file mode 100644 index 0000000..8ee0122 --- /dev/null +++ b/build/compchk_uefix64.bat @@ -0,0 +1,24 @@ +@echo off +set edkpath=C:\UefiDKII +set mdepath=C:\UefiDKII\MdePkg +set libpath=C:\UefiDKII\Bin\MdePkg +set binpath=..\bin\compchk_uefix64 +set objpath=..\bin\compchk_uefix64\Intermediate + +title Compiling UefiDiskAccess, Checked Build, UEFI (AMD64 Architecture) +echo Project: UefiDiskAccess +echo Platform: Unified Extensible Firmware Interface +echo Preset: Debug/Checked Build +echo Powered by zero.tangptr@gmail.com +clang-cl --version +lld-link --version +pause + +echo ============Start Compiling============ +clang-cl ..\src\efimain.c /I"%mdepath%\Include" /I"%mdepath%\Include\X64" /D"_EFI_BOOT" /Zi /W3 /WX /Ot /Fa"%objpath%\efimain.cod" /Fo"%objpath%\efimain.obj" /GS- /Gr /TC /c -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types + +echo ============Start Linking============ +lld-link "%objpath%\efimain.obj" /NODEFAULTLIB /LIBPATH:"%libpath%\compchk_uefix64" "BaseLib.lib" "BaseDebugPrintErrorLevelLib.lib" "BaseMemoryLib.lib" "BasePrintLib.lib" "UefiLib.lib" "UefiDebugLibConOut.lib" "UefiMemoryAllocationLib.lib" "UefiDevicePathLib.Lib" "UefiBootServicesTableLib.Lib" "UefiRuntimeServicesTableLib.Lib" /OUT:"%binpath%\bootx64.efi" /SUBSYSTEM:EFI_APPLICATION /ENTRY:"EfiMain" /DEBUG /PDB:"%objpath%\bootx64.pdb" /Machine:X64 + +echo Completed! +pause. \ No newline at end of file diff --git a/build/compfre_uefix64.bat b/build/compfre_uefix64.bat new file mode 100644 index 0000000..6919a02 --- /dev/null +++ b/build/compfre_uefix64.bat @@ -0,0 +1,24 @@ +@echo off +set edkpath=C:\UefiDKII +set mdepath=C:\UefiDKII\MdePkg +set libpath=C:\UefiDKII\Bin\MdePkg +set binpath=..\bin\compfre_uefix64 +set objpath=..\bin\compfre_uefix64\Intermediate + +title Compiling UefiDiskAccess, Free Build, UEFI (AMD64 Architecture) +echo Project: UefiDiskAccess +echo Platform: Unified Extensible Firmware Interface +echo Preset: Release/Free Build +echo Powered by zero.tangptr@gmail.com +clang-cl --version +lld-link --version +pause + +echo ============Start Compiling============ +clang-cl ..\src\efimain.c /I"%mdepath%\Include" /I"%mdepath%\Include\X64" /D"_EFI_BOOT" /Zi /W3 /WX /O2 /Fa"%objpath%\efimain.cod" /Fo"%objpath%\efimain.obj" /GS- /Gr /TC /c -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types + +echo ============Start Linking============ +lld-link "%objpath%\efimain.obj" /NODEFAULTLIB /LIBPATH:"%libpath%\compfre_uefix64" "BaseLib.lib" "BaseDebugPrintErrorLevelLib.lib" "BaseMemoryLib.lib" "BasePrintLib.lib" "UefiLib.lib" "UefiDebugLibConOut.lib" "UefiMemoryAllocationLib.lib" "UefiDevicePathLib.Lib" "UefiBootServicesTableLib.Lib" "UefiRuntimeServicesTableLib.Lib" /OUT:"%binpath%\bootx64.efi" /OPT:REF /SUBSYSTEM:EFI_APPLICATION /ENTRY:"EfiMain" /DEBUG /PDB:"%objpath%\bootx64.pdb" /Machine:X64 + +echo Completed! +pause. \ No newline at end of file diff --git a/src/efimain.c b/src/efimain.c new file mode 100644 index 0000000..520c7e4 --- /dev/null +++ b/src/efimain.c @@ -0,0 +1,257 @@ +/* + UefiDiskAccess - Simple demo of Accessing Disk I/O + + Copyright 2021 Zero Tang. All rights reserved. + + This program is distributed in the hope that it will be useful, but + without any warranty (no matter implied warranty or merchantability + or fitness for a particular purpose, etc.). + + File Location: /src/efimain.c +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "efimain.h" + +CHAR16 BlockUntilKeyStroke(IN CHAR16 Unicode) +{ + EFI_INPUT_KEY InKey; + do + { + UINTN fi=0; + gBS->WaitForEvent(1,&StdIn->WaitForKey,&fi); + StdIn->ReadKeyStroke(StdIn,&InKey); + }while(InKey.UnicodeChar!=Unicode && Unicode); + return InKey.UnicodeChar; +} + +INTN EfiCompareGuid(EFI_GUID *Guid1,EFI_GUID *Guid2) +{ + if(Guid1->Data1>Guid2->Data1) + return 1; + else if(Guid1->Data1Data1) + return -1; + if(Guid1->Data2>Guid2->Data2) + return 1; + else if(Guid1->Data2Data2) + return -1; + if(Guid1->Data3>Guid2->Data3) + return 1; + else if(Guid1->Data3Data3) + return -1; + for(UINT8 i=0;i<8;i++) + { + if(Guid1->Data4[i]>Guid2->Data4[i]) + return 1; + else if(Guid1->Data4[i]Data4[i]) + return -1; + } + return 0; +} + +void SetConsoleModeToMaximumRows() +{ + UINTN MaxHgt=0,OptIndex; + for(UINTN i=0;iMode->MaxMode;i++) + { + UINTN Col,Row; + EFI_STATUS st=StdOut->QueryMode(StdOut,i,&Col,&Row); + if(st==EFI_SUCCESS) + { + if(Row>MaxHgt) + { + OptIndex=i; + MaxHgt=Row; + } + } + } + StdOut->SetMode(StdOut,OptIndex); + StdOut->ClearScreen(StdOut); + StdOut->SetAttribute(StdOut,EFI_BACKGROUND_BLACK|EFI_LIGHTGRAY); +} + +void DisplaySize(IN UINT64 Size,OUT CHAR16 *Buffer,IN UINTN Limit) +{ + if(Size=LimitKiB && Size>10); + else if(Size>=LimitMiB && Size>20); + else + UnicodeSPrint(Buffer,Limit,L"%u GiB",Size>>30); +} + +EFI_STATUS EnumDiskPartitions(IN EFI_BLOCK_IO_PROTOCOL *BlockIoProtocol) +{ + EFI_STATUS st=EFI_DEVICE_ERROR; + if(!BlockIoProtocol->Media->LogicalPartition) + { + MASTER_BOOT_RECORD MBRContent; + st=BlockIoProtocol->ReadBlocks(BlockIoProtocol,BlockIoProtocol->Media->MediaId,0,sizeof(MASTER_BOOT_RECORD),&MBRContent); + if(st==EFI_SUCCESS) + { + if(MBRContent.Signature!=MBR_SIGNATURE) + StdOut->OutputString(StdOut,L"Invalid MBR Signature! MBR might be corrupted!\r\n"); + for(UINT8 i=0;iOSIndicator) + { + UINT32 StartLBA=*(UINT32*)Partition->StartingLBA; + UINT32 SizeInLBA=*(UINT32*)Partition->SizeInLBA; + CHAR16 ScaledStart[32],ScaledSize[32]; + DisplaySize(__emulu(StartLBA,BlockIoProtocol->Media->BlockSize),ScaledStart,sizeof(ScaledStart)); + DisplaySize(__emulu(SizeInLBA,BlockIoProtocol->Media->BlockSize),ScaledSize,sizeof(ScaledSize)); + Print(L"MBR-Defined Partition %d: OS Type: 0x%02X Start Position: %s Partition Size: %s\n",i,Partition->OSIndicator,ScaledStart,SizeInLBA==0xFFFFFFFF?L"Over 2TiB":ScaledSize); + if(Partition->OSIndicator==PMBR_GPT_PARTITION || Partition->OSIndicator==EFI_PARTITION) + { + EFI_PARTITION_TABLE_HEADER *GptHeader=AllocatePool(BlockIoProtocol->Media->BlockSize); + if(GptHeader) + { + st=BlockIoProtocol->ReadBlocks(BlockIoProtocol,BlockIoProtocol->Media->MediaId,StartLBA,BlockIoProtocol->Media->BlockSize,GptHeader); + if(st==EFI_SUCCESS) + { + if(GptHeader->Header.Signature!=EFI_PTAB_HEADER_ID) + StdOut->OutputString(StdOut,L"Improper GPT Header Signature!"); + else + { + UINT32 PartitionEntrySize=GptHeader->SizeOfPartitionEntry*GptHeader->NumberOfPartitionEntries; + VOID* PartitionEntries=AllocatePool(PartitionEntrySize); + Print(L"Disk GUID: {%g} Partition Array LBA: %u Number of Partitions: %u\n",&GptHeader->DiskGUID,GptHeader->PartitionEntryLBA,GptHeader->NumberOfPartitionEntries); + if(PartitionEntries) + { + st=BlockIoProtocol->ReadBlocks(BlockIoProtocol,BlockIoProtocol->Media->MediaId,GptHeader->PartitionEntryLBA,PartitionEntrySize,PartitionEntries); + if(st==EFI_SUCCESS) + { + for(UINT32 j=0;jNumberOfPartitionEntries;j++) + { + EFI_PARTITION_ENTRY *PartitionEntry=(EFI_PARTITION_ENTRY*)((UINTN)PartitionEntries+j*GptHeader->SizeOfPartitionEntry); + if(EfiCompareGuid(&PartitionEntry->PartitionTypeGUID,&gEfiPartTypeUnusedGuid)) + { + DisplaySize(MultU64x32(PartitionEntry->StartingLBA,BlockIoProtocol->Media->BlockSize),ScaledStart,sizeof(ScaledStart)); + DisplaySize(MultU64x32(PartitionEntry->EndingLBA-PartitionEntry->StartingLBA+1,BlockIoProtocol->Media->BlockSize),ScaledSize,sizeof(ScaledSize)); + Print(L"GPT-Defined Partition %u: Start Position: %s Partition Size: %s\n",j,ScaledStart,ScaledSize); + Print(L"Partition Type GUID: {%g}\n",&PartitionEntry->PartitionTypeGUID); + Print(L"Unique Partition GUID: {%g}\n",&PartitionEntry->UniquePartitionGUID); + } + } + } + FreePool(PartitionEntries); + } + } + } + else + Print(L"Failed to read GPT Header! Status=0x%p\n",st); + FreePool(GptHeader); + } + } + } + } + } + } + return st; +} + +void EnumAllDiskPartitions() +{ + for(UINTN i=0;iMedia->MediaPresent && !DiskDevices[i].BlockIo->Media->LogicalPartition) + { + CHAR16 *DiskDevicePath=ConvertDevicePathToText(DiskDevices[i].DevicePath,FALSE,FALSE); + if(DiskDevicePath) + { + StdOut->OutputString(StdOut,L"=============================================================================\r\n"); + Print(L"Partition Info of Device Path: %s\n",DiskDevicePath); + FreePool(DiskDevicePath); + Print(L"Block Size: %d bytes. I/O Alignment: 0x%X. Last LBA: 0x%llX.\n",DiskDevices[i].BlockIo->Media->BlockSize,DiskDevices[i].BlockIo->Media->IoAlign,DiskDevices[i].BlockIo->Media->LastBlock); + EnumDiskPartitions(DiskDevices[i].BlockIo); + } + } + } + StdOut->OutputString(StdOut,L"=============================================================================\r\n"); +} + +EFI_STATUS InitializeDiskIoProtocol() +{ + UINTN BuffCount=0; + EFI_HANDLE *HandleBuffer=NULL; + // Locate all devices that support Disk I/O Protocol. + EFI_STATUS st=gBS->LocateHandleBuffer(ByProtocol,&gEfiBlockIoProtocolGuid,NULL,&BuffCount,&HandleBuffer); + if(st==EFI_SUCCESS) + { + DiskDevices=AllocateZeroPool(sizeof(DISK_DEVICE_OBJECT)*BuffCount); + if(DiskDevices) + { + NumberOfDiskDevices=BuffCount; + for(UINTN i=0;iHandleProtocol(HandleBuffer[i],&gEfiBlockIoProtocolGuid,&DiskDevices[i].BlockIo); + if(HandleBuffer[i]==CurrentImage->DeviceHandle) + { + CHAR16* DevPath=ConvertDevicePathToText(DiskDevices[i].DevicePath,FALSE,FALSE); + if(DevPath) + { + Print(L"Image was loaded from Disk Device: %s\r\n",DevPath); + FreePool(DevPath); + } + CurrentDiskDevice=&DiskDevices[i]; + } + } + } + else + { + st=EFI_OUT_OF_RESOURCES; + StdOut->OutputString(StdOut,L"Failed to build list of Disk Devices!\r\n"); + } + FreePool(HandleBuffer); + } + else + Print(L"Failed to locate Disk I/O handles! Status=0x%p\n",st); + return st; +} + +EFI_STATUS EFIAPI EfiInitialize(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable) +{ + UefiBootServicesTableLibConstructor(ImageHandle,SystemTable); + UefiRuntimeServicesTableLibConstructor(ImageHandle,SystemTable); + UefiLibConstructor(ImageHandle,SystemTable); + DevicePathLibConstructor(ImageHandle,SystemTable); + StdIn=SystemTable->ConIn; + StdOut=SystemTable->ConOut; + return gBS->HandleProtocol(ImageHandle,&gEfiLoadedImageProtocolGuid,&CurrentImage); +} + +EFI_STATUS EFIAPI EfiMain(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable) +{ + EFI_STATUS st=EfiInitialize(ImageHandle,SystemTable); + if(st==EFI_SUCCESS) + { + UINT16 RevHi=(UINT16)(SystemTable->Hdr.Revision>>16); + UINT16 RevLo=(UINT16)(SystemTable->Hdr.Revision&0xFFFF); + SetConsoleModeToMaximumRows(); + StdOut->OutputString(StdOut,L"UefiDiskAccess Demo - Simple Demo of Accessing Disks in UEFI\r\n"); + StdOut->OutputString(StdOut,L"Powered by zero.tangptr@gmail.com, Copyright Zero Tang, 2021, All Rights Reserved.\r\n"); + Print(L"UEFI Firmware Vendor: %s Revision: %d.%d\n",SystemTable->FirmwareVendor,RevHi,RevLo); + st=InitializeDiskIoProtocol(); + if(st==EFI_SUCCESS) + { + EnumAllDiskPartitions(); + FreePool(DiskDevices); + } + StdOut->OutputString(StdOut,L"Press Enter key to continue...\r\n"); + BlockUntilKeyStroke(L'\r'); + } + return st; +} \ No newline at end of file diff --git a/src/efimain.h b/src/efimain.h new file mode 100644 index 0000000..406973c --- /dev/null +++ b/src/efimain.h @@ -0,0 +1,63 @@ +/* + UefiDiskAccess - Simple demo of Accessing Disk I/O + + Copyright 2021 Zero Tang. All rights reserved. + + This program is distributed in the hope that it will be useful, but + without any warranty (no matter implied warranty or merchantability + or fitness for a particular purpose, etc.). + + File Location: /src/efimain.h +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define LimitKiB (1<<10) +#define LimitMiB (1<<20) +#define LimitGiB (1<<30) + +typedef struct _DISK_DEVICE_OBJECT +{ + EFI_DEVICE_PATH_PROTOCOL* DevicePath; + EFI_BLOCK_IO_PROTOCOL* BlockIo; +}DISK_DEVICE_OBJECT; + +EFI_STATUS EFIAPI UefiBootServicesTableLibConstructor(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable); +EFI_STATUS EFIAPI UefiRuntimeServicesTableLibConstructor(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable); +EFI_STATUS EFIAPI UefiLibConstructor(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable); +EFI_STATUS EFIAPI DevicePathLibConstructor(IN EFI_HANDLE ImageHandle,IN EFI_SYSTEM_TABLE *SystemTable); + +EFI_LOADED_IMAGE_PROTOCOL *CurrentImage=NULL; +EFI_SIMPLE_TEXT_INPUT_PROTOCOL *StdIn=NULL; +EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *StdOut=NULL; + +EFI_GUID gEfiSimpleFileSystemProtocolGuid=EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID; +EFI_GUID gEfiGraphicsOutputProtocolGuid=EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; +EFI_GUID gEfiUgaDrawProtocolGuid=EFI_UGA_DRAW_PROTOCOL_GUID; +EFI_GUID gEfiHiiFontProtocolGuid=EFI_HII_FONT_PROTOCOL_GUID; +EFI_GUID gEfiSimpleTextOutProtocolGuid=EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID; +EFI_GUID gEfiDevicePathProtocolGuid=EFI_DEVICE_PATH_PROTOCOL_GUID; +EFI_GUID gEfiDevicePathUtilitiesProtocolGuid=EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID; +EFI_GUID gEfiDevicePathToTextProtocolGuid=EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; +EFI_GUID gEfiDevicePathFromTextProtocolGuid=EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID; +EFI_GUID gEfiGlobalVariableGuid=EFI_GLOBAL_VARIABLE; +EFI_GUID gEfiBlockIoProtocolGuid=EFI_BLOCK_IO_PROTOCOL_GUID; +EFI_GUID gEfiPartTypeUnusedGuid=EFI_PART_TYPE_UNUSED_GUID; +EFI_GUID gEfiLoadedImageProtocolGuid=EFI_LOADED_IMAGE_PROTOCOL_GUID; + +UINTN NumberOfDiskDevices=0; +DISK_DEVICE_OBJECT *DiskDevices=NULL; +DISK_DEVICE_OBJECT *CurrentDiskDevice=NULL; + +extern EFI_BOOT_SERVICES *gBS; +extern EFI_SYSTEM_TABLE *gST; \ No newline at end of file