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