ncch_container: support encrypted games
This commit is contained in:
parent
b92660435c
commit
d4a808c885
17 changed files with 319 additions and 103 deletions
|
@ -283,8 +283,7 @@ ResultStatus AppLoader_THREEDSX::Load(Kernel::SharedPtr<Kernel::Process>& proces
|
|||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_THREEDSX::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file,
|
||||
u64& offset, u64& size) {
|
||||
ResultStatus AppLoader_THREEDSX::ReadRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) {
|
||||
if (!file.IsOpen())
|
||||
return ResultStatus::Error;
|
||||
|
||||
|
@ -307,12 +306,12 @@ ResultStatus AppLoader_THREEDSX::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& ro
|
|||
LOG_DEBUG(Loader, "RomFS size: {:#010X}", romfs_size);
|
||||
|
||||
// We reopen the file, to allow its position to be independent from file's
|
||||
romfs_file = std::make_shared<FileUtil::IOFile>(filepath, "rb");
|
||||
if (!romfs_file->IsOpen())
|
||||
FileUtil::IOFile romfs_file_inner(filepath, "rb");
|
||||
if (!romfs_file_inner.IsOpen())
|
||||
return ResultStatus::Error;
|
||||
|
||||
offset = romfs_offset;
|
||||
size = romfs_size;
|
||||
romfs_file = std::make_shared<FileSys::RomFSReader>(std::move(romfs_file_inner),
|
||||
romfs_offset, romfs_size);
|
||||
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@ public:
|
|||
|
||||
ResultStatus ReadIcon(std::vector<u8>& buffer) override;
|
||||
|
||||
ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
||||
u64& size) override;
|
||||
ResultStatus ReadRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) override;
|
||||
|
||||
private:
|
||||
std::string filename;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <boost/optional.hpp>
|
||||
#include "common/common_types.h"
|
||||
#include "common/file_util.h"
|
||||
#include "core/file_sys/romfs_reader.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
|
||||
namespace Kernel {
|
||||
|
@ -160,12 +161,9 @@ public:
|
|||
* Get the RomFS of the application
|
||||
* Since the RomFS can be huge, we return a file reference instead of copying to a buffer
|
||||
* @param romfs_file The file containing the RomFS
|
||||
* @param offset The offset the romfs begins on
|
||||
* @param size The size of the romfs
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
||||
u64& size) {
|
||||
virtual ResultStatus ReadRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) {
|
||||
return ResultStatus::ErrorNotImplemented;
|
||||
}
|
||||
|
||||
|
@ -173,12 +171,9 @@ public:
|
|||
* Get the update RomFS of the application
|
||||
* Since the RomFS can be huge, we return a file reference instead of copying to a buffer
|
||||
* @param romfs_file The file containing the RomFS
|
||||
* @param offset The offset the romfs begins on
|
||||
* @param size The size of the romfs
|
||||
* @return ResultStatus result of function
|
||||
*/
|
||||
virtual ResultStatus ReadUpdateRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
||||
u64& size) {
|
||||
virtual ResultStatus ReadUpdateRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) {
|
||||
return ResultStatus::ErrorNotImplemented;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,17 +211,15 @@ ResultStatus AppLoader_NCCH::ReadProgramId(u64& out_program_id) {
|
|||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
||||
u64& size) {
|
||||
return base_ncch.ReadRomFS(romfs_file, offset, size);
|
||||
ResultStatus AppLoader_NCCH::ReadRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) {
|
||||
return base_ncch.ReadRomFS(romfs_file);
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NCCH::ReadUpdateRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file,
|
||||
u64& offset, u64& size) {
|
||||
ResultStatus result = update_ncch.ReadRomFS(romfs_file, offset, size);
|
||||
ResultStatus AppLoader_NCCH::ReadUpdateRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) {
|
||||
ResultStatus result = update_ncch.ReadRomFS(romfs_file);
|
||||
|
||||
if (result != ResultStatus::Success)
|
||||
return base_ncch.ReadRomFS(romfs_file, offset, size);
|
||||
return base_ncch.ReadRomFS(romfs_file);
|
||||
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
|
|
@ -51,11 +51,9 @@ public:
|
|||
|
||||
ResultStatus ReadProgramId(u64& out_program_id) override;
|
||||
|
||||
ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
||||
u64& size) override;
|
||||
ResultStatus ReadRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) override;
|
||||
|
||||
ResultStatus ReadUpdateRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset,
|
||||
u64& size) override;
|
||||
ResultStatus ReadUpdateRomFS(std::shared_ptr<FileSys::RomFSReader>& romfs_file) override;
|
||||
|
||||
ResultStatus ReadTitle(std::string& title) override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue