2018-01-13 22:22:39 +01:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-09-24 17:08:31 +02:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-10-15 03:41:58 +02:00
|
|
|
#include <optional>
|
2017-09-24 17:08:31 +02:00
|
|
|
#include "common/common_types.h"
|
2018-09-30 04:16:09 +02:00
|
|
|
#include "core/file_sys/patch_manager.h"
|
2017-10-06 05:30:08 +02:00
|
|
|
#include "core/loader/linker.h"
|
2017-09-24 17:08:31 +02:00
|
|
|
#include "core/loader/loader.h"
|
|
|
|
|
2018-12-03 04:24:43 +01:00
|
|
|
namespace Kernel {
|
|
|
|
class Process;
|
|
|
|
}
|
|
|
|
|
2017-09-24 17:08:31 +02:00
|
|
|
namespace Loader {
|
|
|
|
|
2018-10-05 19:52:07 +02:00
|
|
|
constexpr u64 NSO_ARGUMENT_DATA_ALLOCATION_SIZE = 0x9000;
|
|
|
|
|
2018-09-30 20:04:48 +02:00
|
|
|
struct NSOArgumentHeader {
|
|
|
|
u32_le allocated_size;
|
|
|
|
u32_le actual_size;
|
|
|
|
INSERT_PADDING_BYTES(0x18);
|
|
|
|
};
|
|
|
|
static_assert(sizeof(NSOArgumentHeader) == 0x20, "NSOArgumentHeader has incorrect size.");
|
|
|
|
|
2017-09-24 17:08:31 +02:00
|
|
|
/// Loads an NSO file
|
2017-10-06 05:30:08 +02:00
|
|
|
class AppLoader_NSO final : public AppLoader, Linker {
|
2017-09-24 17:08:31 +02:00
|
|
|
public:
|
2018-07-19 03:07:11 +02:00
|
|
|
explicit AppLoader_NSO(FileSys::VirtualFile file);
|
2017-09-24 17:08:31 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the type of the file
|
2018-07-19 03:07:11 +02:00
|
|
|
* @param file std::shared_ptr<VfsFile> open file
|
2017-09-24 17:08:31 +02:00
|
|
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
|
|
|
*/
|
2018-07-19 03:07:11 +02:00
|
|
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
2017-09-24 17:08:31 +02:00
|
|
|
|
|
|
|
FileType GetFileType() override {
|
2018-07-19 03:07:11 +02:00
|
|
|
return IdentifyType(file);
|
2017-09-24 17:08:31 +02:00
|
|
|
}
|
|
|
|
|
2018-12-03 04:24:43 +01:00
|
|
|
static std::optional<VAddr> LoadModule(Kernel::Process& process, const FileSys::VfsFile& file,
|
|
|
|
VAddr load_base, bool should_pass_arguments,
|
2018-10-15 03:41:58 +02:00
|
|
|
std::optional<FileSys::PatchManager> pm = {});
|
2018-01-20 20:20:04 +01:00
|
|
|
|
2018-09-29 21:57:40 +02:00
|
|
|
ResultStatus Load(Kernel::Process& process) override;
|
2017-09-24 17:08:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Loader
|