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