// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/nekernel-org/nekernel #ifndef KERNELKIT_PE32CODEMGR_H #define KERNELKIT_PE32CODEMGR_H //////////////////////////////////////////////////// // LAST REV: Mon Feb 12 13:52:01 CET 2024 //////////////////////////////////////////////////// #include #include #include #include #include #ifndef __KERNEL_KIT_USER_PROCESS_SCHEDULER_H__ #include #endif #define kPeApplicationMime "application/vnd-portable-executable" #define kPeImageStart "__ImageStart" namespace Kernel { /// /// \name PE32Loader /// \brief PE32+ loader class. /// class PE32Loader : public ILoader { private: explicit PE32Loader() = delete; public: explicit PE32Loader(const VoidPtr blob); explicit PE32Loader(const Char* path); ~PE32Loader() override; public: NE_COPY_DEFAULT(PE32Loader) public: const Char* Path() override; const Char* AsString() override; const Char* MIME() override; public: ErrorOr FindStart() override; ErrorOr FindSectionByName(const Char* name); ErrorOr FindSymbol(const Char* name, Int32 kind) override; ErrorOr GetBlob() override; public: BOOL IsLoaded(); private: #ifdef __FSKIT_INCLUDES_NEFS__ OwnPtr> fFile; #elif defined(__FSKIT_INCLUDES_OPENHEFS__) OwnPtr> fFile; #else OwnPtr> fFile; #endif // __FSKIT_INCLUDES_NEFS__ Ref fPath; RefAny fCachedBlob{}; BOOL fBad{}; }; enum { kPEPlatformInvalid, kPEPlatformAMD64 = 100, kPEPlatformARM64 }; enum { kPETypeInvalid, kPETypeText = 100, kPETypeData, kPETypeBSS }; using PE_SECTION_INFO = LDR_SECTION_HEADER; ProcessID rtl_create_user_process(PE32Loader& exec, const UserProcess::ExecutableKind& process_kind); } // namespace Kernel #endif