2014-06-17 04:57:09 +02:00
|
|
|
// Copyright 2014 Citra Emulator Project
|
2014-12-17 06:38:14 +01:00
|
|
|
// Licensed under GPLv2 or any later version
|
2014-06-17 04:57:09 +02:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-05-06 09:06:12 +02:00
|
|
|
#include <memory>
|
|
|
|
#include "common/common_types.h"
|
2015-05-04 05:01:16 +02:00
|
|
|
#include "common/swap.h"
|
2017-09-25 08:17:38 +02:00
|
|
|
#include "core/file_sys/ncch_container.h"
|
2014-06-19 00:58:09 +02:00
|
|
|
#include "core/loader/loader.h"
|
|
|
|
|
2014-06-17 04:57:09 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2014-06-19 00:58:09 +02:00
|
|
|
// Loader namespace
|
2014-06-17 04:57:09 +02:00
|
|
|
|
|
|
|
namespace Loader {
|
|
|
|
|
2014-06-19 00:58:09 +02:00
|
|
|
/// Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI)
|
2014-07-04 19:20:40 +02:00
|
|
|
class AppLoader_NCCH final : public AppLoader {
|
2014-06-19 00:58:09 +02:00
|
|
|
public:
|
2015-07-12 00:16:33 +02:00
|
|
|
AppLoader_NCCH(FileUtil::IOFile&& file, const std::string& filepath)
|
2017-12-11 01:50:45 +01:00
|
|
|
: AppLoader(std::move(file)), base_ncch(filepath), overlay_ncch(&base_ncch),
|
|
|
|
filepath(filepath) {}
|
2014-06-19 00:58:09 +02:00
|
|
|
|
2015-01-07 00:10:13 +01:00
|
|
|
/**
|
|
|
|
* Returns the type of the file
|
|
|
|
* @param file FileUtil::IOFile open file
|
|
|
|
* @return FileType found, or FileType::Error if this loader doesn't know it
|
|
|
|
*/
|
|
|
|
static FileType IdentifyType(FileUtil::IOFile& file);
|
|
|
|
|
2016-05-18 00:30:44 +02:00
|
|
|
FileType GetFileType() override {
|
|
|
|
return IdentifyType(file);
|
|
|
|
}
|
|
|
|
|
2019-03-23 21:04:19 +01:00
|
|
|
ResultStatus Load(std::shared_ptr<Kernel::Process>& process) override;
|
2014-06-19 00:58:09 +02:00
|
|
|
|
2016-11-20 02:40:04 +01:00
|
|
|
/**
|
|
|
|
* Loads the Exheader and returns the system mode for this application.
|
2017-06-02 23:03:38 +02:00
|
|
|
* @returns A pair with the optional system mode, and and the status.
|
2016-11-20 02:40:04 +01:00
|
|
|
*/
|
2018-10-05 12:37:55 +02:00
|
|
|
std::pair<std::optional<u32>, ResultStatus> LoadKernelSystemMode() override;
|
2016-11-20 02:40:04 +01:00
|
|
|
|
2019-09-07 10:52:18 +02:00
|
|
|
ResultStatus IsExecutable(bool& out_executable) override;
|
|
|
|
|
2015-07-12 00:16:33 +02:00
|
|
|
ResultStatus ReadCode(std::vector<u8>& buffer) override;
|
2014-06-19 00:58:09 +02:00
|
|
|
|
2015-07-12 00:16:33 +02:00
|
|
|
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
2014-06-19 00:58:09 +02:00
|
|
|
|
2015-07-12 00:16:33 +02:00
|
|
|
ResultStatus ReadBanner(std::vector<u8>& buffer) override;
|
2014-06-22 21:40:21 +02:00
|
|
|
|
2015-07-12 00:16:33 +02:00
|
|
|
ResultStatus ReadLogo(std::vector<u8>& buffer) override;
|
2014-06-22 21:40:21 +02:00
|
|
|
|
2016-12-15 10:54:25 +01:00
|
|
|
ResultStatus ReadProgramId(u64& out_program_id) override;
|
|
|
|
|
2018-09-16 06:48:39 +02:00
|
|
|
ResultStatus ReadExtdataId(u64& out_extdata_id) override;
|
|
|
|
|
2018-07-28 17:30:54 +02:00
|
|
|
ResultStatus ReadRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) override;
|
2014-06-22 21:40:21 +02:00
|
|
|
|
2018-07-28 17:30:54 +02:00
|
|
|
ResultStatus ReadUpdateRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) override;
|
2017-09-25 08:17:38 +02:00
|
|
|
|
2017-08-02 01:51:44 +02:00
|
|
|
ResultStatus ReadTitle(std::string& title) override;
|
|
|
|
|
2014-06-22 21:40:21 +02:00
|
|
|
private:
|
2014-06-19 00:58:09 +02:00
|
|
|
/**
|
|
|
|
* Loads .code section into memory for booting
|
2017-09-27 01:17:47 +02:00
|
|
|
* @param process The newly created process
|
2014-06-19 00:58:09 +02:00
|
|
|
* @return ResultStatus result of function
|
|
|
|
*/
|
2019-03-23 21:04:19 +01:00
|
|
|
ResultStatus LoadExec(std::shared_ptr<Kernel::Process>& process);
|
2014-06-19 00:58:09 +02:00
|
|
|
|
2016-11-30 10:32:09 +01:00
|
|
|
/// Reads the region lockout info in the SMDH and send it to CFG service
|
|
|
|
void ParseRegionLockoutInfo();
|
|
|
|
|
2017-09-25 08:17:38 +02:00
|
|
|
FileSys::NCCHContainer base_ncch;
|
|
|
|
FileSys::NCCHContainer update_ncch;
|
|
|
|
FileSys::NCCHContainer* overlay_ncch;
|
2015-07-09 23:55:23 +02:00
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
std::string filepath;
|
2014-06-19 00:58:09 +02:00
|
|
|
};
|
2014-06-17 04:57:09 +02:00
|
|
|
|
|
|
|
} // namespace Loader
|