diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-08 12:32:41 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-08 12:32:41 +0200 |
| commit | 09dd11ddf800898c00ecb04a65fb5cd10fb481fa (patch) | |
| tree | eda0b4e23d6a71da7de3a78f0bb76ec3201dd2f9 /NewKernel/KernelKit/MSDOS.hpp | |
| parent | ca83108fd138cc0398f900e6a6c0a53ad51aee31 (diff) | |
MHR-23: :boom: changes, reworked project tree.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'NewKernel/KernelKit/MSDOS.hpp')
| -rw-r--r-- | NewKernel/KernelKit/MSDOS.hpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/NewKernel/KernelKit/MSDOS.hpp b/NewKernel/KernelKit/MSDOS.hpp new file mode 100644 index 00000000..41e8340f --- /dev/null +++ b/NewKernel/KernelKit/MSDOS.hpp @@ -0,0 +1,68 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: MSDOS.hpp + Purpose: MS-DOS header for NewOS. + + Revision History: + + 30/01/24: Added file (amlel) + +------------------------------------------- */ + +#ifndef __MSDOS_EXEC__ +#define __MSDOS_EXEC__ + +#include <KernelKit/PE.hxx> +#include <NewKit/Defines.hpp> + +// 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__ */ |
