diff --git a/lib/libhac/include/nn/hac/PfsHeader.h b/lib/libhac/include/nn/hac/PartitionFsHeader.h similarity index 84% rename from lib/libhac/include/nn/hac/PfsHeader.h rename to lib/libhac/include/nn/hac/PartitionFsHeader.h index 8a3e660..94fad7a 100644 --- a/lib/libhac/include/nn/hac/PfsHeader.h +++ b/lib/libhac/include/nn/hac/PartitionFsHeader.h @@ -9,7 +9,7 @@ namespace nn { namespace hac { - class PfsHeader : + class PartitionFsHeader : public fnd::IByteModel { public: @@ -62,12 +62,12 @@ namespace hac } }; - PfsHeader(); - PfsHeader(const PfsHeader& other); + PartitionFsHeader(); + PartitionFsHeader(const PartitionFsHeader& other); - void operator=(const PfsHeader& other); - bool operator==(const PfsHeader& other) const; - bool operator!=(const PfsHeader& other) const; + void operator=(const PartitionFsHeader& other); + bool operator==(const PartitionFsHeader& other) const; + bool operator!=(const PartitionFsHeader& other) const; // IByteModel void toBytes(); @@ -84,7 +84,7 @@ namespace hac void addFile(const std::string& name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash); private: - const std::string kModuleName = "PFS_HEADER"; + const std::string kModuleName = "PARTITIONFS_HEADER"; // binary blob fnd::Vec mRawBinary; diff --git a/lib/libhac/libhac.vcxproj b/lib/libhac/libhac.vcxproj index 5b505ba..46790e8 100644 --- a/lib/libhac/libhac.vcxproj +++ b/lib/libhac/libhac.vcxproj @@ -74,8 +74,8 @@ + - @@ -121,8 +121,8 @@ + - diff --git a/lib/libhac/libhac.vcxproj.filters b/lib/libhac/libhac.vcxproj.filters index 5dacb3e..67d059e 100644 --- a/lib/libhac/libhac.vcxproj.filters +++ b/lib/libhac/libhac.vcxproj.filters @@ -15,6 +15,57 @@ + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + + + Header Files\define + Header Files @@ -120,10 +171,10 @@ Header Files - + Header Files - + Header Files @@ -153,57 +204,6 @@ Header Files - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - - - Header Files\define - @@ -308,10 +308,10 @@ Source Files - + Source Files - + Source Files diff --git a/lib/libhac/source/PfsHeader.cpp b/lib/libhac/source/PartitionFsHeader.cpp similarity index 82% rename from lib/libhac/source/PfsHeader.cpp rename to lib/libhac/source/PartitionFsHeader.cpp index 14cd2ec..1e4a431 100644 --- a/lib/libhac/source/PfsHeader.cpp +++ b/lib/libhac/source/PartitionFsHeader.cpp @@ -1,16 +1,16 @@ -#include +#include -nn::hac::PfsHeader::PfsHeader() +nn::hac::PartitionFsHeader::PartitionFsHeader() { clear(); } -nn::hac::PfsHeader::PfsHeader(const PfsHeader & other) +nn::hac::PartitionFsHeader::PartitionFsHeader(const PartitionFsHeader & other) { *this = other; } -void nn::hac::PfsHeader::operator=(const PfsHeader & other) +void nn::hac::PartitionFsHeader::operator=(const PartitionFsHeader & other) { if (other.getBytes().size()) { @@ -24,24 +24,24 @@ void nn::hac::PfsHeader::operator=(const PfsHeader & other) } } -bool nn::hac::PfsHeader::operator==(const PfsHeader & other) const +bool nn::hac::PartitionFsHeader::operator==(const PartitionFsHeader & other) const { return (mFsType == other.mFsType) \ && (mFileList == other.mFileList); } -bool nn::hac::PfsHeader::operator!=(const PfsHeader & other) const +bool nn::hac::PartitionFsHeader::operator!=(const PartitionFsHeader & other) const { return !(*this == other); } -const fnd::Vec& nn::hac::PfsHeader::getBytes() const +const fnd::Vec& nn::hac::PartitionFsHeader::getBytes() const { return mRawBinary; } -void nn::hac::PfsHeader::toBytes() +void nn::hac::PartitionFsHeader::toBytes() { // calculate name table size size_t name_table_size = 0; @@ -113,7 +113,7 @@ void nn::hac::PfsHeader::toBytes() } -void nn::hac::PfsHeader::fromBytes(const byte_t* data, size_t len) +void nn::hac::PartitionFsHeader::fromBytes(const byte_t* data, size_t len) { // check input length meets minimum size if (len < sizeof(sPfsHeader)) @@ -195,39 +195,39 @@ void nn::hac::PfsHeader::fromBytes(const byte_t* data, size_t len) } -void nn::hac::PfsHeader::clear() +void nn::hac::PartitionFsHeader::clear() { mRawBinary.clear(); mFsType = TYPE_PFS0; mFileList.clear(); } -nn::hac::PfsHeader::FsType nn::hac::PfsHeader::getFsType() const +nn::hac::PartitionFsHeader::FsType nn::hac::PartitionFsHeader::getFsType() const { return mFsType; } -void nn::hac::PfsHeader::setFsType(FsType type) +void nn::hac::PartitionFsHeader::setFsType(FsType type) { mFsType = type; } -const fnd::List& nn::hac::PfsHeader::getFileList() const +const fnd::List& nn::hac::PartitionFsHeader::getFileList() const { return mFileList; } -void nn::hac::PfsHeader::addFile(const std::string & name, size_t size) +void nn::hac::PartitionFsHeader::addFile(const std::string & name, size_t size) { mFileList.addElement({ name, 0, size, 0 }); } -void nn::hac::PfsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash) +void nn::hac::PartitionFsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash) { mFileList.addElement({ name, 0, size, hash_protected_size, hash }); } -size_t nn::hac::PfsHeader::getFileEntrySize(FsType fs_type) +size_t nn::hac::PartitionFsHeader::getFileEntrySize(FsType fs_type) { size_t size = 0; switch(fs_type) @@ -244,7 +244,7 @@ size_t nn::hac::PfsHeader::getFileEntrySize(FsType fs_type) return size; } -void nn::hac::PfsHeader::calculateOffsets(size_t data_offset) +void nn::hac::PartitionFsHeader::calculateOffsets(size_t data_offset) { for (size_t i = 0; i < mFileList.size(); i++) { diff --git a/programs/nstool/source/NcaProcess.cpp b/programs/nstool/source/NcaProcess.cpp index d1fa659..fcfb8db 100644 --- a/programs/nstool/source/NcaProcess.cpp +++ b/programs/nstool/source/NcaProcess.cpp @@ -410,7 +410,7 @@ void NcaProcess::validateNcaSignatures() // open main.npdm if (exefs.getPfsHeader().getFileList().hasElement(kNpdmExefsPath) == true) { - const nn::hac::PfsHeader::sFile& file = exefs.getPfsHeader().getFileList().getElement(kNpdmExefsPath); + const nn::hac::PartitionFsHeader::sFile& file = exefs.getPfsHeader().getFileList().getElement(kNpdmExefsPath); MetaProcess npdm; npdm.setInputFile(new fnd::OffsetAdjustedIFile(mPartitions[nn::hac::nca::PARTITION_CODE].reader, file.offset, file.size)); diff --git a/programs/nstool/source/PfsProcess.cpp b/programs/nstool/source/PfsProcess.cpp index 999b487..3661fd1 100644 --- a/programs/nstool/source/PfsProcess.cpp +++ b/programs/nstool/source/PfsProcess.cpp @@ -63,7 +63,7 @@ void PfsProcess::setListFs(bool list_fs) mListFs = list_fs; } -const nn::hac::PfsHeader& PfsProcess::getPfsHeader() const +const nn::hac::PartitionFsHeader& PfsProcess::getPfsHeader() const { return mPfs; } @@ -110,16 +110,16 @@ void PfsProcess::displayFs() { for (size_t i = 0; i < mPfs.getFileList().size(); i++) { - const nn::hac::PfsHeader::sFile& file = mPfs.getFileList()[i]; + const nn::hac::PartitionFsHeader::sFile& file = mPfs.getFileList()[i]; std::cout << " " << file.name; if (_HAS_BIT(mCliOutputMode, OUTPUT_LAYOUT)) { switch (mPfs.getFsType()) { - case (nn::hac::PfsHeader::TYPE_PFS0): + case (nn::hac::PartitionFsHeader::TYPE_PFS0): std::cout << std::hex << " (offset=0x" << file.offset << ", size=0x" << file.size << ")"; break; - case (nn::hac::PfsHeader::TYPE_HFS0): + case (nn::hac::PartitionFsHeader::TYPE_HFS0): std::cout << std::hex << " (offset=0x" << file.offset << ", size=0x" << file.size << ", hash_protected_size=0x" << file.hash_protected_size << ")"; break; } @@ -148,7 +148,7 @@ bool PfsProcess::validateHeaderMagic(const nn::hac::sPfsHeader* hdr) void PfsProcess::validateHfs() { fnd::sha::sSha256Hash hash; - const fnd::List& file = mPfs.getFileList(); + const fnd::List& file = mPfs.getFileList(); for (size_t i = 0; i < file.size(); i++) { mCache.alloc(file[i].hash_protected_size); @@ -170,7 +170,7 @@ void PfsProcess::extractFs() fnd::io::makeDirectory(mExtractPath); fnd::SimpleFile outFile; - const fnd::List& file = mPfs.getFileList(); + const fnd::List& file = mPfs.getFileList(); std::string file_path; for (size_t i = 0; i < file.size(); i++) @@ -193,16 +193,16 @@ void PfsProcess::extractFs() } } -const char* PfsProcess::getFsTypeStr(nn::hac::PfsHeader::FsType type) const +const char* PfsProcess::getFsTypeStr(nn::hac::PartitionFsHeader::FsType type) const { const char* str = nullptr; switch (type) { - case (nn::hac::PfsHeader::TYPE_PFS0): + case (nn::hac::PartitionFsHeader::TYPE_PFS0): str = "PFS0"; break; - case (nn::hac::PfsHeader::TYPE_HFS0): + case (nn::hac::PartitionFsHeader::TYPE_HFS0): str = "HFS0"; break; default: diff --git a/programs/nstool/source/PfsProcess.h b/programs/nstool/source/PfsProcess.h index bf9d61c..d49ba9a 100644 --- a/programs/nstool/source/PfsProcess.h +++ b/programs/nstool/source/PfsProcess.h @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "common.h" @@ -24,7 +24,7 @@ public: void setExtractPath(const std::string& path); void setListFs(bool list_fs); - const nn::hac::PfsHeader& getPfsHeader() const; + const nn::hac::PartitionFsHeader& getPfsHeader() const; private: const std::string kModuleName = "PfsProcess"; @@ -41,7 +41,7 @@ private: fnd::Vec mCache; - nn::hac::PfsHeader mPfs; + nn::hac::PartitionFsHeader mPfs; void importHeader(); void displayHeader(); @@ -51,5 +51,5 @@ private: void validateHfs(); void extractFs(); - const char* getFsTypeStr(nn::hac::PfsHeader::FsType type) const; + const char* getFsTypeStr(nn::hac::PartitionFsHeader::FsType type) const; }; \ No newline at end of file diff --git a/programs/nstool/source/XciProcess.cpp b/programs/nstool/source/XciProcess.cpp index d86c630..02fd089 100644 --- a/programs/nstool/source/XciProcess.cpp +++ b/programs/nstool/source/XciProcess.cpp @@ -216,7 +216,7 @@ void XciProcess::processRootPfs() void XciProcess::processPartitionPfs() { - const fnd::List& rootPartitions = mRootPfs.getPfsHeader().getFileList(); + const fnd::List& rootPartitions = mRootPfs.getPfsHeader().getFileList(); for (size_t i = 0; i < rootPartitions.size(); i++) { // this must be validated here because only the size of the root partiton header is known at verification time