From af8a516fc22865abd80d6e26f1541fa3d6bebfdc Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 9 May 2024 00:42:44 +0200 Subject: MHR-23: :boom:, refactors. - Move NewBoot to /Boot, thus making Kernel directory only containing the kernel. Signed-off-by: Amlal El Mahrouss --- Kernel/KernelKit/MSDOS.hpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Kernel/KernelKit/MSDOS.hpp (limited to 'Kernel/KernelKit/MSDOS.hpp') diff --git a/Kernel/KernelKit/MSDOS.hpp b/Kernel/KernelKit/MSDOS.hpp new file mode 100644 index 00000000..8b27ca58 --- /dev/null +++ b/Kernel/KernelKit/MSDOS.hpp @@ -0,0 +1,68 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + + File: MSDOS.hpp + Purpose: MS-DOS header for NewOS. + + Revision History: + + 30/01/24: Added file (amlel) + +------------------------------------------- */ + +#ifndef __MSDOS_EXEC__ +#define __MSDOS_EXEC__ + +#include +#include + +// Last Rev +// Sat Feb 24 CET 2024 + +#define kMagMz0 'M' +#define kMagMz1 'Z' + +typedef NewOS::UInt32 DosWord; +typedef NewOS::Long DosLong; + +typedef struct _DosHeader +{ + NewOS::UInt8 eMagic[2]; + DosWord eMagLen; + DosWord ePagesCount; + DosWord eCrlc; + DosWord eCParHdr; + DosWord eMinAlloc; + DosWord eMaxAlloc; + DosWord eStackSeg; + DosWord eStackPtr; + DosWord eChksum; + DosWord eIp; + DosWord eCs; + DosWord eLfarlc; + DosWord eOvno; + DosWord eRes[4]; + DosWord eOemid; + DosWord eOeminfo; + DosWord eRes2[10]; + DosLong eLfanew; +} DosHeader, *DosHeaderPtr; + +namespace NewOS +{ + /// @brief Find the PE header inside the the blob. + inline auto rt_find_exec_header(DosHeaderPtr ptrDos) -> VoidPtr + { + if (!ptrDos) + return nullptr; + if (ptrDos->eMagic[0] != kMagMz0) + return nullptr; + if (ptrDos->eMagic[1] != kMagMz1) + return nullptr; + + return (VoidPtr)(&ptrDos->eLfanew + 1); + } +} // namespace NewOS + +#endif /* ifndef __MSDOS_EXEC__ */ -- cgit v1.2.3