summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/Entrypoint.cxx6
-rw-r--r--Private/NewBoot/Source/FileReader.cxx21
-rw-r--r--Private/NewBoot/Source/makefile2
3 files changed, 21 insertions, 8 deletions
diff --git a/Private/NewBoot/Source/Entrypoint.cxx b/Private/NewBoot/Source/Entrypoint.cxx
index 2b1e5c35..7026da4d 100644
--- a/Private/NewBoot/Source/Entrypoint.cxx
+++ b/Private/NewBoot/Source/Entrypoint.cxx
@@ -46,9 +46,11 @@ EFI_EXTERN_C Int EfiMain(EfiHandlePtr ImageHandle,
UInt64 mapKey = 0;
- BFileReader img(L"\\EFI\\BOOT\\HCoreKrnl.exe");
+ BFileReader img(L"\\EFI\\BOOT\\HCOREKRNL.EXE");
- PEImagePtr blob = (PEImagePtr)img.Fetch(ImageHandle);
+ SizeT imageSz = 0;
+
+ PEImagePtr blob = (PEImagePtr)img.Fetch(ImageHandle, imageSz);
if (!blob)
EFI::RaiseHardError(L"HCoreLdr_NoSuchKernel",
diff --git a/Private/NewBoot/Source/FileReader.cxx b/Private/NewBoot/Source/FileReader.cxx
index 7bcccc10..8602114f 100644
--- a/Private/NewBoot/Source/FileReader.cxx
+++ b/Private/NewBoot/Source/FileReader.cxx
@@ -50,7 +50,7 @@ BFileReader::~BFileReader() {
@brief this reads all of the buffer.
@param ImageHandle used internally.
*/
-HCore::VoidPtr BFileReader::Fetch(EfiHandlePtr ImageHandle) {
+HCore::VoidPtr BFileReader::Fetch(EfiHandlePtr ImageHandle, SizeT& imageSz) {
mWriter.WriteString(L"HCoreLdr: Fetch-File: ")
.WriteString(mPath)
.WriteString(L"\r\n");
@@ -100,6 +100,13 @@ HCore::VoidPtr BFileReader::Fetch(EfiHandlePtr ImageHandle) {
return nullptr;
}
+ if (kernelFile->Revision < EFI_FILE_PROTOCOL_REVISION2) {
+ mWriter.WriteString(L"HCoreLdr: Fetch-Protocol: Invalid-Revision: ")
+ .WriteString(mPath)
+ .WriteString(L"\r\n");
+ return nullptr;
+ }
+
/// File FAT info.
UInt32 szInfo = sizeof(EfiFileInfo);
@@ -139,6 +146,7 @@ HCore::VoidPtr BFileReader::Fetch(EfiHandlePtr ImageHandle) {
}
*sz = info.FileSize;
+ imageSz = *sz;
if (BS->AllocatePool(EfiLoaderData, *sz, (VoidPtr*)&blob) != kEfiOk) {
mWriter
@@ -155,14 +163,17 @@ HCore::VoidPtr BFileReader::Fetch(EfiHandlePtr ImageHandle) {
BSetMem((CharacterType*)blob, 0, *sz);
mWriter.WriteString(L"HCoreLdr: Fetch-File: In-Progress...")
+ .WriteString(info.FileName)
.WriteString(L"\r\n");
- kernelFile->Read(kernelFile, sz, blob);
-
- mWriter.WriteString(L"HCoreLdr: Fetch-File: OK").WriteString(L"\r\n");
-
+ auto resultEfiRead = kernelFile->Read(kernelFile, sz, blob);
kernelFile->Close(kernelFile);
+ if (resultEfiRead == kEfiOk)
+ mWriter.WriteString(L"HCoreLdr: Fetch-File: OK").WriteString(L"\r\n");
+ else
+ return nullptr;
+
this->mCached = true;
this->mErrorCode = kOperationOkay;
diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile
index 3deef8f4..05d6a9ab 100644
--- a/Private/NewBoot/Source/makefile
+++ b/Private/NewBoot/Source/makefile
@@ -19,7 +19,7 @@ bootloader-amd64:
$(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx *.cxx
$(LD_GNU) *.o HEL/AMD64/*.obj -e efi_main -filealign:16 -shared --subsystem=10 -ffreestanding -o HCoreLdr.exe
cp HCoreLdr.exe CDROM/EFI/BOOT/BOOTX64.EFI
- cp ../../HCoreKrnl.exe CDROM/EFI/BOOT/HCoreKrnl.exe
+ cp ../../HCoreKrnl.exe CDROM/EFI/BOOT/HCOREKRNL.EXE
.PHONY: make-disk
make-disk: