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-09-25 08:17:38 +02:00
|
|
|
: AppLoader(std::move(file)), filepath(filepath), base_ncch(filepath),
|
|
|
|
overlay_ncch(&base_ncch) {}
|
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);
|
|
|
|
}
|
|
|
|
|
2017-09-27 01:17:47 +02:00
|
|
|
ResultStatus Load(Kernel::SharedPtr<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
|
|
|
*/
|
2017-03-09 02:21:31 +01:00
|
|
|
std::pair<boost::optional<u32>, ResultStatus> LoadKernelSystemMode() override;
|
2016-11-20 02:40:04 +01:00
|
|
|
|
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;
|
|
|
|
|
2016-09-18 02:38:01 +02:00
|
|
|
ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
|
|
|
u64& size) override;
|
2014-06-22 21:40:21 +02:00
|
|
|
|
2017-09-25 08:17:38 +02:00
|
|
|
ResultStatus ReadUpdateRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
|
|
|
u64& size) override;
|
|
|
|
|
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
|
|
|
|
*/
|
2017-09-27 01:17:47 +02:00
|
|
|
ResultStatus LoadExec(Kernel::SharedPtr<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
|