diff options
| author | Amlal <amlal@nekernel.org> | 2025-04-25 13:08:33 +0200 |
|---|---|---|
| committer | Amlal <amlal@nekernel.org> | 2025-04-25 13:08:33 +0200 |
| commit | fb790b07aeba8e22e4190cf3e1834d11ecde6c96 (patch) | |
| tree | 4cec7d1b321307b1d5935577631dae116a658a37 /dev/kernel/CFKit/Utils.h | |
| parent | 63a2d92c5dfe976175cda024ec01905d11b43738 (diff) | |
dev: better .clang-format, ran format command.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/CFKit/Utils.h')
| -rw-r--r-- | dev/kernel/CFKit/Utils.h | 90 |
1 files changed, 40 insertions, 50 deletions
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 |
