[hac|nstool] Renamed hac::PfsHeader to hac::PartitionFsHeader.

This commit is contained in:
jakcron 2018-10-27 13:43:57 +08:00
parent 24e2fc5e77
commit 364a3880f1
8 changed files with 96 additions and 96 deletions

View file

@ -9,7 +9,7 @@ namespace nn
{ {
namespace hac namespace hac
{ {
class PfsHeader : class PartitionFsHeader :
public fnd::IByteModel public fnd::IByteModel
{ {
public: public:
@ -62,12 +62,12 @@ namespace hac
} }
}; };
PfsHeader(); PartitionFsHeader();
PfsHeader(const PfsHeader& other); PartitionFsHeader(const PartitionFsHeader& other);
void operator=(const PfsHeader& other); void operator=(const PartitionFsHeader& other);
bool operator==(const PfsHeader& other) const; bool operator==(const PartitionFsHeader& other) const;
bool operator!=(const PfsHeader& other) const; bool operator!=(const PartitionFsHeader& other) const;
// IByteModel // IByteModel
void toBytes(); 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); void addFile(const std::string& name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash);
private: private:
const std::string kModuleName = "PFS_HEADER"; const std::string kModuleName = "PARTITIONFS_HEADER";
// binary blob // binary blob
fnd::Vec<byte_t> mRawBinary; fnd::Vec<byte_t> mRawBinary;

View file

@ -74,8 +74,8 @@
<ClInclude Include="include\nn\hac\MiscParamsHandler.h" /> <ClInclude Include="include\nn\hac\MiscParamsHandler.h" />
<ClInclude Include="include\nn\hac\NroHeader.h" /> <ClInclude Include="include\nn\hac\NroHeader.h" />
<ClInclude Include="include\nn\hac\NsoHeader.h" /> <ClInclude Include="include\nn\hac\NsoHeader.h" />
<ClInclude Include="include\nn\hac\PartitionFsHeader.h" />
<ClInclude Include="include\nn\hac\PatchMetaExtendedHeader.h" /> <ClInclude Include="include\nn\hac\PatchMetaExtendedHeader.h" />
<ClInclude Include="include\nn\hac\PfsHeader.h" />
<ClInclude Include="include\nn\hac\Result.h" /> <ClInclude Include="include\nn\hac\Result.h" />
<ClInclude Include="include\nn\hac\ServiceAccessControl.h" /> <ClInclude Include="include\nn\hac\ServiceAccessControl.h" />
<ClInclude Include="include\nn\hac\ServiceAccessControlEntry.h" /> <ClInclude Include="include\nn\hac\ServiceAccessControlEntry.h" />
@ -121,8 +121,8 @@
<ClCompile Include="source\MiscParamsHandler.cpp" /> <ClCompile Include="source\MiscParamsHandler.cpp" />
<ClCompile Include="source\NroHeader.cpp" /> <ClCompile Include="source\NroHeader.cpp" />
<ClCompile Include="source\NsoHeader.cpp" /> <ClCompile Include="source\NsoHeader.cpp" />
<ClCompile Include="source\PartitionFsHeader.cpp" />
<ClCompile Include="source\PatchMetaExtendedHeader.cpp" /> <ClCompile Include="source\PatchMetaExtendedHeader.cpp" />
<ClCompile Include="source\PfsHeader.cpp" />
<ClCompile Include="source\Result.cpp" /> <ClCompile Include="source\Result.cpp" />
<ClCompile Include="source\ServiceAccessControl.cpp" /> <ClCompile Include="source\ServiceAccessControl.cpp" />
<ClCompile Include="source\ServiceAccessControlEntry.cpp" /> <ClCompile Include="source\ServiceAccessControlEntry.cpp" />

View file

@ -15,6 +15,57 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="include\nn\hac\define\aci.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\cnmt.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\delta.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\fac.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\hierarchicalintegrity.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\hierarchicalsha256.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\kc.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\macro.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\meta.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nacp.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nca.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nro.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nrr.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nso.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\pfs.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\romfs.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\xci.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\AccessControlInfo.h"> <ClInclude Include="include\nn\hac\AccessControlInfo.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -120,10 +171,10 @@
<ClInclude Include="include\nn\hac\NsoHeader.h"> <ClInclude Include="include\nn\hac\NsoHeader.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\nn\hac\PatchMetaExtendedHeader.h"> <ClInclude Include="include\nn\hac\PartitionFsHeader.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\nn\hac\PfsHeader.h"> <ClInclude Include="include\nn\hac\PatchMetaExtendedHeader.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\nn\hac\Result.h"> <ClInclude Include="include\nn\hac\Result.h">
@ -153,57 +204,6 @@
<ClInclude Include="include\nn\hac\XciUtils.h"> <ClInclude Include="include\nn\hac\XciUtils.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\nn\hac\define\aci.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\cnmt.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\delta.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\fac.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\hierarchicalintegrity.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\hierarchicalsha256.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\kc.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\macro.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\meta.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nacp.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nca.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nro.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nrr.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\nso.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\pfs.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\romfs.h">
<Filter>Header Files\define</Filter>
</ClInclude>
<ClInclude Include="include\nn\hac\define\xci.h">
<Filter>Header Files\define</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="source\AccessControlInfo.cpp"> <ClCompile Include="source\AccessControlInfo.cpp">
@ -308,10 +308,10 @@
<ClCompile Include="source\NsoHeader.cpp"> <ClCompile Include="source\NsoHeader.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\PatchMetaExtendedHeader.cpp"> <ClCompile Include="source\PartitionFsHeader.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\PfsHeader.cpp"> <ClCompile Include="source\PatchMetaExtendedHeader.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\Result.cpp"> <ClCompile Include="source\Result.cpp">

View file

@ -1,16 +1,16 @@
#include <nn/hac/PfsHeader.h> #include <nn/hac/PartitionFsHeader.h>
nn::hac::PfsHeader::PfsHeader() nn::hac::PartitionFsHeader::PartitionFsHeader()
{ {
clear(); clear();
} }
nn::hac::PfsHeader::PfsHeader(const PfsHeader & other) nn::hac::PartitionFsHeader::PartitionFsHeader(const PartitionFsHeader & other)
{ {
*this = other; *this = other;
} }
void nn::hac::PfsHeader::operator=(const PfsHeader & other) void nn::hac::PartitionFsHeader::operator=(const PartitionFsHeader & other)
{ {
if (other.getBytes().size()) 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) \ return (mFsType == other.mFsType) \
&& (mFileList == other.mFileList); && (mFileList == other.mFileList);
} }
bool nn::hac::PfsHeader::operator!=(const PfsHeader & other) const bool nn::hac::PartitionFsHeader::operator!=(const PartitionFsHeader & other) const
{ {
return !(*this == other); return !(*this == other);
} }
const fnd::Vec<byte_t>& nn::hac::PfsHeader::getBytes() const const fnd::Vec<byte_t>& nn::hac::PartitionFsHeader::getBytes() const
{ {
return mRawBinary; return mRawBinary;
} }
void nn::hac::PfsHeader::toBytes() void nn::hac::PartitionFsHeader::toBytes()
{ {
// calculate name table size // calculate name table size
size_t name_table_size = 0; 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 // check input length meets minimum size
if (len < sizeof(sPfsHeader)) 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(); mRawBinary.clear();
mFsType = TYPE_PFS0; mFsType = TYPE_PFS0;
mFileList.clear(); mFileList.clear();
} }
nn::hac::PfsHeader::FsType nn::hac::PfsHeader::getFsType() const nn::hac::PartitionFsHeader::FsType nn::hac::PartitionFsHeader::getFsType() const
{ {
return mFsType; return mFsType;
} }
void nn::hac::PfsHeader::setFsType(FsType type) void nn::hac::PartitionFsHeader::setFsType(FsType type)
{ {
mFsType = type; mFsType = type;
} }
const fnd::List<nn::hac::PfsHeader::sFile>& nn::hac::PfsHeader::getFileList() const const fnd::List<nn::hac::PartitionFsHeader::sFile>& nn::hac::PartitionFsHeader::getFileList() const
{ {
return mFileList; 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 }); 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 }); 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; size_t size = 0;
switch(fs_type) switch(fs_type)
@ -244,7 +244,7 @@ size_t nn::hac::PfsHeader::getFileEntrySize(FsType fs_type)
return size; 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++) for (size_t i = 0; i < mFileList.size(); i++)
{ {

View file

@ -410,7 +410,7 @@ void NcaProcess::validateNcaSignatures()
// open main.npdm // open main.npdm
if (exefs.getPfsHeader().getFileList().hasElement(kNpdmExefsPath) == true) 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; MetaProcess npdm;
npdm.setInputFile(new fnd::OffsetAdjustedIFile(mPartitions[nn::hac::nca::PARTITION_CODE].reader, file.offset, file.size)); npdm.setInputFile(new fnd::OffsetAdjustedIFile(mPartitions[nn::hac::nca::PARTITION_CODE].reader, file.offset, file.size));

View file

@ -63,7 +63,7 @@ void PfsProcess::setListFs(bool list_fs)
mListFs = list_fs; mListFs = list_fs;
} }
const nn::hac::PfsHeader& PfsProcess::getPfsHeader() const const nn::hac::PartitionFsHeader& PfsProcess::getPfsHeader() const
{ {
return mPfs; return mPfs;
} }
@ -110,16 +110,16 @@ void PfsProcess::displayFs()
{ {
for (size_t i = 0; i < mPfs.getFileList().size(); i++) 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; std::cout << " " << file.name;
if (_HAS_BIT(mCliOutputMode, OUTPUT_LAYOUT)) if (_HAS_BIT(mCliOutputMode, OUTPUT_LAYOUT))
{ {
switch (mPfs.getFsType()) 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 << ")"; std::cout << std::hex << " (offset=0x" << file.offset << ", size=0x" << file.size << ")";
break; 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 << ")"; std::cout << std::hex << " (offset=0x" << file.offset << ", size=0x" << file.size << ", hash_protected_size=0x" << file.hash_protected_size << ")";
break; break;
} }
@ -148,7 +148,7 @@ bool PfsProcess::validateHeaderMagic(const nn::hac::sPfsHeader* hdr)
void PfsProcess::validateHfs() void PfsProcess::validateHfs()
{ {
fnd::sha::sSha256Hash hash; fnd::sha::sSha256Hash hash;
const fnd::List<nn::hac::PfsHeader::sFile>& file = mPfs.getFileList(); const fnd::List<nn::hac::PartitionFsHeader::sFile>& file = mPfs.getFileList();
for (size_t i = 0; i < file.size(); i++) for (size_t i = 0; i < file.size(); i++)
{ {
mCache.alloc(file[i].hash_protected_size); mCache.alloc(file[i].hash_protected_size);
@ -170,7 +170,7 @@ void PfsProcess::extractFs()
fnd::io::makeDirectory(mExtractPath); fnd::io::makeDirectory(mExtractPath);
fnd::SimpleFile outFile; fnd::SimpleFile outFile;
const fnd::List<nn::hac::PfsHeader::sFile>& file = mPfs.getFileList(); const fnd::List<nn::hac::PartitionFsHeader::sFile>& file = mPfs.getFileList();
std::string file_path; std::string file_path;
for (size_t i = 0; i < file.size(); i++) 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; const char* str = nullptr;
switch (type) switch (type)
{ {
case (nn::hac::PfsHeader::TYPE_PFS0): case (nn::hac::PartitionFsHeader::TYPE_PFS0):
str = "PFS0"; str = "PFS0";
break; break;
case (nn::hac::PfsHeader::TYPE_HFS0): case (nn::hac::PartitionFsHeader::TYPE_HFS0):
str = "HFS0"; str = "HFS0";
break; break;
default: default:

View file

@ -3,7 +3,7 @@
#include <fnd/types.h> #include <fnd/types.h>
#include <fnd/IFile.h> #include <fnd/IFile.h>
#include <fnd/SharedPtr.h> #include <fnd/SharedPtr.h>
#include <nn/hac/PfsHeader.h> #include <nn/hac/PartitionFsHeader.h>
#include "common.h" #include "common.h"
@ -24,7 +24,7 @@ public:
void setExtractPath(const std::string& path); void setExtractPath(const std::string& path);
void setListFs(bool list_fs); void setListFs(bool list_fs);
const nn::hac::PfsHeader& getPfsHeader() const; const nn::hac::PartitionFsHeader& getPfsHeader() const;
private: private:
const std::string kModuleName = "PfsProcess"; const std::string kModuleName = "PfsProcess";
@ -41,7 +41,7 @@ private:
fnd::Vec<byte_t> mCache; fnd::Vec<byte_t> mCache;
nn::hac::PfsHeader mPfs; nn::hac::PartitionFsHeader mPfs;
void importHeader(); void importHeader();
void displayHeader(); void displayHeader();
@ -51,5 +51,5 @@ private:
void validateHfs(); void validateHfs();
void extractFs(); void extractFs();
const char* getFsTypeStr(nn::hac::PfsHeader::FsType type) const; const char* getFsTypeStr(nn::hac::PartitionFsHeader::FsType type) const;
}; };

View file

@ -216,7 +216,7 @@ void XciProcess::processRootPfs()
void XciProcess::processPartitionPfs() void XciProcess::processPartitionPfs()
{ {
const fnd::List<nn::hac::PfsHeader::sFile>& rootPartitions = mRootPfs.getPfsHeader().getFileList(); const fnd::List<nn::hac::PartitionFsHeader::sFile>& rootPartitions = mRootPfs.getPfsHeader().getFileList();
for (size_t i = 0; i < rootPartitions.size(); i++) 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 // this must be validated here because only the size of the root partiton header is known at verification time