From d48cbe75ef29a9c67c9d176bf58e56ea6448fb9e Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 21 Oct 2024 20:23:36 +0200 Subject: IMP: Major refactor of header and source files extensions. Signed-off-by: Amlal El Mahrouss --- dev/zka/CFKit/GUIDWizard.h | 22 ++++++++++++++++ dev/zka/CFKit/GUIDWizard.hxx | 22 ---------------- dev/zka/CFKit/GUIDWrapper.h | 58 +++++++++++++++++++++++++++++++++++++++++++ dev/zka/CFKit/GUIDWrapper.hxx | 58 ------------------------------------------- dev/zka/CFKit/LoaderUtils.h | 53 +++++++++++++++++++++++++++++++++++++++ dev/zka/CFKit/LoaderUtils.hxx | 53 --------------------------------------- dev/zka/CFKit/Property.h | 47 +++++++++++++++++++++++++++++++++++ dev/zka/CFKit/Property.hxx | 47 ----------------------------------- 8 files changed, 180 insertions(+), 180 deletions(-) create mode 100644 dev/zka/CFKit/GUIDWizard.h delete mode 100644 dev/zka/CFKit/GUIDWizard.hxx create mode 100644 dev/zka/CFKit/GUIDWrapper.h delete mode 100644 dev/zka/CFKit/GUIDWrapper.hxx create mode 100644 dev/zka/CFKit/LoaderUtils.h delete mode 100644 dev/zka/CFKit/LoaderUtils.hxx create mode 100644 dev/zka/CFKit/Property.h delete mode 100644 dev/zka/CFKit/Property.hxx (limited to 'dev/zka/CFKit') diff --git a/dev/zka/CFKit/GUIDWizard.h b/dev/zka/CFKit/GUIDWizard.h new file mode 100644 index 00000000..74dab72b --- /dev/null +++ b/dev/zka/CFKit/GUIDWizard.h @@ -0,0 +1,22 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Kernel::XRN::Version1 +{ + Ref cf_make_sequence(const ArrayList& seq); + ErrorOr> cf_try_guid_to_string(Ref& guid); +} // namespace Kernel::XRN::Version1 diff --git a/dev/zka/CFKit/GUIDWizard.hxx b/dev/zka/CFKit/GUIDWizard.hxx deleted file mode 100644 index bd390bd4..00000000 --- a/dev/zka/CFKit/GUIDWizard.hxx +++ /dev/null @@ -1,22 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Kernel::XRN::Version1 -{ - Ref cf_make_sequence(const ArrayList& seq); - ErrorOr> cf_try_guid_to_string(Ref& guid); -} // namespace Kernel::XRN::Version1 diff --git a/dev/zka/CFKit/GUIDWrapper.h b/dev/zka/CFKit/GUIDWrapper.h new file mode 100644 index 00000000..ee51e065 --- /dev/null +++ b/dev/zka/CFKit/GUIDWrapper.h @@ -0,0 +1,58 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#pragma once + +#include +#include +#include + +/* GUID for C++ Components */ + +#define kXRNNil "@{........-....-M...-N...-............}" + +// eXtensible Resource Information +namespace Kernel::XRN +{ + union GUIDSequence { + alignas(8) UShort u8[16]; + alignas(8) UShort u16[8]; + alignas(8) UInt u32[4]; + alignas(8) ULong u64[2]; + + struct + { + alignas(8) UInt fMs1; + UShort fMs2; + UShort fMs3; + UChar fMs4[8]; + }; + }; + + class GUID final + { + public: + explicit GUID() = default; + ~GUID() = default; + + public: + GUID& operator=(const GUID&) = default; + GUID(const GUID&) = default; + + public: + GUIDSequence& operator->() noexcept + { + return fUUID; + } + GUIDSequence& Leak() noexcept + { + return fUUID; + } + + private: + GUIDSequence fUUID; + }; +} // namespace Kernel::XRN diff --git a/dev/zka/CFKit/GUIDWrapper.hxx b/dev/zka/CFKit/GUIDWrapper.hxx deleted file mode 100644 index 48977a7c..00000000 --- a/dev/zka/CFKit/GUIDWrapper.hxx +++ /dev/null @@ -1,58 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#pragma once - -#include -#include -#include - -/* GUID for C++ Components */ - -#define kXRNNil "@{........-....-M...-N...-............}" - -// eXtensible Resource Information -namespace Kernel::XRN -{ - union GUIDSequence { - alignas(8) UShort u8[16]; - alignas(8) UShort u16[8]; - alignas(8) UInt u32[4]; - alignas(8) ULong u64[2]; - - struct - { - alignas(8) UInt fMs1; - UShort fMs2; - UShort fMs3; - UChar fMs4[8]; - }; - }; - - class GUID final - { - public: - explicit GUID() = default; - ~GUID() = default; - - public: - GUID& operator=(const GUID&) = default; - GUID(const GUID&) = default; - - public: - GUIDSequence& operator->() noexcept - { - return fUUID; - } - GUIDSequence& Leak() noexcept - { - return fUUID; - } - - private: - GUIDSequence fUUID; - }; -} // namespace Kernel::XRN diff --git a/dev/zka/CFKit/LoaderUtils.h b/dev/zka/CFKit/LoaderUtils.h new file mode 100644 index 00000000..4a30ec84 --- /dev/null +++ b/dev/zka/CFKit/LoaderUtils.h @@ -0,0 +1,53 @@ +#ifndef __CFKIT_LOADER_UTILS_HXX__ +#define __CFKIT_LOADER_UTILS_HXX__ + +#include +#include + +namespace Kernel +{ + /// @brief Find the PE header inside the blob. + inline auto ldr_find_exec_header(DosHeaderPtr ptrDos) -> LDR_EXEC_HEADER_PTR + { + if (!ptrDos) + return nullptr; + + if (ptrDos->eMagic[0] != kMagMz0) + return nullptr; + + if (ptrDos->eMagic[1] != kMagMz1) + return nullptr; + + return (LDR_EXEC_HEADER_PTR)(VoidPtr)(&ptrDos->eLfanew + 1); + } + + /// @brief Find the PE optional header inside the blob. + inline auto ldr_find_opt_exec_header(DosHeaderPtr ptrDos) -> LDR_OPTIONAL_HEADER_PTR + { + if (!ptrDos) + return nullptr; + + auto exec = ldr_find_exec_header(ptrDos); + + if (!exec) + return nullptr; + + return (LDR_OPTIONAL_HEADER_PTR)(VoidPtr)(&exec->mCharacteristics + 1); + } + + /// @brief Find the PE header inside the blob. + /// @note overloaded function. + inline auto ldr_find_exec_header(const Char* ptrDos) -> LDR_EXEC_HEADER_PTR + { + return ldr_find_exec_header((DosHeaderPtr)ptrDos); + } + + /// @brief Find the PE header inside the blob. + /// @note overloaded function. + inline auto ldr_find_opt_exec_header(const Char* ptrDos) -> LDR_OPTIONAL_HEADER_PTR + { + return ldr_find_opt_exec_header((DosHeaderPtr)ptrDos); + } +} // namespace Kernel + +#endif // ifndef __CFKIT_LOADER_UTILS_HXX__ diff --git a/dev/zka/CFKit/LoaderUtils.hxx b/dev/zka/CFKit/LoaderUtils.hxx deleted file mode 100644 index 7385fc2e..00000000 --- a/dev/zka/CFKit/LoaderUtils.hxx +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __CFKIT_LOADER_UTILS_HXX__ -#define __CFKIT_LOADER_UTILS_HXX__ - -#include -#include - -namespace Kernel -{ - /// @brief Find the PE header inside the blob. - inline auto ldr_find_exec_header(DosHeaderPtr ptrDos) -> LDR_EXEC_HEADER_PTR - { - if (!ptrDos) - return nullptr; - - if (ptrDos->eMagic[0] != kMagMz0) - return nullptr; - - if (ptrDos->eMagic[1] != kMagMz1) - return nullptr; - - return (LDR_EXEC_HEADER_PTR)(VoidPtr)(&ptrDos->eLfanew + 1); - } - - /// @brief Find the PE optional header inside the blob. - inline auto ldr_find_opt_exec_header(DosHeaderPtr ptrDos) -> LDR_OPTIONAL_HEADER_PTR - { - if (!ptrDos) - return nullptr; - - auto exec = ldr_find_exec_header(ptrDos); - - if (!exec) - return nullptr; - - return (LDR_OPTIONAL_HEADER_PTR)(VoidPtr)(&exec->mCharacteristics + 1); - } - - /// @brief Find the PE header inside the blob. - /// @note overloaded function. - inline auto ldr_find_exec_header(const Char* ptrDos) -> LDR_EXEC_HEADER_PTR - { - return ldr_find_exec_header((DosHeaderPtr)ptrDos); - } - - /// @brief Find the PE header inside the blob. - /// @note overloaded function. - inline auto ldr_find_opt_exec_header(const Char* ptrDos) -> LDR_OPTIONAL_HEADER_PTR - { - return ldr_find_opt_exec_header((DosHeaderPtr)ptrDos); - } -} // namespace Kernel - -#endif // ifndef __CFKIT_LOADER_UTILS_HXX__ diff --git a/dev/zka/CFKit/Property.h b/dev/zka/CFKit/Property.h new file mode 100644 index 00000000..56829165 --- /dev/null +++ b/dev/zka/CFKit/Property.h @@ -0,0 +1,47 @@ +/* ------------------------------------------- + + Copyright ZKA Web Services Co. + +------------------------------------------- */ + +#ifndef __INC_PROPS_HPP__ +#define __INC_PROPS_HPP__ + +#include +#include +#include +#include + +#define cMaxPropLen 4096 + +namespace Kernel +{ + /// @brief handle to anything (number, ptr, string...) + using PropertyId = UIntPtr; + + /// @brief Kernel property class. + /// @example \Properties\SmpCores or \Properties\KernelVersion + class Property + { + public: + Property() = default; + virtual ~Property(); + + public: + Property& operator=(const Property&) = default; + Property(const Property&) = default; + + bool StringEquals(StringView& name); + PropertyId& GetValue(); + StringView& GetKey(); + + private: + StringView fName{cMaxPropLen}; + PropertyId fAction{No}; + }; + + template + using PropertyArray = Array; +} // namespace Kernel + +#endif // !__INC_PROPS_HPP__ diff --git a/dev/zka/CFKit/Property.hxx b/dev/zka/CFKit/Property.hxx deleted file mode 100644 index 7f1aed64..00000000 --- a/dev/zka/CFKit/Property.hxx +++ /dev/null @@ -1,47 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Web Services Co. - -------------------------------------------- */ - -#ifndef __INC_PROPS_HPP__ -#define __INC_PROPS_HPP__ - -#include -#include -#include -#include - -#define cMaxPropLen 4096 - -namespace Kernel -{ - /// @brief handle to anything (number, ptr, string...) - using PropertyId = UIntPtr; - - /// @brief Kernel property class. - /// @example \Properties\SmpCores or \Properties\KernelVersion - class Property - { - public: - Property() = default; - virtual ~Property(); - - public: - Property& operator=(const Property&) = default; - Property(const Property&) = default; - - bool StringEquals(StringView& name); - PropertyId& GetValue(); - StringView& GetKey(); - - private: - StringView fName{cMaxPropLen}; - PropertyId fAction{No}; - }; - - template - using PropertyArray = Array; -} // namespace Kernel - -#endif // !__INC_PROPS_HPP__ -- cgit v1.2.3