2018-01-13 15:22:39 -06:00
|
|
|
// Copyright 2018 yuzu emulator team
|
2017-10-05 22:30:08 -05:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-19 19:45:55 -05:00
|
|
|
#include <memory>
|
2017-10-05 22:30:08 -05:00
|
|
|
#include <string>
|
2018-10-23 17:35:20 -05:00
|
|
|
#include <vector>
|
2017-10-05 22:30:08 -05:00
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "core/loader/loader.h"
|
|
|
|
|
2018-07-23 16:27:50 -05:00
|
|
|
namespace FileSys {
|
|
|
|
class NACP;
|
|
|
|
}
|
|
|
|
|
2018-12-02 21:13:50 -06:00
|
|
|
namespace Kernel {
|
|
|
|
class Process;
|
|
|
|
}
|
|
|
|
|
2017-10-05 22:30:08 -05:00
|
|
|
namespace Loader {
|
|
|
|
|
|
|
|
/// Loads an NRO file
|
2019-03-19 19:45:55 -05:00
|
|
|
class AppLoader_NRO final : public AppLoader {
|
2017-10-05 22:30:08 -05:00
|
|
|
public:
|
2018-07-23 16:20:29 -05:00
|
|
|
explicit AppLoader_NRO(FileSys::VirtualFile file);
|
2018-07-23 16:27:50 -05:00
|
|
|
~AppLoader_NRO() override;
|
2017-10-05 22:30:08 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the type of the file
|
2018-07-18 20:07:11 -05:00
|
|
|
* @param file std::shared_ptr<VfsFile> open file
|
2017-10-05 22:30:08 -05:00
|
|
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
|
|
|
*/
|
2018-07-18 20:07:11 -05:00
|
|
|
static FileType IdentifyType(const FileSys::VirtualFile& file);
|
2017-10-05 22:30:08 -05:00
|
|
|
|
2018-12-05 16:42:41 -06:00
|
|
|
FileType GetFileType() const override {
|
2018-07-18 20:07:11 -05:00
|
|
|
return IdentifyType(file);
|
2017-10-05 22:30:08 -05:00
|
|
|
}
|
|
|
|
|
2019-04-09 16:03:04 -05:00
|
|
|
LoadResult Load(Kernel::Process& process) override;
|
2017-10-05 22:30:08 -05:00
|
|
|
|
2018-07-23 11:33:24 -05: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;
|
2018-08-26 09:53:31 -05:00
|
|
|
bool IsRomFSUpdatable() const override;
|
2018-07-23 11:33:24 -05:00
|
|
|
|
2017-10-05 22:30:08 -05:00
|
|
|
private:
|
2018-12-02 21:13:50 -06:00
|
|
|
bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& file, VAddr load_base);
|
2018-07-23 11:33:24 -05:00
|
|
|
|
|
|
|
std::vector<u8> icon_data;
|
|
|
|
std::unique_ptr<FileSys::NACP> nacp;
|
|
|
|
FileSys::VirtualFile romfs;
|
2017-10-05 22:30:08 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Loader
|