diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-31 16:28:11 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-31 16:28:11 +0100 |
| commit | 91a554f36af763394835f29ecdefdf2d6448a6c3 (patch) | |
| tree | 8bf392cd3b14842ea3ede17521d0efba3aaae218 | |
| parent | 0269e7f53f44d8e62ec35280d4adde7aa3ef1c6c (diff) | |
HEL: Adding BFileReader implementation.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
| -rw-r--r-- | Private/NewBoot/BootKit/BootKit.hxx | 10 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/BootKit.cxx | 41 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx | 6 | ||||
| -rw-r--r-- | Private/NewBoot/Source/HEL/AMD64/Platform.cxx | 4 |
4 files changed, 52 insertions, 9 deletions
diff --git a/Private/NewBoot/BootKit/BootKit.hxx b/Private/NewBoot/BootKit/BootKit.hxx index 6f0ee927..54f1d5d9 100644 --- a/Private/NewBoot/BootKit/BootKit.hxx +++ b/Private/NewBoot/BootKit/BootKit.hxx @@ -47,8 +47,9 @@ class BTextWriter final { BTextWriter(const BTextWriter &) = default; }; -HCore::SizeT BStrLen(const char *ptr); -HCore::SizeT BSetMem(char *src, const char byte, const HCore::SizeT len); +HCore::SizeT BStrLen(const CharacterType *ptr); +HCore::SizeT BSetMem(CharacterType *src, const CharacterType byte, + const HCore::SizeT len); /** * @brief BootKit File Reader class @@ -56,7 +57,7 @@ HCore::SizeT BSetMem(char *src, const char byte, const HCore::SizeT len); */ class BFileReader final { public: - explicit BFileReader(const char *path); + explicit BFileReader(const CharacterType *path); ~BFileReader() = default; HCore::VoidPtr ReadAll(); @@ -64,6 +65,9 @@ class BFileReader final { public: BFileReader &operator=(const BFileReader &) = default; BFileReader(const BFileReader &) = default; + + private: + CharacterType mPath[255]; }; /***********************************************************************************/ diff --git a/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx b/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx index e0dd5172..d5b4ee9e 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootKit.cxx @@ -10,12 +10,14 @@ #include <BootKit/BootKit.hxx> #include <EFIKit/EFILib.hxx> +#include "NewKit/Defines.hpp" + /// bugs 0 -HCore::SizeT BStrLen(const char *ptr) { - long long int cnt = 0; +HCore::SizeT BStrLen(const CharacterType *ptr) { + HCore::SizeT cnt = 0; - while (*ptr != 0) { + while (*ptr != (CharacterType)0) { ++ptr; ++cnt; } @@ -23,7 +25,12 @@ HCore::SizeT BStrLen(const char *ptr) { return cnt; } -HCore::SizeT BSetMem(char *src, const char byte, const HCore::SizeT len) { +/** + @biref set memory +*/ + +HCore::SizeT BSetMem(CharacterType *src, const CharacterType byte, + const HCore::SizeT len) { HCore::SizeT cnt = 0UL; while (*src != 0) { @@ -60,3 +67,29 @@ BTextWriter &BTextWriter::WriteCharacter(CharacterType c) { return *this; } + +/*** + @brief File Reader constructor. +*/ +BFileReader::BFileReader(const CharacterType *path) { + if (path != nullptr) { + SizeT index = 0UL; + for (; path[index] != L'0'; ++index) { + mPath[index] = path[index]; + } + + mPath[index] = 0; + } +} + +/** +@brief this reads all of the buffer. +*/ +HCore::VoidPtr BFileReader::ReadAll() { + BTextWriter writer; + writer.WriteString(L"*** PE/COFF: Reading ") + .WriteString(mPath) + .WriteString(L" *** \r\n"); + + return nullptr; +} diff --git a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx b/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx index 7fd55ec1..3e96ff14 100644 --- a/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/Entrypoint.cxx @@ -27,9 +27,11 @@ EFI_EXTERN_C int EfiMain(EfiHandlePtr ImageHandle, UInt64 mapKey = 0; - // TODO: Jump Code + BFileReader reader(L"\\MAHROUSS\\Root\\System\\HCoreKrnl.efi\0"); + auto blob = reader.ReadAll(); - KeRuntimeStop(L"HCoreLdr", L"Couldn't find HCoreKrnl.exe! Aborting..."); + if (!blob) + KeRuntimeStop(L"HCoreLdr", L"Couldn't find HCoreKrnl.exe! Aborting..."); EFI::ExitBootServices(SystemTable, mapKey, ImageHandle); EFI::Stop(); diff --git a/Private/NewBoot/Source/HEL/AMD64/Platform.cxx b/Private/NewBoot/Source/HEL/AMD64/Platform.cxx index 9b26f517..dbd2b900 100644 --- a/Private/NewBoot/Source/HEL/AMD64/Platform.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/Platform.cxx @@ -16,6 +16,8 @@ #include <BootKit/Platform.hxx> +#include "EFIKit/EFILib.hxx" + extern "C" void rt_halt() { asm volatile("hlt"); } extern "C" void rt_cli() { asm volatile("cli"); } @@ -25,3 +27,5 @@ extern "C" void rt_sti() { asm volatile("sti"); } extern "C" void rt_cld() { asm volatile("cld"); } extern "C" void rt_std() { asm volatile("std"); } + +extern "C" void ___chkstk_ms(void) { EFI::Stop(); } |
