summaryrefslogtreecommitdiffhomepage
path: root/Kernel/KernelKit/MSDOS.hxx
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-04 23:53:20 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-07-04 23:53:56 +0200
commit175296c1e85d2747fb4b1063199e933978320231 (patch)
tree161659f9af65a0c37802630209ec2654cfec1659 /Kernel/KernelKit/MSDOS.hxx
parent16c2e132b39836a3e312f3bda7ee0e6de60d6dd9 (diff)
MHR-36: Running run_format.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/KernelKit/MSDOS.hxx')
-rw-r--r--Kernel/KernelKit/MSDOS.hxx70
1 files changed, 70 insertions, 0 deletions
diff --git a/Kernel/KernelKit/MSDOS.hxx b/Kernel/KernelKit/MSDOS.hxx
new file mode 100644
index 00000000..7b0c2a2f
--- /dev/null
+++ b/Kernel/KernelKit/MSDOS.hxx
@@ -0,0 +1,70 @@
+/* -------------------------------------------
+
+ Copyright Zeta Electronics Corporation
+
+ File: MSDOS.hpp
+ Purpose: MS-DOS header for Kernel.
+
+ 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 Kernel::UInt32 DosWord;
+typedef Kernel::Long DosLong;
+
+typedef struct _DosHeader
+{
+ Kernel::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 Kernel
+{
+ /// @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 Kernel
+
+#endif /* ifndef __MSDOS_EXEC__ */