2018-01-13 21:22:39 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-10-06 03:30:08 +00:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "core/hle/kernel/kernel.h"
|
|
|
|
#include "core/loader/linker.h"
|
|
|
|
#include "core/loader/loader.h"
|
|
|
|
|
2018-07-23 21:27:50 +00:00
|
|
|
namespace FileSys {
|
|
|
|
class NACP;
|
|
|
|
}
|
|
|
|
|
2017-10-06 03:30:08 +00:00
|
|
|
namespace Loader {
|
|
|
|
|
|
|
|
/// Loads an NRO file
|
|
|
|
class AppLoader_NRO final : public AppLoader, Linker {
|
|
|
|
public:
|
2018-07-23 21:20:29 +00:00
|
|
|
explicit AppLoader_NRO(FileSys::VirtualFile file);
|
2018-07-23 21:27:50 +00:00
|
|
|
~AppLoader_NRO() override;
|
2017-10-06 03:30:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the type of the file
|
2018-07-19 01:07:11 +00:00
|
|
|
* @param file std::shared_ptr<VfsFile> open file
|
2017-10-06 03:30:08 +00:00
|
|
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
|
|
|
*/
|
2018-07-19 01:07:11 +00:00
|
|
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
2017-10-06 03:30:08 +00:00
|
|
|
|
|
|
|
FileType GetFileType() override {
|
2018-07-19 01:07:11 +00:00
|
|
|
return IdentifyType(file);
|
2017-10-06 03:30:08 +00:00
|
|
|
}
|
|
|
|
|
2017-10-10 03:56:20 +00:00
|
|
|
ResultStatus Load(Kernel::SharedPtr<Kernel::Process>& process) override;
|
2017-10-06 03:30:08 +00:00
|
|
|
|
2018-07-23 16:33:24 +00:00
|
|
|
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
|
|
|
ResultStatus ReadProgramId(u64& out_program_id) override;
|
|
|
|
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
|
|
|
ResultStatus ReadTitle(std::string& title) override;
|
|
|
|
|
2017-10-06 03:30:08 +00:00
|
|
|
private:
|
2018-07-19 01:07:11 +00:00
|
|
|
bool LoadNro(FileSys::VirtualFile file, VAddr load_base);
|
2018-07-23 16:33:24 +00:00
|
|
|
|
|
|
|
std::vector<u8> icon_data;
|
|
|
|
std::unique_ptr<FileSys::NACP> nacp;
|
|
|
|
FileSys::VirtualFile romfs;
|
2017-10-06 03:30:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Loader
|