From cfbe3331e31dfa4ae8aa0a3485528b67fa3841e7 Mon Sep 17 00:00:00 2001 From: jakcron Date: Sat, 12 Mar 2022 13:30:43 +0800 Subject: [PATCH] Update to libtoolchain v0.5 --- deps/libnintendo-es | 2 +- deps/libnintendo-hac | 2 +- deps/libnintendo-hac-hb | 2 +- deps/libnintendo-pki | 2 +- deps/libtoolchain | 2 +- src/FsProcess.cpp | 6 +++--- src/FsProcess.h | 4 ++-- src/GameCardProcess.cpp | 10 +++++----- src/GameCardProcess.h | 2 +- src/IniProcess.cpp | 2 +- src/NcaProcess.cpp | 27 +++++++++++++++------------ src/NcaProcess.h | 8 ++++---- src/PfsProcess.cpp | 8 ++++---- src/PfsProcess.h | 4 ++-- src/RomfsProcess.cpp | 4 ++-- src/RomfsProcess.h | 2 +- src/Settings.cpp | 4 ++-- 17 files changed, 47 insertions(+), 44 deletions(-) diff --git a/deps/libnintendo-es b/deps/libnintendo-es index 984c7e6..4c230fc 160000 --- a/deps/libnintendo-es +++ b/deps/libnintendo-es @@ -1 +1 @@ -Subproject commit 984c7e6d80729eb59035932815c00e1ad614ef77 +Subproject commit 4c230fc27636940e58f2790ad9de1abbe849f22c diff --git a/deps/libnintendo-hac b/deps/libnintendo-hac index 64adf7e..1ceb8e2 160000 --- a/deps/libnintendo-hac +++ b/deps/libnintendo-hac @@ -1 +1 @@ -Subproject commit 64adf7e5ee46355270e370231ea933ed82509915 +Subproject commit 1ceb8e2a147db1cd3084fda4cd1a686c6afa0c4b diff --git a/deps/libnintendo-hac-hb b/deps/libnintendo-hac-hb index 0635b0c..c219873 160000 --- a/deps/libnintendo-hac-hb +++ b/deps/libnintendo-hac-hb @@ -1 +1 @@ -Subproject commit 0635b0c532f4ef152506775c930b3d45f575a14c +Subproject commit c21987316da2d0497f58823898b9295cf7d75ed5 diff --git a/deps/libnintendo-pki b/deps/libnintendo-pki index 87fdd1b..c75a7df 160000 --- a/deps/libnintendo-pki +++ b/deps/libnintendo-pki @@ -1 +1 @@ -Subproject commit 87fdd1be853013a95116c107520078ece7869881 +Subproject commit c75a7df0aeef430e47e1e3693eb131b705cc4bd1 diff --git a/deps/libtoolchain b/deps/libtoolchain index ec41443..4beacd6 160000 --- a/deps/libtoolchain +++ b/deps/libtoolchain @@ -1 +1 @@ -Subproject commit ec4144330589b96c53adc10dac36f654821327a0 +Subproject commit 4beacd6ece086b2c930367cfbe241abcc6170c39 diff --git a/src/FsProcess.cpp b/src/FsProcess.cpp index 3d64edc..ce5d508 100644 --- a/src/FsProcess.cpp +++ b/src/FsProcess.cpp @@ -49,7 +49,7 @@ void nstool::FsProcess::process() } } -void nstool::FsProcess::setInputFileSystem(const std::shared_ptr& input_fs) +void nstool::FsProcess::setInputFileSystem(const std::shared_ptr& input_fs) { mInputFs = input_fs; } @@ -227,7 +227,7 @@ void nstool::FsProcess::extractFs() //fmt::print("Valid File Path: \"{:s}\"\n", path_str); // the output path for this file will depend on the user specified extract path - std::shared_ptr local_fs = std::make_shared(tc::io::LocalStorage()); + std::shared_ptr local_fs = std::make_shared(tc::io::LocalFileSystem()); // case: the extract_path is a valid path to an existing directory // behaviour: extract the file, preserving the original filename, to the specified directory @@ -317,7 +317,7 @@ void nstool::FsProcess::extractFs() void nstool::FsProcess::visitDir(const tc::io::Path& v_path, const tc::io::Path& l_path, bool extract_fs, bool print_fs) { - tc::io::LocalStorage local_fs; + tc::io::LocalFileSystem local_fs; // get listing for directory tc::io::sDirectoryListing info; diff --git a/src/FsProcess.h b/src/FsProcess.h index 61210eb..285595a 100644 --- a/src/FsProcess.h +++ b/src/FsProcess.h @@ -14,7 +14,7 @@ public: void process(); - void setInputFileSystem(const std::shared_ptr& input_fs); + void setInputFileSystem(const std::shared_ptr& input_fs); void setFsFormatName(const std::string& fs_format_name); void setFsProperties(const std::vector& properties); void setShowFsInfo(bool show_fs_info); @@ -25,7 +25,7 @@ public: private: std::string mModuleLabel; - std::shared_ptr mInputFs; + std::shared_ptr mInputFs; // fs info tc::Optional mFsFormatName; diff --git a/src/GameCardProcess.cpp b/src/GameCardProcess.cpp index ed0f3cd..5b628a7 100644 --- a/src/GameCardProcess.cpp +++ b/src/GameCardProcess.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include "FsProcess.h" @@ -272,15 +272,15 @@ void nstool::GameCardProcess::processRootPfs() std::shared_ptr gc_fs_raw = std::make_shared(tc::io::SubStream(mFile, mHdr.getPartitionFsAddress(), nn::hac::GameCardUtil::blockToAddr(mHdr.getValidDataEndPage()+1) - mHdr.getPartitionFsAddress())); - auto gc_vfs_meta = nn::hac::GameCardFsMetaGenerator(gc_fs_raw, mHdr.getPartitionFsSize(), mVerify ? nn::hac::GameCardFsMetaGenerator::ValidationMode_Warn : nn::hac::GameCardFsMetaGenerator::ValidationMode_None); - mFileSystem = std::make_shared(tc::io::VirtualFileSystem(gc_vfs_meta) ); + auto gc_vfs_snapshot = nn::hac::GameCardFsSnapshotGenerator(gc_fs_raw, mHdr.getPartitionFsSize(), mVerify ? nn::hac::GameCardFsSnapshotGenerator::ValidationMode_Warn : nn::hac::GameCardFsSnapshotGenerator::ValidationMode_None); + mFileSystem = std::make_shared(tc::io::VirtualFileSystem(gc_vfs_snapshot) ); mFsProcess.setInputFileSystem(mFileSystem); mFsProcess.setFsFormatName("PartitionFs"); mFsProcess.setFsProperties({ fmt::format("Type: Nested HFS0"), - fmt::format("DirNum: {:d}", gc_vfs_meta.dir_entries.empty() ? 0 : gc_vfs_meta.dir_entries.size() - 1), // -1 to not include root directory - fmt::format("FileNum: {:d}", gc_vfs_meta.file_entries.size()) + fmt::format("DirNum: {:d}", gc_vfs_snapshot.dir_entries.empty() ? 0 : gc_vfs_snapshot.dir_entries.size() - 1), // -1 to not include root directory + fmt::format("FileNum: {:d}", gc_vfs_snapshot.file_entries.size()) }); mFsProcess.setShowFsInfo(mCliOutputMode.show_basic_info); mFsProcess.setFsRootLabel(kXciMountPointName); diff --git a/src/GameCardProcess.h b/src/GameCardProcess.h index 7fe9f63..c20e39a 100644 --- a/src/GameCardProcess.h +++ b/src/GameCardProcess.h @@ -43,7 +43,7 @@ private: nn::hac::GameCardHeader mHdr; // fs processing - std::shared_ptr mFileSystem; + std::shared_ptr mFileSystem; FsProcess mFsProcess; void importHeader(); diff --git a/src/IniProcess.cpp b/src/IniProcess.cpp index cf329c8..b6fbda2 100644 --- a/src/IniProcess.cpp +++ b/src/IniProcess.cpp @@ -121,7 +121,7 @@ void nstool::IniProcess::extractKipList() tc::ByteData cache = tc::ByteData(kCacheSize); // make extract dir - tc::io::LocalStorage local_fs; + tc::io::LocalFileSystem local_fs; local_fs.createDirectory(mKipExtractPath.get()); // out path for extracted KIP diff --git a/src/NcaProcess.cpp b/src/NcaProcess.cpp index 7ad3e66..e7a8068 100644 --- a/src/NcaProcess.cpp +++ b/src/NcaProcess.cpp @@ -8,9 +8,9 @@ #include #include #include -#include -#include -#include +#include +#include +#include #include #include @@ -89,7 +89,7 @@ void nstool::NcaProcess::setExtractJobs(const std::vector& e mFsProcess.setExtractJobs(extract_jobs); } -const std::shared_ptr& nstool::NcaProcess::getFileSystem() const +const std::shared_ptr& nstool::NcaProcess::getFileSystem() const { return mFileSystem; } @@ -270,6 +270,8 @@ void nstool::NcaProcess::generatePartitionConfiguration() // handle partition encryption and partition compaction (sparse layer) if (fs_header.sparse_info.generation.unwrap() != 0) { + fmt::print("Sparsy\n"); +#if 0 if (fs_header.sparse_info.bucket.header.st_magic.unwrap() != nn::hac::bktr::kBktrStructMagic) { throw tc::Exception(mModuleName, fmt::format("SparseInfo BucketTree header had invalid magic ID.")); @@ -454,6 +456,7 @@ void nstool::NcaProcess::generatePartitionConfiguration() // create logical partition //info.reader = std::make_shared(nn::hac::SparseStorageStream(data_stream, info.size, bucket_tree)); } +#endif } else { @@ -511,12 +514,12 @@ void nstool::NcaProcess::generatePartitionConfiguration() switch (info.format_type) { case (nn::hac::nca::FormatType::PartitionFs): - info.fs_meta = nn::hac::PartitionFsMetaGenerator(info.reader); - info.fs_reader = std::make_shared(tc::io::VirtualFileSystem(info.fs_meta)); + info.fs_snapshot = nn::hac::PartitionFsSnapshotGenerator(info.reader); + info.fs_reader = std::make_shared(tc::io::VirtualFileSystem(info.fs_snapshot)); break; case (nn::hac::nca::FormatType::RomFs): - info.fs_meta = nn::hac::RomFsMetaGenerator(info.reader); - info.fs_reader = std::make_shared(tc::io::VirtualFileSystem(info.fs_meta)); + info.fs_snapshot = nn::hac::RomFsSnapshotGenerator(info.reader); + info.fs_reader = std::make_shared(tc::io::VirtualFileSystem(info.fs_snapshot)); break; default: throw tc::Exception(mModuleName, fmt::format("FormatType({:s}): UNKNOWN", nn::hac::ContentArchiveUtil::getFormatTypeAsString(info.format_type))); @@ -705,7 +708,7 @@ void nstool::NcaProcess::displayHeader() void nstool::NcaProcess::processPartitions() { - std::vector mount_points; + std::vector mount_points; for (size_t i = 0; i < mHdr.getPartitionEntryList().size(); i++) { @@ -736,12 +739,12 @@ void nstool::NcaProcess::processPartitions() mount_point_name = fmt::format("{:d}", index); } - mount_points.push_back( { mount_point_name, partition.fs_meta } ); + mount_points.push_back( { mount_point_name, partition.fs_snapshot } ); } - tc::io::VirtualFileSystem::FileSystemMeta fs_meta = nn::hac::CombinedFsMetaGenerator(mount_points); + tc::io::VirtualFileSystem::FileSystemSnapshot fs_snapshot = nn::hac::CombinedFsSnapshotGenerator(mount_points); - std::shared_ptr nca_fs = std::make_shared(tc::io::VirtualFileSystem(fs_meta)); + std::shared_ptr nca_fs = std::make_shared(tc::io::VirtualFileSystem(fs_snapshot)); mFsProcess.setInputFileSystem(nca_fs); mFsProcess.setFsFormatName("ContentArchive"); diff --git a/src/NcaProcess.h b/src/NcaProcess.h index 18bc449..097ac26 100644 --- a/src/NcaProcess.h +++ b/src/NcaProcess.h @@ -29,7 +29,7 @@ public: void setExtractJobs(const std::vector& extract_jobs); // post process() get FS out - const std::shared_ptr& getFileSystem() const; + const std::shared_ptr& getFileSystem() const; private: const std::string kNpdmExefsPath = "/main.npdm"; @@ -42,7 +42,7 @@ private: bool mVerify; // fs processing - std::shared_ptr mFileSystem; + std::shared_ptr mFileSystem; FsProcess mFsProcess; // nca data @@ -95,8 +95,8 @@ private: struct sPartitionInfo { std::shared_ptr reader; - tc::io::VirtualFileSystem::FileSystemMeta fs_meta; - std::shared_ptr fs_reader; + tc::io::VirtualFileSystem::FileSystemSnapshot fs_snapshot; + std::shared_ptr fs_reader; std::string fail_reason; int64_t offset; int64_t size; diff --git a/src/PfsProcess.cpp b/src/PfsProcess.cpp index 9f69d2d..8dba77d 100644 --- a/src/PfsProcess.cpp +++ b/src/PfsProcess.cpp @@ -2,10 +2,10 @@ #include "util.h" #include -#include +#include #include -#include +#include nstool::PfsProcess::PfsProcess() : @@ -62,7 +62,7 @@ void nstool::PfsProcess::process() mPfs.fromBytes(scratch.data(), scratch.size()); // create virtual filesystem - mFileSystem = std::make_shared(tc::io::VirtualFileSystem(nn::hac::PartitionFsMetaGenerator(mFile, mVerify ? nn::hac::PartitionFsMetaGenerator::ValidationMode_Warn : nn::hac::PartitionFsMetaGenerator::ValidationMode_None))); + mFileSystem = std::make_shared(tc::io::VirtualFileSystem(nn::hac::PartitionFsSnapshotGenerator(mFile, mVerify ? nn::hac::PartitionFsSnapshotGenerator::ValidationMode_Warn : nn::hac::PartitionFsSnapshotGenerator::ValidationMode_None))); mFsProcess.setInputFileSystem(mFileSystem); // set properties for FsProcess @@ -115,7 +115,7 @@ const nn::hac::PartitionFsHeader& nstool::PfsProcess::getPfsHeader() const return mPfs; } -const std::shared_ptr& nstool::PfsProcess::getFileSystem() const +const std::shared_ptr& nstool::PfsProcess::getFileSystem() const { return mFileSystem; } diff --git a/src/PfsProcess.h b/src/PfsProcess.h index ca69028..c5f8f56 100644 --- a/src/PfsProcess.h +++ b/src/PfsProcess.h @@ -26,7 +26,7 @@ public: // post process() get PFS/FS out const nn::hac::PartitionFsHeader& getPfsHeader() const; - const std::shared_ptr& getFileSystem() const; + const std::shared_ptr& getFileSystem() const; private: static const size_t kCacheSize = 0x10000; @@ -39,7 +39,7 @@ private: nn::hac::PartitionFsHeader mPfs; - std::shared_ptr mFileSystem; + std::shared_ptr mFileSystem; FsProcess mFsProcess; size_t determineHeaderSize(const nn::hac::sPfsHeader* hdr); diff --git a/src/RomfsProcess.cpp b/src/RomfsProcess.cpp index 2a80bdf..d004a0b 100644 --- a/src/RomfsProcess.cpp +++ b/src/RomfsProcess.cpp @@ -2,7 +2,7 @@ #include "util.h" #include -#include +#include nstool::RomfsProcess::RomfsProcess() : @@ -83,7 +83,7 @@ void nstool::RomfsProcess::process() } // create virtual filesystem - mFileSystem = std::make_shared(tc::io::VirtualFileSystem(nn::hac::RomFsMetaGenerator(mFile))); + mFileSystem = std::make_shared(tc::io::VirtualFileSystem(nn::hac::RomFsSnapshotGenerator(mFile))); mFsProcess.setInputFileSystem(mFileSystem); // set properties for FsProcess diff --git a/src/RomfsProcess.h b/src/RomfsProcess.h index 4597c20..f2ee3a7 100644 --- a/src/RomfsProcess.h +++ b/src/RomfsProcess.h @@ -36,7 +36,7 @@ private: size_t mDirNum; size_t mFileNum; - std::shared_ptr mFileSystem; + std::shared_ptr mFileSystem; FsProcess mFsProcess; }; diff --git a/src/Settings.cpp b/src/Settings.cpp index 543dcfb..a017a09 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -1176,8 +1176,8 @@ bool nstool::SettingsInitializer::determineValidEsTikFromSample(const tc::ByteDa const nn::es::sTicketBody_v2* body = (const nn::es::sTicketBody_v2*)(sample.data() + sign.getBytes().size()); - if ((body->issuer.str().substr(0, 5) == "Root-" - && body->issuer.str().substr(16, 2) == "XS") == false) + if ((body->issuer.decode().substr(0, 5) == "Root-" + && body->issuer.decode().substr(16, 2) == "XS") == false) return false; return true;