diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-07-11 12:35:24 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-07-11 12:35:24 +0200 |
| commit | d5cf80c085c67aed598df06e3c5dc94fdcfbde6c (patch) | |
| tree | 39bcf4e98c5e2ba5c9072a81649ac787197de5fc | |
| parent | 0402a1c2feb8e8036c56dfc51d13e63ef3133208 (diff) | |
[IMPROVEMENT] Program loader checks magic according to specs.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
| -rw-r--r-- | Boot/Sources/ProgramLoader.cxx | 21 | ||||
| -rw-r--r-- | Kernel/KernelKit/PEF.hpp | 7 |
2 files changed, 17 insertions, 11 deletions
diff --git a/Boot/Sources/ProgramLoader.cxx b/Boot/Sources/ProgramLoader.cxx index 0603fb9c..62dd8d8e 100644 --- a/Boot/Sources/ProgramLoader.cxx +++ b/Boot/Sources/ProgramLoader.cxx @@ -8,6 +8,8 @@ #include <BootKit/Vendor/Support.hxx> #include <BootKit/BootKit.hxx> +#include <KernelKit/PEF.hpp> + EXTERN_C { #include <string.h> @@ -29,17 +31,17 @@ namespace Boot return; } - if (firstBytes[0] == 'M' && - firstBytes[1] == 'Z') + if (firstBytes[0] == kMagMz0 && + firstBytes[1] == kMagMz1) { // Parse PE32+ fStartAddress = nullptr; writer.Write("newosldr: MZ executable detected.\r"); } - else if (firstBytes[0] == 'J' && - firstBytes[1] == 'o' && - firstBytes[2] == 'y' && - firstBytes[3] == '!') + else if (firstBytes[0] == kPefMagic[0] && + firstBytes[1] == kPefMagic[1] && + firstBytes[2] == kPefMagic[2] && + firstBytes[3] == kPefMagic[3]) { // Parse Non FAT PEF. fStartAddress = nullptr; @@ -52,14 +54,17 @@ namespace Boot } } + /// @note handover header has to be valid! Void ProgramLoader::Start(HEL::HandoverInformationHeader* handover) { + MUST_PASS(handover); + BTextWriter writer; - writer.Write("newosldr: running: ").Write(fBlobName).Write("\r"); + writer.Write("newosldr: Trying to run: ").Write(fBlobName).Write("\r"); if (!fStartAddress) { - writer.Write("newosldr: exec error.\r"); + writer.Write("newosldr: Exec format error.\r"); return; } diff --git a/Kernel/KernelKit/PEF.hpp b/Kernel/KernelKit/PEF.hpp index f27d8dd5..93b6bcbb 100644 --- a/Kernel/KernelKit/PEF.hpp +++ b/Kernel/KernelKit/PEF.hpp @@ -11,8 +11,8 @@ ------------------------------------------- */ -#ifndef __PEF__ -#define __PEF__ +#ifndef __INC_PEF_HPP__ +#define __INC_PEF_HPP__ #include <CompilerKit/CompilerKit.hxx> #include <KernelKit/LoaderInterface.hpp> @@ -95,6 +95,7 @@ namespace Kernel }; } // namespace Kernel +/* not mandatory, only for non fork based filesystems */ #define kPefExt ".exec" #define kPefDylibExt ".lib" #define kPefLibExt ".slib" @@ -109,4 +110,4 @@ namespace Kernel #define kPefForkKind kPefMagic #define kPefForkKindFAT kPefMagicFat -#endif /* ifndef __PEF__ */ +#endif /* ifndef __INC_PEF_HPP__ */ |
