diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-26 04:07:14 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-26 04:16:24 +0200 |
| commit | ff94ce367f7f23e3a78f157f9420c480a4d7f9aa (patch) | |
| tree | fc87ecd1ccf3de317db4214fe6460e324a5e76e4 /dev/ZKA/Sources/PEFDLLInterface.cxx | |
| parent | b98a81f4f26b4da98f2ac760763af656f95f392b (diff) | |
[IMP] DLLInterface class and also reworked SCI's API.
[IMP] Handover now gives the kernel image, for the OS.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/Sources/PEFDLLInterface.cxx')
| -rw-r--r-- | dev/ZKA/Sources/PEFDLLInterface.cxx | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/dev/ZKA/Sources/PEFDLLInterface.cxx b/dev/ZKA/Sources/PEFDLLInterface.cxx new file mode 100644 index 00000000..0ca6b85e --- /dev/null +++ b/dev/ZKA/Sources/PEFDLLInterface.cxx @@ -0,0 +1,100 @@ +/* + * ======================================================== + * + * newoskrnl + * Copyright ZKA Technologies., all rights reserved. + * + * ======================================================== + */ + +#include <KernelKit/DebugOutput.hxx> +#include <KernelKit/PEF.hxx> +#include <KernelKit/PEFDLLInterface.hxx> +#include <KernelKit/ProcessScheduler.hxx> +#include <KernelKit/ThreadLocalStorage.hxx> +#include <NewKit/Defines.hxx> + +/* ------------------------------------------- + + Revision History: + + 01/02/24: Rework shared sharedObj ABI, except a rtl_init_shared_object and + rtl_fini_shared_object (amlel) 15/02/24: Breaking changes, changed the name of the + routines. (amlel) + + 07/28/24: Replace rt_library_free with rtl_fini_shared_object + + ------------------------------------------- */ + +using namespace Kernel; + +/***********************************************************************************/ +/// @file PEFSharedObjectRT.cxx +/// @brief PEF's shared object runtime. +/***********************************************************************************/ + +/***********************************************************************************/ +/** @brief Library initializer. */ +/***********************************************************************************/ + +EXTERN_C DLLInterfacePtr rtl_init_shared_object(PROCESS_HEADER_BLOCK* header) +{ + DLLInterfacePtr sharedObj = tls_new_class<PEFDLLInterface>(); + + if (!sharedObj) + { + header->Crash(); + + return nullptr; + } + + sharedObj->Mount(tls_new_class<PEFDLLInterface::DLL_TRAITS>()); + + if (!sharedObj->Get()) + { + header->Crash(); + + return nullptr; + } + + sharedObj->Get()->fImageObject = + header->Image; + + if (!sharedObj->Get()->fImageObject) + { + header->Crash(); + + return nullptr; + } + + sharedObj->Get()->fImageEntrypointOffset = + sharedObj->Load<VoidPtr>(kPefStart, rt_string_len(kPefStart, 0), kPefCode); + + return sharedObj; +} + +/***********************************************************************************/ +/** @brief Frees the sharedObj. */ +/** @note Please check if the lib got freed! */ +/** @param lib The sharedObj to free. */ +/** @param successful Reports if successful or not. */ +/***********************************************************************************/ + +EXTERN_C Void rtl_fini_shared_object(PROCESS_HEADER_BLOCK* header, DLLInterfacePtr lib, Bool* successful) +{ + MUST_PASS(successful); + + // sanity check (will also trigger a bug check if this fails) + if (lib == nullptr) + { + *successful = false; + header->Crash(); + } + + delete lib->Get(); + delete lib; + + lib = nullptr; + + *successful = true; +} |
