summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/CFKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-05-02 19:38:46 +0200
committerGitHub <noreply@github.com>2025-05-02 19:38:46 +0200
commit997be16e5ac9a68d54882ab69529815860d62955 (patch)
tree19d6129c2d776bb1edc5d4a7325e39ca176c3403 /dev/kernel/CFKit
parent618104e74c195d7508a18450524f8ed7f9af8cc6 (diff)
parentb3b4b1ebdcd6adeac914869017c86d892b7a8ced (diff)
Merge pull request #28 from nekernel-org/dev
0.0.2
Diffstat (limited to 'dev/kernel/CFKit')
-rw-r--r--dev/kernel/CFKit/GUIDWizard.h15
-rw-r--r--dev/kernel/CFKit/GUIDWrapper.h79
-rw-r--r--dev/kernel/CFKit/Property.h75
-rw-r--r--dev/kernel/CFKit/Utils.h90
4 files changed, 118 insertions, 141 deletions
diff --git a/dev/kernel/CFKit/GUIDWizard.h b/dev/kernel/CFKit/GUIDWizard.h
index b1d3e310..ae62b8fc 100644
--- a/dev/kernel/CFKit/GUIDWizard.h
+++ b/dev/kernel/CFKit/GUIDWizard.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
@@ -11,14 +11,13 @@
#include <NewKit/ArrayList.h>
#include <NewKit/Defines.h>
#include <NewKit/ErrorOr.h>
+#include <NewKit/KString.h>
#include <NewKit/Ref.h>
#include <NewKit/Stream.h>
-#include <NewKit/KString.h>
-namespace CF::XRN::Version1
-{
- using namespace Kernel;
+namespace CF::XRN::Version1 {
+using namespace Kernel;
- Ref<GUIDSequence*> cf_make_sequence(const ArrayList<UInt32>& seq);
- ErrorOr<Ref<Kernel::KString>> cf_try_guid_to_string(Ref<GUIDSequence*>& guid);
-} // namespace CF::XRN::Version1
+Ref<GUIDSequence*> cf_make_sequence(const ArrayList<UInt32>& seq);
+ErrorOr<Ref<Kernel::KString>> cf_try_guid_to_string(Ref<GUIDSequence*>& guid);
+} // namespace CF::XRN::Version1
diff --git a/dev/kernel/CFKit/GUIDWrapper.h b/dev/kernel/CFKit/GUIDWrapper.h
index c8143cea..cc01bfad 100644
--- a/dev/kernel/CFKit/GUIDWrapper.h
+++ b/dev/kernel/CFKit/GUIDWrapper.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
@@ -15,46 +15,37 @@
#define kXRNNil "@{........-....-M...-N...-............}"
/// @brief eXtended Resource Namespace
-namespace CF::XRN
-{
- using namespace Kernel;
-
- union GUIDSequence {
- alignas(8) UShort fU8[16];
- alignas(8) UShort fU16[8];
- alignas(8) UInt fU32[4];
- alignas(8) ULong fU64[2];
-
- struct GUID
- {
- alignas(8) UInt fMs1;
- UShort fMs2;
- UShort fMs3;
- UChar fMs4[8];
- } fUuid;
- };
-
- 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 CF::XRN
+namespace CF::XRN {
+using namespace Kernel;
+
+union GUIDSequence {
+ alignas(8) UShort fU8[16];
+ alignas(8) UShort fU16[8];
+ alignas(8) UInt fU32[4];
+ alignas(8) ULong fU64[2];
+
+ struct GUID {
+ alignas(8) UInt fMs1;
+ UShort fMs2;
+ UShort fMs3;
+ UChar fMs4[8];
+ } fUuid;
+};
+
+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 CF::XRN
diff --git a/dev/kernel/CFKit/Property.h b/dev/kernel/CFKit/Property.h
index 510b2c53..4dde15f9 100644
--- a/dev/kernel/CFKit/Property.h
+++ b/dev/kernel/CFKit/Property.h
@@ -1,56 +1,53 @@
/* -------------------------------------------
- Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
#ifndef CFKIT_PROPS_H
#define CFKIT_PROPS_H
+#include <CFKit/GUIDWrapper.h>
#include <NewKit/Array.h>
#include <NewKit/Defines.h>
#include <NewKit/Function.h>
#include <NewKit/KString.h>
-#include <CFKit/GUIDWrapper.h>
#define kMaxPropLen (256U)
-namespace CF
-{
- using namespace Kernel;
-
- /// @brief handle to anything (number, ptr, string...)
- using PropertyId = UIntPtr;
-
- /// @brief Kernel property class.
- /// @example /prop/smp_max or /prop/kern_ver
- class Property
- {
- public:
- Property();
- virtual ~Property();
-
- public:
- Property& operator=(const Property&) = default;
- Property(const Property&) = default;
-
- BOOL StringEquals(KString& name);
- PropertyId& GetValue();
- KString& GetKey();
-
- private:
- KString fName{kMaxPropLen};
- PropertyId fValue{0UL};
- Ref<XRN::GUID> fGUID{};
- };
-
- template <SizeT N>
- using PropertyArray = Array<Property, N>;
-} // namespace CF
-
-namespace Kernel
-{
- using namespace CF;
+namespace CF {
+using namespace Kernel;
+
+/// @brief handle to anything (number, ptr, string...)
+using PropertyId = UIntPtr;
+
+/// @brief Kernel property class.
+/// @example /prop/smp_max or /prop/kern_ver
+class Property {
+ public:
+ Property();
+ virtual ~Property();
+
+ public:
+ Property& operator=(const Property&) = default;
+ Property(const Property&) = default;
+
+ BOOL StringEquals(KString& name);
+ PropertyId& GetValue();
+ KString& GetKey();
+
+ private:
+ KString fName{kMaxPropLen};
+ PropertyId fValue{0UL};
+ Ref<XRN::GUID> fGUID{};
+};
+
+template <SizeT N>
+using PropertyArray = Array<Property, N>;
+} // namespace CF
+
+namespace Kernel {
+using namespace CF;
}
-#endif // !CFKIT_PROPS_H
+#endif // !CFKIT_PROPS_H
diff --git a/dev/kernel/CFKit/Utils.h b/dev/kernel/CFKit/Utils.h
index b2a8b708..a5df8097 100644
--- a/dev/kernel/CFKit/Utils.h
+++ b/dev/kernel/CFKit/Utils.h
@@ -1,56 +1,46 @@
#ifndef CFKIT_UTILS_H
#define CFKIT_UTILS_H
-#include <KernelKit/PE.h>
#include <KernelKit/MSDOS.h>
+#include <KernelKit/PE.h>
/// @brief CFKit
-namespace CF
-{
- using namespace Kernel;
-
- /// @brief Finds 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 Finds 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->Characteristics + 1);
- }
-
- /// @brief Finds 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 Finds 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 CF
-
-#endif // ifndef CFKIT_UTILS_H
+namespace CF {
+using namespace Kernel;
+
+/// @brief Finds 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 Finds 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->Characteristics + 1);
+}
+
+/// @brief Finds 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 Finds 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 CF
+
+#endif // ifndef CFKIT_UTILS_H