diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:02:43 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-24 03:02:43 +0100 |
| commit | 83d870e58457a1d335a1d9b9966a6a1887cc297b (patch) | |
| tree | 72888f88c7728c82f3f6df1f4f70591de15eab36 /dev/kernel/src/IPEFDylibObject.cc | |
| parent | ab37adbacf0f33845804c788b39680cd754752a8 (diff) | |
feat! breaking changes on kernel sources.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/src/IPEFDylibObject.cc')
| -rw-r--r-- | dev/kernel/src/IPEFDylibObject.cc | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/dev/kernel/src/IPEFDylibObject.cc b/dev/kernel/src/IPEFDylibObject.cc deleted file mode 100644 index 4ba9278d..00000000 --- a/dev/kernel/src/IPEFDylibObject.cc +++ /dev/null @@ -1,109 +0,0 @@ -/* - * ======================================================== - * - * NeKernel - * Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - * - * ======================================================== - */ - -#include <KernelKit/DebugOutput.h> -#include <KernelKit/IPEFDylibObject.h> -#include <KernelKit/PEF.h> -#include <KernelKit/ProcessScheduler.h> -#include <KernelKit/ThreadLocalStorage.h> -#include <NeKit/Defines.h> - -/* ======================================== - - Revision History: - - 01/02/24: Reworked dll ABI, expect a rtl_init_dylib_pef and - rtl_fini_dylib_pef (amlel) - - 15/02/24: Breaking changes, changed the name of the - routines. (amlel) - - 07/28/24: Replace rt_library_free with rtl_fini_dylib_pef - - 10/8/24: FIX: Fix log comment. - - ======================================== */ - -using namespace Kernel; - -/***********************************************************************************/ -/// @file IPEFDylibObject.cc -/// @brief PEF's Dylib runtime. -///! @author Amlal El Mahrouss (amlal@nekernel.org) -/***********************************************************************************/ - -/***********************************************************************************/ -/** @brief Library initializer. */ -/***********************************************************************************/ - -EXTERN_C IDylibRef rtl_init_dylib_pef(USER_PROCESS& process) { - IDylibRef dll_obj = tls_new_class<IPEFDylibObject>(); - - if (!dll_obj) { - process.Crash(); - return nullptr; - } - - dll_obj->Mount(new IPEFDylibObject::DylibTraits()); - - if (!dll_obj->Get()) { - tls_delete_class(dll_obj); - dll_obj = nullptr; - - process.Crash(); - - return nullptr; - } - - dll_obj->Get()->ImageObject = process.Image.LeakBlob().Leak().Leak(); - - if (!dll_obj->Get()->ImageObject) { - delete dll_obj->Get(); - - tls_delete_class(dll_obj); - dll_obj = nullptr; - - process.Crash(); - - return nullptr; - } - - dll_obj->Get()->ImageEntrypointOffset = - dll_obj->Load<VoidPtr>(kPefStart, rt_string_len(kPefStart, 0), kPefCode); - - return dll_obj; -} - -/***********************************************************************************/ -/** @brief Frees the dll_obj. */ -/** @note Please check if the dll_obj got freed! */ -/** @param dll_obj The dll_obj to free. */ -/** @param successful Reports if successful or not. */ -/***********************************************************************************/ - -EXTERN_C Void rtl_fini_dylib_pef(USER_PROCESS& process, IDylibRef dll_obj, BOOL* successful) { - MUST_PASS(successful); - - if (!successful) { - return; - } - - // sanity check (will also trigger a bug check if this fails) - if (dll_obj == nullptr) { - *successful = false; - process.Crash(); - } - - delete dll_obj->Get(); - delete dll_obj; - - dll_obj = nullptr; - - *successful = true; -} |
