summaryrefslogtreecommitdiffhomepage
path: root/Private/Source/CodeManager.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Private/Source/CodeManager.cxx')
-rw-r--r--Private/Source/CodeManager.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/Private/Source/CodeManager.cxx b/Private/Source/CodeManager.cxx
new file mode 100644
index 00000000..db2a7017
--- /dev/null
+++ b/Private/Source/CodeManager.cxx
@@ -0,0 +1,26 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <NewKit/Utils.hpp>
+#include <KernelKit/CodeManager.hpp>
+#include <KernelKit/ProcessScheduler.hpp>
+
+using namespace NewOS;
+
+/// @brief Executes a new process from a function. kernel code only.
+/// @param main the start of the process.
+/// @return
+bool execute_from_image(MainKind main, const char* processName) noexcept {
+ if (!main) return false;
+
+ ProcessHeader proc((VoidPtr)main);
+ proc.Kind = ProcessHeader::kDriverKind;
+ rt_copy_memory((VoidPtr)processName, proc.Name, rt_string_len(proc.Name));
+
+ Ref<ProcessHeader> refProc = proc;
+
+ return ProcessScheduler::Shared().Leak().Add(refProc);
+} \ No newline at end of file