mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-13 02:27:56 -05:00
Loader/NCCH: Add support for loading application updates (#2927)
* loader/ncch: split NCCH parsing into its own file * loader/ncch: add support for loading update NCCHs from the SD card * loader/ncch: fix formatting * file_sys/ncch_container: Return a value for OpenFile * loader/ncch: cleanup, always instantiate overlay_ncch to base_ncch * file_sys/ncch_container: better encryption checks, allow non-app NCCHs to load properly and for the existence of NCCH structures to be checked * file_sys/ncch_container: pass filepath as a const reference
This commit is contained in:
@ -102,8 +102,7 @@ public:
|
||||
|
||||
switch (static_cast<SelfNCCHFilePathType>(file_path.type)) {
|
||||
case SelfNCCHFilePathType::UpdateRomFS:
|
||||
LOG_WARNING(Service_FS, "(STUBBED) open update RomFS");
|
||||
return OpenRomFS();
|
||||
return OpenUpdateRomFS();
|
||||
|
||||
case SelfNCCHFilePathType::RomFS:
|
||||
return OpenRomFS();
|
||||
@ -179,6 +178,17 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
ResultVal<std::unique_ptr<FileBackend>> OpenUpdateRomFS() const {
|
||||
if (ncch_data.update_romfs_file) {
|
||||
return MakeResult<std::unique_ptr<FileBackend>>(std::make_unique<IVFCFile>(
|
||||
ncch_data.update_romfs_file, ncch_data.update_romfs_offset,
|
||||
ncch_data.update_romfs_size));
|
||||
} else {
|
||||
LOG_INFO(Service_FS, "Unable to read update RomFS");
|
||||
return ERROR_ROMFS_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
ResultVal<std::unique_ptr<FileBackend>> OpenExeFS(const std::string& filename) const {
|
||||
if (filename == "icon") {
|
||||
if (ncch_data.icon) {
|
||||
@ -218,11 +228,19 @@ private:
|
||||
};
|
||||
|
||||
ArchiveFactory_SelfNCCH::ArchiveFactory_SelfNCCH(Loader::AppLoader& app_loader) {
|
||||
std::shared_ptr<FileUtil::IOFile> romfs_file_;
|
||||
std::shared_ptr<FileUtil::IOFile> romfs_file;
|
||||
if (Loader::ResultStatus::Success ==
|
||||
app_loader.ReadRomFS(romfs_file_, ncch_data.romfs_offset, ncch_data.romfs_size)) {
|
||||
app_loader.ReadRomFS(romfs_file, ncch_data.romfs_offset, ncch_data.romfs_size)) {
|
||||
|
||||
ncch_data.romfs_file = std::move(romfs_file_);
|
||||
ncch_data.romfs_file = std::move(romfs_file);
|
||||
}
|
||||
|
||||
std::shared_ptr<FileUtil::IOFile> update_romfs_file;
|
||||
if (Loader::ResultStatus::Success ==
|
||||
app_loader.ReadUpdateRomFS(update_romfs_file, ncch_data.update_romfs_offset,
|
||||
ncch_data.update_romfs_size)) {
|
||||
|
||||
ncch_data.update_romfs_file = std::move(update_romfs_file);
|
||||
}
|
||||
|
||||
std::vector<u8> buffer;
|
||||
|
Reference in New Issue
Block a user