summaryrefslogtreecommitdiffhomepage
path: root/Private/NewBoot/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-02 22:19:08 +0100
committerAmlal El Mahrouss <amlalelmahrouss@icloud.com>2024-02-02 22:19:08 +0100
commit275c162c7c270499408ee4cbdd8f24b6d0240117 (patch)
tree74e995363b2bf98659848d6e99b176a2876f28cc /Private/NewBoot/Source
parent1b7cde24b45bb9cb8335767d4e50101867d21a37 (diff)
Bootloader: Fix code that isn't supposed to be there, EFI wrapper
improvements. Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/NewBoot/Source')
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx28
-rw-r--r--Private/NewBoot/Source/HEL/AMD64/AMD64-Platform.cxx3
2 files changed, 19 insertions, 12 deletions
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx
index 8ca7737d..328e7bc9 100644
--- a/Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-BootKit.cxx
@@ -11,9 +11,6 @@
#include <EFIKit/Api.hxx>
#include <FSKit/NewFS.hxx>
-#include "EFIKit/EFI.hxx"
-#include "NewKit/Macros.hpp"
-
/// bugs 0
/////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -113,7 +110,7 @@ HCore::VoidPtr BFileReader::ReadAll(SizeT &size) {
EfiHandlePtr handleFile = nullptr;
EfiLoadFileProtocol *loadFile = nullptr;
- EfiGUID loadFileGUID = EfiGUID(EFI_LOAD_FILE2_PROTOCOL_GUID);
+ EfiGUID loadFileGUID = EfiGUID(EFI_LOAD_FILE_PROTOCOL_GUID);
BS->LocateProtocol(&loadFileGUID, nullptr, (VoidPtr *)&loadFile);
@@ -128,21 +125,30 @@ HCore::VoidPtr BFileReader::ReadAll(SizeT &size) {
BS->AllocatePool(EfiLoaderCode, sizeof(UInt32), (VoidPtr *)&bufSz);
*bufSz = KIB(324);
+ if (!bufSz) {
+ return nullptr;
+ }
+
BS->AllocatePool(EfiLoaderCode, *bufSz, &buf);
- if (!buf) return nullptr;
+ if (!buf) {
+ BS->FreePool(bufSz);
+ bufSz = nullptr;
+
+ return nullptr;
+ }
EfiFileDevicePathProtocol filePath{0};
- filePath.Proto.Length[0] = sizeof(EfiDevicePathProtocol);
- filePath.Proto.Length[1] = BStrLen(mPath);
+ filePath.Proto.Length[0] = sizeof(EfiDevicePathProtocol) + BStrLen(mPath);
+ filePath.Proto.Length[1] = 0;
filePath.Proto.Type = kEFIMediaDevicePath;
filePath.Proto.SubType = kEFIMediaDevicePath; // from all drives.
BCopyMem(filePath.Path, mPath, BStrLen(mPath));
- auto err = loadFile->LoadFile(loadFile, &filePath, false, &bufSz, &buf);
+ auto err = loadFile->LoadFile(loadFile, &filePath, true, bufSz, buf);
size = *bufSz;
@@ -158,7 +164,7 @@ HCore::VoidPtr BFileReader::ReadAll(SizeT &size) {
case 2: {
writer.WriteString(L"HCoreLdr: Error: ")
.WriteString(mPath)
- .WriteString(L", Code: Invalid-Parameter")
+ .WriteString(L", EFI-Code: Invalid-Parameter")
.WriteString(L"\r\n");
break;
@@ -166,7 +172,7 @@ HCore::VoidPtr BFileReader::ReadAll(SizeT &size) {
case 14: {
writer.WriteString(L"HCoreLdr: Error: ")
.WriteString(mPath)
- .WriteString(L" , EFI-Code: Not-Found")
+ .WriteString(L", EFI-Code: Not-Found")
.WriteString(L"\r\n");
break;
@@ -174,7 +180,7 @@ HCore::VoidPtr BFileReader::ReadAll(SizeT &size) {
default: {
writer.WriteString(L"HCoreLdr: Error: ")
.WriteString(mPath)
- .WriteString(L" , EFI-Code: Unknown-Error")
+ .WriteString(L", EFI-Code: Unknown-Error")
.WriteString(L"\r\n");
break;
diff --git a/Private/NewBoot/Source/HEL/AMD64/AMD64-Platform.cxx b/Private/NewBoot/Source/HEL/AMD64/AMD64-Platform.cxx
index 663d4bcb..20dd3125 100644
--- a/Private/NewBoot/Source/HEL/AMD64/AMD64-Platform.cxx
+++ b/Private/NewBoot/Source/HEL/AMD64/AMD64-Platform.cxx
@@ -14,6 +14,7 @@
*
*/
+#include <BootKit/BootKit.hxx>
#include <BootKit/Platform.hxx>
#include <EFIKit/Api.hxx>
@@ -27,6 +28,6 @@ extern "C" void rt_cld() { asm volatile("cld"); }
extern "C" void rt_std() { asm volatile("std"); }
-/// @brief Stack check
+/// @brief Stack Checker, leave empty.
extern "C" void ___chkstk_ms(void) {}