Luna/kernel/src/binfmt/BinaryFormat.h

33 lines
827 B
C
Raw Normal View History

#pragma once
#include "fs/VFS.h"
#include "memory/AddressSpace.h"
class BinaryFormatLoader : public Shareable
{
public:
virtual Result<bool> sniff() = 0;
virtual Result<u64> load(AddressSpace* space) = 0;
virtual StringView format() const = 0;
virtual Result<Vector<String>> cmdline(const String& path, Vector<String> args) = 0;
virtual ~BinaryFormatLoader() = default;
BinaryFormatLoader(SharedPtr<VFS::Inode>);
protected:
SharedPtr<VFS::Inode> m_inode;
};
typedef Result<SharedPtr<BinaryFormatLoader>> (*binfmt_loader_creator_t)(SharedPtr<VFS::Inode>, void*);
namespace BinaryFormat
{
Result<void> init();
Result<void> register_binary_format(binfmt_loader_creator_t creator, void* arg);
Result<SharedPtr<BinaryFormatLoader>> create_loader(SharedPtr<VFS::Inode> inode);
}