#pragma once #ifndef __is_kernel #error "This is kernel only header" #endif #include #include #include #include #include #include namespace LibELF { class LoadableELF { BAN_NON_COPYABLE(LoadableELF); BAN_NON_MOVABLE(LoadableELF); public: static BAN::ErrorOr> load_from_inode(Kernel::PageTable&, BAN::RefPtr); ~LoadableELF(); Kernel::vaddr_t entry_point() const; bool contains(Kernel::vaddr_t address) const; bool is_address_space_free() const; void reserve_address_space(); void update_suid_sgid(Kernel::Credentials&); BAN::ErrorOr load_page_to_memory(Kernel::vaddr_t address); BAN::ErrorOr> clone(Kernel::PageTable&); size_t virtual_page_count() const { return m_virtual_page_count; } size_t physical_page_count() const { return m_physical_page_count; } private: LoadableELF(Kernel::PageTable&, BAN::RefPtr); BAN::ErrorOr initialize(); private: BAN::RefPtr m_inode; Kernel::PageTable& m_page_table; ElfNativeFileHeader m_file_header; BAN::Vector m_program_headers; size_t m_virtual_page_count = 0; size_t m_physical_page_count = 0; bool m_loaded { false }; }; }