From e0024d9ea688ee91a77abc0e28c5ea24b13ca67d Mon Sep 17 00:00:00 2001 From: Amlal Date: Mon, 28 Oct 2024 07:01:58 +0100 Subject: IMP: Refactor whole source code to make it even. - That is because previously the source was both in lowercase and lettercase. Signed-off-by: Amlal --- dev/ZKAKit/src/IPEFDLLObject.cc | 102 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 dev/ZKAKit/src/IPEFDLLObject.cc (limited to 'dev/ZKAKit/src/IPEFDLLObject.cc') diff --git a/dev/ZKAKit/src/IPEFDLLObject.cc b/dev/ZKAKit/src/IPEFDLLObject.cc new file mode 100644 index 00000000..0f0ac483 --- /dev/null +++ b/dev/ZKAKit/src/IPEFDLLObject.cc @@ -0,0 +1,102 @@ +/* + * ======================================================== + * + * minoskrnl + * Copyright ZKA Web Services Co., all rights reserved. + * + * ======================================================== + */ + +#include +#include +#include +#include +#include +#include + +/* ------------------------------------------- + + Revision History: + + 01/02/24: Reworked dll ABI, expect a rtl_init_dll and + rtl_fini_dll (amlel) 15/02/24: Breaking changes, changed the name of the + routines. (amlel) + + 07/28/24: Replace rt_library_free with rtl_fini_dll + + 10/8/24: FIX: Fix log comment. + + ------------------------------------------- */ + +using namespace Kernel; + +/***********************************************************************************/ +/// @file PEFSharedObjectRT.cc +/// @brief PEF's shared object runtime. +/***********************************************************************************/ + +/***********************************************************************************/ +/** @brief Library initializer. */ +/***********************************************************************************/ + +EXTERN_C IDLL rtl_init_dll(UserProcess* header) +{ + IDLL dll_obj = tls_new_class(); + + if (!dll_obj) + { + header->Crash(); + + return nullptr; + } + + dll_obj->Mount(tls_new_class()); + + if (!dll_obj->Get()) + { + header->Crash(); + + return nullptr; + } + + dll_obj->Get()->fImageObject = + header->Image; + + if (!dll_obj->Get()->fImageObject) + { + header->Crash(); + + return nullptr; + } + + dll_obj->Get()->fImageEntrypointOffset = + dll_obj->Load(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_dll(UserProcess* header, IDLL dll_obj, Bool* successful) +{ + MUST_PASS(successful); + + // sanity check (will also trigger a bug check if this fails) + if (dll_obj == nullptr) + { + *successful = false; + header->Crash(); + } + + delete dll_obj->Get(); + delete dll_obj; + + dll_obj = nullptr; + + *successful = true; +} -- cgit v1.2.3