Merge pull request #54 from jakcron/npdm-meta-refactor

[fac|nstool] Correct name of Npdm to Meta.
This commit is contained in:
Jack 2018-10-07 12:38:58 +08:00 committed by GitHub
commit 125dff0d7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 186 additions and 185 deletions

View file

@ -2,7 +2,7 @@
#include <string> #include <string>
#include <fnd/List.h> #include <fnd/List.h>
#include <fnd/ISerialisable.h> #include <fnd/ISerialisable.h>
#include <nn/hac/npdm.h> #include <nn/hac/meta.h>
#include <nn/hac/AccessControlInfoBinary.h> #include <nn/hac/AccessControlInfoBinary.h>
#include <nn/hac/AccessControlInfoDescBinary.h> #include <nn/hac/AccessControlInfoDescBinary.h>
@ -10,16 +10,16 @@ namespace nn
{ {
namespace hac namespace hac
{ {
class NpdmBinary : class MetaBinary :
public fnd::ISerialisable public fnd::ISerialisable
{ {
public: public:
NpdmBinary(); MetaBinary();
NpdmBinary(const NpdmBinary& other); MetaBinary(const MetaBinary& other);
void operator=(const NpdmBinary& other); void operator=(const MetaBinary& other);
bool operator==(const NpdmBinary& other) const; bool operator==(const MetaBinary& other) const;
bool operator!=(const NpdmBinary& other) const; bool operator!=(const MetaBinary& other) const;
// export/import binary // export/import binary
void toBytes(); void toBytes();
@ -29,11 +29,11 @@ namespace hac
// variables // variables
void clear(); void clear();
npdm::InstructionType getInstructionType() const; meta::InstructionType getInstructionType() const;
void setInstructionType(npdm::InstructionType type); void setInstructionType(meta::InstructionType type);
npdm::ProcAddrSpaceType getProcAddressSpaceType() const; meta::ProcAddrSpaceType getProcAddressSpaceType() const;
void setProcAddressSpaceType(npdm::ProcAddrSpaceType type); void setProcAddressSpaceType(meta::ProcAddrSpaceType type);
byte_t getMainThreadPriority() const; byte_t getMainThreadPriority() const;
void setMainThreadPriority(byte_t priority); void setMainThreadPriority(byte_t priority);
@ -59,14 +59,14 @@ namespace hac
const AccessControlInfoDescBinary& getAcid() const; const AccessControlInfoDescBinary& getAcid() const;
void setAcid(const AccessControlInfoDescBinary& acid); void setAcid(const AccessControlInfoDescBinary& acid);
private: private:
const std::string kModuleName = "NPDM_BINARY"; const std::string kModuleName = "META_BINARY";
// raw binary // raw binary
fnd::Vec<byte_t> mRawBinary; fnd::Vec<byte_t> mRawBinary;
// variables // variables
npdm::InstructionType mInstructionType; meta::InstructionType mInstructionType;
npdm::ProcAddrSpaceType mProcAddressSpaceType; meta::ProcAddrSpaceType mProcAddressSpaceType;
byte_t mMainThreadPriority; byte_t mMainThreadPriority;
byte_t mMainThreadCpuId; byte_t mMainThreadCpuId;
uint32_t mVersion; uint32_t mVersion;

View file

@ -6,9 +6,9 @@ namespace nn
{ {
namespace hac namespace hac
{ {
namespace npdm namespace meta
{ {
static const uint32_t kNpdmStructMagic = _MAKE_STRUCT_MAGIC_U32("META"); static const uint32_t kMetaStructMagic = _MAKE_STRUCT_MAGIC_U32("META");
static const size_t kNameMaxLen = 0x10; static const size_t kNameMaxLen = 0x10;
static const size_t kProductCodeMaxLen = 0x10; static const size_t kProductCodeMaxLen = 0x10;
static const uint32_t kMaxPriority = BIT(6) - 1; static const uint32_t kMaxPriority = BIT(6) - 1;
@ -29,8 +29,13 @@ namespace hac
}; };
} }
#pragma pack(push,1) #pragma pack(push,1)
struct sMetaSection
{
le_uint32_t offset;
le_uint32_t size;
};
struct sNpdmHeader struct sMetaHeader
{ {
le_uint32_t st_magic; le_uint32_t st_magic;
byte_t reserved_0[8]; byte_t reserved_0[8];
@ -41,15 +46,11 @@ namespace hac
byte_t reserved_2[8]; byte_t reserved_2[8];
le_uint32_t version; le_uint32_t version;
le_uint32_t main_thread_stack_size; le_uint32_t main_thread_stack_size;
char name[npdm::kNameMaxLen]; // important char name[meta::kNameMaxLen]; // important
char product_code[npdm::kProductCodeMaxLen]; // can be empty char product_code[meta::kProductCodeMaxLen]; // can be empty
byte_t reserved_3[48]; byte_t reserved_3[48];
// Access Control Info sMetaSection aci;
struct sNpdmSection sMetaSection acid;
{
le_uint32_t offset;
le_uint32_t size;
} aci, acid;
}; };
#pragma pack(pop) #pragma pack(pop)

View file

@ -51,6 +51,8 @@
<ClInclude Include="include\nn\hac\macro.h" /> <ClInclude Include="include\nn\hac\macro.h" />
<ClInclude Include="include\nn\hac\MemoryMappingHandler.h" /> <ClInclude Include="include\nn\hac\MemoryMappingHandler.h" />
<ClInclude Include="include\nn\hac\MemoryPageEntry.h" /> <ClInclude Include="include\nn\hac\MemoryPageEntry.h" />
<ClInclude Include="include\nn\hac\meta.h" />
<ClInclude Include="include\nn\hac\MetaBinary.h" />
<ClInclude Include="include\nn\hac\MiscFlagsEntry.h" /> <ClInclude Include="include\nn\hac\MiscFlagsEntry.h" />
<ClInclude Include="include\nn\hac\MiscFlagsHandler.h" /> <ClInclude Include="include\nn\hac\MiscFlagsHandler.h" />
<ClInclude Include="include\nn\hac\MiscParamsEntry.h" /> <ClInclude Include="include\nn\hac\MiscParamsEntry.h" />
@ -59,8 +61,6 @@
<ClInclude Include="include\nn\hac\nca.h" /> <ClInclude Include="include\nn\hac\nca.h" />
<ClInclude Include="include\nn\hac\NcaHeader.h" /> <ClInclude Include="include\nn\hac\NcaHeader.h" />
<ClInclude Include="include\nn\hac\NcaUtils.h" /> <ClInclude Include="include\nn\hac\NcaUtils.h" />
<ClInclude Include="include\nn\hac\npdm.h" />
<ClInclude Include="include\nn\hac\NpdmBinary.h" />
<ClInclude Include="include\nn\hac\nro.h" /> <ClInclude Include="include\nn\hac\nro.h" />
<ClInclude Include="include\nn\hac\NroHeader.h" /> <ClInclude Include="include\nn\hac\NroHeader.h" />
<ClInclude Include="include\nn\hac\nrr.h" /> <ClInclude Include="include\nn\hac\nrr.h" />
@ -101,13 +101,13 @@
<ClCompile Include="source\KernelVersionHandler.cpp" /> <ClCompile Include="source\KernelVersionHandler.cpp" />
<ClCompile Include="source\MemoryMappingHandler.cpp" /> <ClCompile Include="source\MemoryMappingHandler.cpp" />
<ClCompile Include="source\MemoryPageEntry.cpp" /> <ClCompile Include="source\MemoryPageEntry.cpp" />
<ClCompile Include="source\MetaBinary.cpp" />
<ClCompile Include="source\MiscFlagsEntry.cpp" /> <ClCompile Include="source\MiscFlagsEntry.cpp" />
<ClCompile Include="source\MiscFlagsHandler.cpp" /> <ClCompile Include="source\MiscFlagsHandler.cpp" />
<ClCompile Include="source\MiscParamsEntry.cpp" /> <ClCompile Include="source\MiscParamsEntry.cpp" />
<ClCompile Include="source\MiscParamsHandler.cpp" /> <ClCompile Include="source\MiscParamsHandler.cpp" />
<ClCompile Include="source\NcaHeader.cpp" /> <ClCompile Include="source\NcaHeader.cpp" />
<ClCompile Include="source\NcaUtils.cpp" /> <ClCompile Include="source\NcaUtils.cpp" />
<ClCompile Include="source\NpdmBinary.cpp" />
<ClCompile Include="source\NroHeader.cpp" /> <ClCompile Include="source\NroHeader.cpp" />
<ClCompile Include="source\NsoHeader.cpp" /> <ClCompile Include="source\NsoHeader.cpp" />
<ClCompile Include="source\PfsHeader.cpp" /> <ClCompile Include="source\PfsHeader.cpp" />

View file

@ -129,7 +129,7 @@
<ClInclude Include="include\nn\hac\npdm.h"> <ClInclude Include="include\nn\hac\npdm.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\nn\hac\NpdmBinary.h"> <ClInclude Include="include\nn\hac\MetaBinary.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="include\nn\hac\nro.h"> <ClInclude Include="include\nn\hac\nro.h">
@ -266,7 +266,7 @@
<ClCompile Include="source\NcaUtils.cpp"> <ClCompile Include="source\NcaUtils.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\NpdmBinary.cpp"> <ClCompile Include="source\MetaBinary.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\NroHeader.cpp"> <ClCompile Include="source\NroHeader.cpp">

View file

@ -1,19 +1,19 @@
#include <nn/hac/NpdmBinary.h> #include <nn/hac/MetaBinary.h>
#include <fnd/SimpleTextOutput.h> #include <fnd/SimpleTextOutput.h>
nn::hac::NpdmBinary::NpdmBinary() nn::hac::MetaBinary::MetaBinary()
{ {
clear(); clear();
} }
nn::hac::NpdmBinary::NpdmBinary(const NpdmBinary & other) : nn::hac::MetaBinary::MetaBinary(const MetaBinary & other) :
NpdmBinary() MetaBinary()
{ {
*this = other; *this = other;
} }
void nn::hac::NpdmBinary::operator=(const NpdmBinary & other) void nn::hac::MetaBinary::operator=(const MetaBinary & other)
{ {
mRawBinary = other.mRawBinary; mRawBinary = other.mRawBinary;
mInstructionType = other.mInstructionType; mInstructionType = other.mInstructionType;
@ -28,7 +28,7 @@ void nn::hac::NpdmBinary::operator=(const NpdmBinary & other)
mAcid = other.mAcid; mAcid = other.mAcid;
} }
bool nn::hac::NpdmBinary::operator==(const NpdmBinary & other) const bool nn::hac::MetaBinary::operator==(const MetaBinary & other) const
{ {
return (mInstructionType == other.mInstructionType) \ return (mInstructionType == other.mInstructionType) \
&& (mProcAddressSpaceType == other.mProcAddressSpaceType) \ && (mProcAddressSpaceType == other.mProcAddressSpaceType) \
@ -42,12 +42,12 @@ bool nn::hac::NpdmBinary::operator==(const NpdmBinary & other) const
&& (mAcid == other.mAcid); && (mAcid == other.mAcid);
} }
bool nn::hac::NpdmBinary::operator!=(const NpdmBinary & other) const bool nn::hac::MetaBinary::operator!=(const MetaBinary & other) const
{ {
return !(*this == other); return !(*this == other);
} }
void nn::hac::NpdmBinary::toBytes() void nn::hac::MetaBinary::toBytes()
{ {
if (mAcid.getBytes().size() == 0) if (mAcid.getBytes().size() == 0)
mAcid.toBytes(); mAcid.toBytes();
@ -61,20 +61,20 @@ void nn::hac::NpdmBinary::toBytes()
uint32_t offset, size; uint32_t offset, size;
} acid, aci; } acid, aci;
acid.offset = (uint32_t)align(sizeof(sNpdmHeader), npdm::kSectionAlignSize); acid.offset = (uint32_t)align(sizeof(sMetaHeader), meta::kSectionAlignSize);
acid.size = (uint32_t)mAcid.getBytes().size(); acid.size = (uint32_t)mAcid.getBytes().size();
aci.offset = (uint32_t)(acid.offset + align(acid.size, npdm::kSectionAlignSize)); aci.offset = (uint32_t)(acid.offset + align(acid.size, meta::kSectionAlignSize));
aci.size = (uint32_t)mAci.getBytes().size(); aci.size = (uint32_t)mAci.getBytes().size();
// get total size // get total size
size_t total_size = _MAX(_MAX(acid.offset + acid.size, aci.offset + aci.size), align(sizeof(sNpdmHeader), npdm::kSectionAlignSize)); size_t total_size = _MAX(_MAX(acid.offset + acid.size, aci.offset + aci.size), align(sizeof(sMetaHeader), meta::kSectionAlignSize));
mRawBinary.alloc(total_size); mRawBinary.alloc(total_size);
sNpdmHeader* hdr = (sNpdmHeader*)mRawBinary.data(); sMetaHeader* hdr = (sMetaHeader*)mRawBinary.data();
// set type // set type
hdr->st_magic = npdm::kNpdmStructMagic; hdr->st_magic = meta::kMetaStructMagic;
// set variables // set variables
byte_t flag = ((byte_t)(mInstructionType & 1) | (byte_t)((mProcAddressSpaceType & 3) << 1)) & 0xf; byte_t flag = ((byte_t)(mInstructionType & 1) | (byte_t)((mProcAddressSpaceType & 3) << 1)) & 0xf;
@ -83,8 +83,8 @@ void nn::hac::NpdmBinary::toBytes()
hdr->main_thread_cpu_id = mMainThreadCpuId; hdr->main_thread_cpu_id = mMainThreadCpuId;
hdr->version = mVersion; hdr->version = mVersion;
hdr->main_thread_stack_size = mMainThreadStackSize; hdr->main_thread_stack_size = mMainThreadStackSize;
strncpy(hdr->name, mName.c_str(), npdm::kNameMaxLen); strncpy(hdr->name, mName.c_str(), meta::kNameMaxLen);
strncpy(hdr->product_code, mProductCode.c_str(), npdm::kProductCodeMaxLen); strncpy(hdr->product_code, mProductCode.c_str(), meta::kProductCodeMaxLen);
// set offset/size // set offset/size
hdr->aci.offset = aci.offset; hdr->aci.offset = aci.offset;
@ -103,45 +103,45 @@ void nn::hac::NpdmBinary::toBytes()
} }
} }
void nn::hac::NpdmBinary::fromBytes(const byte_t* data, size_t len) void nn::hac::MetaBinary::fromBytes(const byte_t* data, size_t len)
{ {
// check size // check size
if (len < sizeof(sNpdmHeader)) if (len < sizeof(sMetaHeader))
{ {
throw fnd::Exception(kModuleName, "NPDM binary is too small"); throw fnd::Exception(kModuleName, "META binary is too small");
} }
// clear variables // clear variables
clear(); clear();
// save a copy of the header // save a copy of the header
sNpdmHeader hdr; sMetaHeader hdr;
memcpy((void*)&hdr, data, sizeof(sNpdmHeader)); memcpy((void*)&hdr, data, sizeof(sMetaHeader));
// check magic // check magic
if (hdr.st_magic.get() != npdm::kNpdmStructMagic) if (hdr.st_magic.get() != meta::kMetaStructMagic)
{ {
throw fnd::Exception(kModuleName, "NPDM header corrupt"); throw fnd::Exception(kModuleName, "META header corrupt (unrecognised struct signature)");
} }
// save variables // save variables
byte_t flag = hdr.flags & 0xf; byte_t flag = hdr.flags & 0xf;
mInstructionType = (npdm::InstructionType)(flag & 1); mInstructionType = (meta::InstructionType)(flag & 1);
mProcAddressSpaceType = (npdm::ProcAddrSpaceType)((flag >> 1) & 3); mProcAddressSpaceType = (meta::ProcAddrSpaceType)((flag >> 1) & 3);
mMainThreadPriority = hdr.main_thread_priority; mMainThreadPriority = hdr.main_thread_priority;
mMainThreadCpuId = hdr.main_thread_cpu_id; mMainThreadCpuId = hdr.main_thread_cpu_id;
mVersion = hdr.version.get(); mVersion = hdr.version.get();
mMainThreadStackSize = hdr.main_thread_stack_size.get(); mMainThreadStackSize = hdr.main_thread_stack_size.get();
mName = std::string(hdr.name, _MIN(strlen(hdr.name), npdm::kNameMaxLen)); mName = std::string(hdr.name, _MIN(strlen(hdr.name), meta::kNameMaxLen));
mProductCode = std::string(hdr.product_code, _MIN(strlen(hdr.product_code), npdm::kProductCodeMaxLen)); mProductCode = std::string(hdr.product_code, _MIN(strlen(hdr.product_code), meta::kProductCodeMaxLen));
// total size // total size
size_t total_size = _MAX(_MAX(hdr.acid.offset.get() + hdr.acid.size.get(), hdr.aci.offset.get() + hdr.aci.size.get()), sizeof(sNpdmHeader)); size_t total_size = _MAX(_MAX(hdr.acid.offset.get() + hdr.acid.size.get(), hdr.aci.offset.get() + hdr.aci.size.get()), sizeof(sMetaHeader));
// check size // check size
if (total_size > len) if (total_size > len)
{ {
throw fnd::Exception(kModuleName, "NPDM binary too small"); throw fnd::Exception(kModuleName, "META binary too small");
} }
// save local copy // save local copy
@ -159,16 +159,16 @@ void nn::hac::NpdmBinary::fromBytes(const byte_t* data, size_t len)
} }
} }
const fnd::Vec<byte_t>& nn::hac::NpdmBinary::getBytes() const const fnd::Vec<byte_t>& nn::hac::MetaBinary::getBytes() const
{ {
return mRawBinary; return mRawBinary;
} }
void nn::hac::NpdmBinary::clear() void nn::hac::MetaBinary::clear()
{ {
mRawBinary.clear(); mRawBinary.clear();
mInstructionType = npdm::INSTR_64BIT; mInstructionType = meta::INSTR_64BIT;
mProcAddressSpaceType = npdm::ADDR_SPACE_64BIT; mProcAddressSpaceType = meta::ADDR_SPACE_64BIT;
mMainThreadPriority = 0; mMainThreadPriority = 0;
mMainThreadCpuId = 0; mMainThreadCpuId = 0;
mVersion = 0; mVersion = 0;
@ -179,34 +179,34 @@ void nn::hac::NpdmBinary::clear()
mAcid.clear(); mAcid.clear();
} }
nn::hac::npdm::InstructionType nn::hac::NpdmBinary::getInstructionType() const nn::hac::meta::InstructionType nn::hac::MetaBinary::getInstructionType() const
{ {
return mInstructionType; return mInstructionType;
} }
void nn::hac::NpdmBinary::setInstructionType(npdm::InstructionType type) void nn::hac::MetaBinary::setInstructionType(meta::InstructionType type)
{ {
mInstructionType = type; mInstructionType = type;
} }
nn::hac::npdm::ProcAddrSpaceType nn::hac::NpdmBinary::getProcAddressSpaceType() const nn::hac::meta::ProcAddrSpaceType nn::hac::MetaBinary::getProcAddressSpaceType() const
{ {
return mProcAddressSpaceType; return mProcAddressSpaceType;
} }
void nn::hac::NpdmBinary::setProcAddressSpaceType(npdm::ProcAddrSpaceType type) void nn::hac::MetaBinary::setProcAddressSpaceType(meta::ProcAddrSpaceType type)
{ {
mProcAddressSpaceType = type; mProcAddressSpaceType = type;
} }
byte_t nn::hac::NpdmBinary::getMainThreadPriority() const byte_t nn::hac::MetaBinary::getMainThreadPriority() const
{ {
return mMainThreadPriority; return mMainThreadPriority;
} }
void nn::hac::NpdmBinary::setMainThreadPriority(byte_t priority) void nn::hac::MetaBinary::setMainThreadPriority(byte_t priority)
{ {
if (priority > npdm::kMaxPriority) if (priority > meta::kMaxPriority)
{ {
throw fnd::Exception(kModuleName, "Illegal main thread priority (range 0-63)"); throw fnd::Exception(kModuleName, "Illegal main thread priority (range 0-63)");
} }
@ -214,44 +214,44 @@ void nn::hac::NpdmBinary::setMainThreadPriority(byte_t priority)
mMainThreadPriority = priority; mMainThreadPriority = priority;
} }
byte_t nn::hac::NpdmBinary::getMainThreadCpuId() const byte_t nn::hac::MetaBinary::getMainThreadCpuId() const
{ {
return mMainThreadCpuId; return mMainThreadCpuId;
} }
void nn::hac::NpdmBinary::setMainThreadCpuId(byte_t core_num) void nn::hac::MetaBinary::setMainThreadCpuId(byte_t core_num)
{ {
mMainThreadCpuId = core_num; mMainThreadCpuId = core_num;
} }
uint32_t nn::hac::NpdmBinary::getVersion() const uint32_t nn::hac::MetaBinary::getVersion() const
{ {
return mVersion; return mVersion;
} }
void nn::hac::NpdmBinary::setVersion(uint32_t version) void nn::hac::MetaBinary::setVersion(uint32_t version)
{ {
mVersion = version; mVersion = version;
} }
uint32_t nn::hac::NpdmBinary::getMainThreadStackSize() const uint32_t nn::hac::MetaBinary::getMainThreadStackSize() const
{ {
return mMainThreadStackSize; return mMainThreadStackSize;
} }
void nn::hac::NpdmBinary::setMainThreadStackSize(uint32_t size) void nn::hac::MetaBinary::setMainThreadStackSize(uint32_t size)
{ {
mMainThreadStackSize = size; mMainThreadStackSize = size;
} }
const std::string & nn::hac::NpdmBinary::getName() const const std::string & nn::hac::MetaBinary::getName() const
{ {
return mName; return mName;
} }
void nn::hac::NpdmBinary::setName(const std::string & name) void nn::hac::MetaBinary::setName(const std::string & name)
{ {
if (name.length() > npdm::kNameMaxLen) if (name.length() > meta::kNameMaxLen)
{ {
throw fnd::Exception(kModuleName, "Name is too long"); throw fnd::Exception(kModuleName, "Name is too long");
} }
@ -259,14 +259,14 @@ void nn::hac::NpdmBinary::setName(const std::string & name)
mName = name; mName = name;
} }
const std::string & nn::hac::NpdmBinary::getProductCode() const const std::string & nn::hac::MetaBinary::getProductCode() const
{ {
return mProductCode; return mProductCode;
} }
void nn::hac::NpdmBinary::setProductCode(const std::string & product_code) void nn::hac::MetaBinary::setProductCode(const std::string & product_code)
{ {
if (product_code.length() > npdm::kProductCodeMaxLen) if (product_code.length() > meta::kProductCodeMaxLen)
{ {
throw fnd::Exception(kModuleName, "Product Code is too long"); throw fnd::Exception(kModuleName, "Product Code is too long");
} }
@ -274,22 +274,22 @@ void nn::hac::NpdmBinary::setProductCode(const std::string & product_code)
mProductCode = product_code; mProductCode = product_code;
} }
const nn::hac::AccessControlInfoBinary & nn::hac::NpdmBinary::getAci() const const nn::hac::AccessControlInfoBinary & nn::hac::MetaBinary::getAci() const
{ {
return mAci; return mAci;
} }
void nn::hac::NpdmBinary::setAci(const AccessControlInfoBinary & aci) void nn::hac::MetaBinary::setAci(const AccessControlInfoBinary & aci)
{ {
mAci = aci; mAci = aci;
} }
const nn::hac::AccessControlInfoDescBinary & nn::hac::NpdmBinary::getAcid() const const nn::hac::AccessControlInfoDescBinary & nn::hac::MetaBinary::getAcid() const
{ {
return mAcid; return mAcid;
} }
void nn::hac::NpdmBinary::setAcid(const AccessControlInfoDescBinary & acid) void nn::hac::MetaBinary::setAcid(const AccessControlInfoDescBinary & acid)
{ {
mAcid = acid; mAcid = acid;
} }

View file

@ -184,9 +184,9 @@
<ClInclude Include="source\ElfSymbolParser.h" /> <ClInclude Include="source\ElfSymbolParser.h" />
<ClInclude Include="source\EsTikProcess.h" /> <ClInclude Include="source\EsTikProcess.h" />
<ClInclude Include="source\KeyConfiguration.h" /> <ClInclude Include="source\KeyConfiguration.h" />
<ClInclude Include="source\MetaProcess.h" />
<ClInclude Include="source\NacpProcess.h" /> <ClInclude Include="source\NacpProcess.h" />
<ClInclude Include="source\NcaProcess.h" /> <ClInclude Include="source\NcaProcess.h" />
<ClInclude Include="source\NpdmProcess.h" />
<ClInclude Include="source\NroProcess.h" /> <ClInclude Include="source\NroProcess.h" />
<ClInclude Include="source\NsoProcess.h" /> <ClInclude Include="source\NsoProcess.h" />
<ClInclude Include="source\PfsProcess.h" /> <ClInclude Include="source\PfsProcess.h" />
@ -206,9 +206,9 @@
<ClCompile Include="source\EsTikProcess.cpp" /> <ClCompile Include="source\EsTikProcess.cpp" />
<ClCompile Include="source\KeyConfiguration.cpp" /> <ClCompile Include="source\KeyConfiguration.cpp" />
<ClCompile Include="source\main.cpp" /> <ClCompile Include="source\main.cpp" />
<ClCompile Include="source\MetaProcess.cpp" />
<ClCompile Include="source\NacpProcess.cpp" /> <ClCompile Include="source\NacpProcess.cpp" />
<ClCompile Include="source\NcaProcess.cpp" /> <ClCompile Include="source\NcaProcess.cpp" />
<ClCompile Include="source\NpdmProcess.cpp" />
<ClCompile Include="source\NroProcess.cpp" /> <ClCompile Include="source\NroProcess.cpp" />
<ClCompile Include="source\NsoProcess.cpp" /> <ClCompile Include="source\NsoProcess.cpp" />
<ClCompile Include="source\PfsProcess.cpp" /> <ClCompile Include="source\PfsProcess.cpp" />

View file

@ -37,15 +37,15 @@
<ClInclude Include="source\KeyConfiguration.h"> <ClInclude Include="source\KeyConfiguration.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="source\MetaProcess.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="source\NacpProcess.h"> <ClInclude Include="source\NacpProcess.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="source\NcaProcess.h"> <ClInclude Include="source\NcaProcess.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="source\NpdmProcess.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="source\NroProcess.h"> <ClInclude Include="source\NroProcess.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
@ -99,15 +99,15 @@
<ClCompile Include="source\main.cpp"> <ClCompile Include="source\main.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\MetaProcess.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\NacpProcess.cpp"> <ClCompile Include="source\NacpProcess.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\NcaProcess.cpp"> <ClCompile Include="source\NcaProcess.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\NpdmProcess.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\NroProcess.cpp"> <ClCompile Include="source\NroProcess.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>

View file

@ -1,72 +1,72 @@
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include "NpdmProcess.h" #include "MetaProcess.h"
NpdmProcess::NpdmProcess() : MetaProcess::MetaProcess() :
mFile(), mFile(),
mCliOutputMode(_BIT(OUTPUT_BASIC)), mCliOutputMode(_BIT(OUTPUT_BASIC)),
mVerify(false) mVerify(false)
{ {
} }
void NpdmProcess::process() void MetaProcess::process()
{ {
importNpdm(); importMeta();
if (mVerify) if (mVerify)
{ {
validateAcidSignature(mNpdm.getAcid()); validateAcidSignature(mMeta.getAcid());
validateAciFromAcid(mNpdm.getAci(), mNpdm.getAcid()); validateAciFromAcid(mMeta.getAci(), mMeta.getAcid());
} }
if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC)) if (_HAS_BIT(mCliOutputMode, OUTPUT_BASIC))
{ {
// npdm binary // npdm binary
displayNpdmHeader(mNpdm); displayMetaHeader(mMeta);
// aci binary // aci binary
displayAciHdr(mNpdm.getAci()); displayAciHdr(mMeta.getAci());
displayFac(mNpdm.getAci().getFileSystemAccessControl()); displayFac(mMeta.getAci().getFileSystemAccessControl());
displaySac(mNpdm.getAci().getServiceAccessControl()); displaySac(mMeta.getAci().getServiceAccessControl());
displayKernelCap(mNpdm.getAci().getKernelCapabilities()); displayKernelCap(mMeta.getAci().getKernelCapabilities());
// acid binary // acid binary
if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED)) if (_HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
{ {
displayAciDescHdr(mNpdm.getAcid()); displayAciDescHdr(mMeta.getAcid());
displayFac(mNpdm.getAcid().getFileSystemAccessControl()); displayFac(mMeta.getAcid().getFileSystemAccessControl());
displaySac(mNpdm.getAcid().getServiceAccessControl()); displaySac(mMeta.getAcid().getServiceAccessControl());
displayKernelCap(mNpdm.getAcid().getKernelCapabilities()); displayKernelCap(mMeta.getAcid().getKernelCapabilities());
} }
} }
} }
void NpdmProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file) void MetaProcess::setInputFile(const fnd::SharedPtr<fnd::IFile>& file)
{ {
mFile = file; mFile = file;
} }
void NpdmProcess::setKeyCfg(const KeyConfiguration& keycfg) void MetaProcess::setKeyCfg(const KeyConfiguration& keycfg)
{ {
mKeyCfg = keycfg; mKeyCfg = keycfg;
} }
void NpdmProcess::setCliOutputMode(CliOutputMode type) void MetaProcess::setCliOutputMode(CliOutputMode type)
{ {
mCliOutputMode = type; mCliOutputMode = type;
} }
void NpdmProcess::setVerifyMode(bool verify) void MetaProcess::setVerifyMode(bool verify)
{ {
mVerify = verify; mVerify = verify;
} }
const nn::hac::NpdmBinary& NpdmProcess::getNpdmBinary() const const nn::hac::MetaBinary& MetaProcess::getMetaBinary() const
{ {
return mNpdm; return mMeta;
} }
void NpdmProcess::importNpdm() void MetaProcess::importMeta()
{ {
fnd::Vec<byte_t> scratch; fnd::Vec<byte_t> scratch;
@ -78,10 +78,10 @@ void NpdmProcess::importNpdm()
scratch.alloc((*mFile)->size()); scratch.alloc((*mFile)->size());
(*mFile)->read(scratch.data(), 0, scratch.size()); (*mFile)->read(scratch.data(), 0, scratch.size());
mNpdm.fromBytes(scratch.data(), scratch.size()); mMeta.fromBytes(scratch.data(), scratch.size());
} }
void NpdmProcess::validateAcidSignature(const nn::hac::AccessControlInfoDescBinary& acid) void MetaProcess::validateAcidSignature(const nn::hac::AccessControlInfoDescBinary& acid)
{ {
try { try {
fnd::rsa::sRsa2048Key acid_sign_key; fnd::rsa::sRsa2048Key acid_sign_key;
@ -96,7 +96,7 @@ void NpdmProcess::validateAcidSignature(const nn::hac::AccessControlInfoDescBina
} }
void NpdmProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& aci, const nn::hac::AccessControlInfoDescBinary& acid) void MetaProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& aci, const nn::hac::AccessControlInfoDescBinary& acid)
{ {
// check Program ID // check Program ID
if (acid.getProgramIdRestrict().min > 0 && aci.getProgramId() < acid.getProgramIdRestrict().min) if (acid.getProgramIdRestrict().min > 0 && aci.getProgramId() < acid.getProgramIdRestrict().min)
@ -287,9 +287,9 @@ void NpdmProcess::validateAciFromAcid(const nn::hac::AccessControlInfoBinary& ac
} }
} }
void NpdmProcess::displayNpdmHeader(const nn::hac::NpdmBinary& hdr) void MetaProcess::displayMetaHeader(const nn::hac::MetaBinary& hdr)
{ {
std::cout << "[NPDM HEADER]" << std::endl; std::cout << "[Meta Header]" << std::endl;
std::cout << " Process Architecture Params:" << std::endl; std::cout << " Process Architecture Params:" << std::endl;
std::cout << " Ins. Type: " << getInstructionTypeStr(hdr.getInstructionType()) << std::endl; std::cout << " Ins. Type: " << getInstructionTypeStr(hdr.getInstructionType()) << std::endl;
std::cout << " Addr Space: " << getProcAddressSpaceTypeStr(hdr.getProcAddressSpaceType()) << std::endl; std::cout << " Addr Space: " << getProcAddressSpaceTypeStr(hdr.getProcAddressSpaceType()) << std::endl;
@ -306,13 +306,13 @@ void NpdmProcess::displayNpdmHeader(const nn::hac::NpdmBinary& hdr)
} }
} }
void NpdmProcess::displayAciHdr(const nn::hac::AccessControlInfoBinary& aci) void MetaProcess::displayAciHdr(const nn::hac::AccessControlInfoBinary& aci)
{ {
std::cout << "[Access Control Info]" << std::endl; std::cout << "[Access Control Info]" << std::endl;
std::cout << " ProgramID: 0x" << std::hex << std::setw(16) << std::setfill('0') << aci.getProgramId() << std::endl; std::cout << " ProgramID: 0x" << std::hex << std::setw(16) << std::setfill('0') << aci.getProgramId() << std::endl;
} }
void NpdmProcess::displayAciDescHdr(const nn::hac::AccessControlInfoDescBinary& acid) void MetaProcess::displayAciDescHdr(const nn::hac::AccessControlInfoDescBinary& acid)
{ {
std::cout << "[Access Control Info Desc]" << std::endl; std::cout << "[Access Control Info Desc]" << std::endl;
if (acid.getFlagList().size() > 0 || _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED)) if (acid.getFlagList().size() > 0 || _HAS_BIT(mCliOutputMode, OUTPUT_EXTENDED))
@ -328,7 +328,7 @@ void NpdmProcess::displayAciDescHdr(const nn::hac::AccessControlInfoDescBinary&
std::cout << " Max: 0x" << std::hex << std::setw(16) << std::setfill('0') << acid.getProgramIdRestrict().max << std::endl; std::cout << " Max: 0x" << std::hex << std::setw(16) << std::setfill('0') << acid.getProgramIdRestrict().max << std::endl;
} }
void NpdmProcess::displayFac(const nn::hac::FileSystemAccessControlBinary& fac) void MetaProcess::displayFac(const nn::hac::FileSystemAccessControlBinary& fac)
{ {
std::cout << "[FS Access Control]" << std::endl; std::cout << "[FS Access Control]" << std::endl;
std::cout << " Format Version: " << std::dec << (uint32_t)fac.getFormatVersion() << std::endl; std::cout << " Format Version: " << std::dec << (uint32_t)fac.getFormatVersion() << std::endl;
@ -373,7 +373,7 @@ void NpdmProcess::displayFac(const nn::hac::FileSystemAccessControlBinary& fac)
} }
void NpdmProcess::displaySac(const nn::hac::ServiceAccessControlBinary& sac) void MetaProcess::displaySac(const nn::hac::ServiceAccessControlBinary& sac)
{ {
std::cout << "[Service Access Control]" << std::endl; std::cout << "[Service Access Control]" << std::endl;
std::cout << " Service List:" << std::endl; std::cout << " Service List:" << std::endl;
@ -394,7 +394,7 @@ void NpdmProcess::displaySac(const nn::hac::ServiceAccessControlBinary& sac)
std::cout << std::endl; std::cout << std::endl;
} }
void NpdmProcess::displayKernelCap(const nn::hac::KernelCapabilityBinary& kern) void MetaProcess::displayKernelCap(const nn::hac::KernelCapabilityBinary& kern)
{ {
std::cout << "[Kernel Capabilities]" << std::endl; std::cout << "[Kernel Capabilities]" << std::endl;
if (kern.getThreadInfo().isSet()) if (kern.getThreadInfo().isSet())
@ -496,16 +496,16 @@ void NpdmProcess::displayKernelCap(const nn::hac::KernelCapabilityBinary& kern)
} }
} }
const char* NpdmProcess::getInstructionTypeStr(nn::hac::npdm::InstructionType type) const const char* MetaProcess::getInstructionTypeStr(nn::hac::meta::InstructionType type) const
{ {
const char* str = nullptr; const char* str = nullptr;
switch(type) switch(type)
{ {
case (nn::hac::npdm::INSTR_32BIT): case (nn::hac::meta::INSTR_32BIT):
str = "32Bit"; str = "32Bit";
break; break;
case (nn::hac::npdm::INSTR_64BIT): case (nn::hac::meta::INSTR_64BIT):
str = "64Bit"; str = "64Bit";
break; break;
default: default:
@ -516,19 +516,19 @@ const char* NpdmProcess::getInstructionTypeStr(nn::hac::npdm::InstructionType ty
return str; return str;
} }
const char* NpdmProcess::getProcAddressSpaceTypeStr(nn::hac::npdm::ProcAddrSpaceType type) const const char* MetaProcess::getProcAddressSpaceTypeStr(nn::hac::meta::ProcAddrSpaceType type) const
{ {
const char* str = nullptr; const char* str = nullptr;
switch(type) switch(type)
{ {
case (nn::hac::npdm::ADDR_SPACE_64BIT): case (nn::hac::meta::ADDR_SPACE_64BIT):
str = "64Bit"; str = "64Bit";
break; break;
case (nn::hac::npdm::ADDR_SPACE_32BIT): case (nn::hac::meta::ADDR_SPACE_32BIT):
str = "32Bit"; str = "32Bit";
break; break;
case (nn::hac::npdm::ADDR_SPACE_32BIT_NO_RESERVED): case (nn::hac::meta::ADDR_SPACE_32BIT_NO_RESERVED):
str = "32Bit no reserved"; str = "32Bit no reserved";
break; break;
default: default:
@ -539,7 +539,7 @@ const char* NpdmProcess::getProcAddressSpaceTypeStr(nn::hac::npdm::ProcAddrSpace
return str; return str;
} }
const char* NpdmProcess::getAcidFlagStr(nn::hac::aci::Flag flag) const const char* MetaProcess::getAcidFlagStr(nn::hac::aci::Flag flag) const
{ {
const char* str = nullptr; const char* str = nullptr;
@ -559,7 +559,7 @@ const char* NpdmProcess::getAcidFlagStr(nn::hac::aci::Flag flag) const
return str; return str;
} }
const char* NpdmProcess::getMiscFlagStr(nn::hac::MiscFlagsHandler::Flags flag) const const char* MetaProcess::getMiscFlagStr(nn::hac::MiscFlagsHandler::Flags flag) const
{ {
const char* str = nullptr; const char* str = nullptr;
@ -579,7 +579,7 @@ const char* NpdmProcess::getMiscFlagStr(nn::hac::MiscFlagsHandler::Flags flag) c
return str; return str;
} }
const char* NpdmProcess::getFsaRightStr(nn::hac::fac::FsAccessFlag flag) const const char* MetaProcess::getFsaRightStr(nn::hac::fac::FsAccessFlag flag) const
{ {
const char* str = nullptr; const char* str = nullptr;
@ -659,7 +659,7 @@ const char* NpdmProcess::getFsaRightStr(nn::hac::fac::FsAccessFlag flag) const
return str; return str;
} }
const char* NpdmProcess::getSaveDataOwnerAccessModeStr(nn::hac::fac::SaveDataOwnerIdAccessType type) const const char* MetaProcess::getSaveDataOwnerAccessModeStr(nn::hac::fac::SaveDataOwnerIdAccessType type) const
{ {
const char* str = nullptr; const char* str = nullptr;
@ -682,7 +682,7 @@ const char* NpdmProcess::getSaveDataOwnerAccessModeStr(nn::hac::fac::SaveDataOwn
return str; return str;
} }
const char* NpdmProcess::getSystemCallStr(byte_t syscall_id) const const char* MetaProcess::getSystemCallStr(byte_t syscall_id) const
{ {
const char* str = nullptr; const char* str = nullptr;
@ -1077,7 +1077,7 @@ const char* NpdmProcess::getSystemCallStr(byte_t syscall_id) const
return str; return str;
} }
const char* NpdmProcess::getMemMapPermStr(nn::hac::MemoryMappingHandler::MemoryPerm type) const const char* MetaProcess::getMemMapPermStr(nn::hac::MemoryMappingHandler::MemoryPerm type) const
{ {
const char* str = nullptr; const char* str = nullptr;
@ -1097,7 +1097,7 @@ const char* NpdmProcess::getMemMapPermStr(nn::hac::MemoryMappingHandler::MemoryP
return str; return str;
} }
const char* NpdmProcess::getMemMapTypeStr(nn::hac::MemoryMappingHandler::MappingType type) const const char* MetaProcess::getMemMapTypeStr(nn::hac::MemoryMappingHandler::MappingType type) const
{ {
const char* str = nullptr; const char* str = nullptr;

View file

@ -3,15 +3,15 @@
#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/NpdmBinary.h> #include <nn/hac/MetaBinary.h>
#include "KeyConfiguration.h" #include "KeyConfiguration.h"
#include "common.h" #include "common.h"
class NpdmProcess class MetaProcess
{ {
public: public:
NpdmProcess(); MetaProcess();
void process(); void process();
@ -20,32 +20,32 @@ public:
void setCliOutputMode(CliOutputMode type); void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify); void setVerifyMode(bool verify);
const nn::hac::NpdmBinary& getNpdmBinary() const; const nn::hac::MetaBinary& getMetaBinary() const;
private: private:
const std::string kModuleName = "NpdmProcess"; const std::string kModuleName = "MetaProcess";
fnd::SharedPtr<fnd::IFile> mFile; fnd::SharedPtr<fnd::IFile> mFile;
KeyConfiguration mKeyCfg; KeyConfiguration mKeyCfg;
CliOutputMode mCliOutputMode; CliOutputMode mCliOutputMode;
bool mVerify; bool mVerify;
nn::hac::NpdmBinary mNpdm; nn::hac::MetaBinary mMeta;
void importNpdm(); void importMeta();
void validateAcidSignature(const nn::hac::AccessControlInfoDescBinary& acid); void validateAcidSignature(const nn::hac::AccessControlInfoDescBinary& acid);
void validateAciFromAcid(const nn::hac::AccessControlInfoBinary& aci, const nn::hac::AccessControlInfoDescBinary& acid); void validateAciFromAcid(const nn::hac::AccessControlInfoBinary& aci, const nn::hac::AccessControlInfoDescBinary& acid);
void displayNpdmHeader(const nn::hac::NpdmBinary& hdr); void displayMetaHeader(const nn::hac::MetaBinary& hdr);
void displayAciHdr(const nn::hac::AccessControlInfoBinary& aci); void displayAciHdr(const nn::hac::AccessControlInfoBinary& aci);
void displayAciDescHdr(const nn::hac::AccessControlInfoDescBinary& aci); void displayAciDescHdr(const nn::hac::AccessControlInfoDescBinary& aci);
void displayFac(const nn::hac::FileSystemAccessControlBinary& fac); void displayFac(const nn::hac::FileSystemAccessControlBinary& fac);
void displaySac(const nn::hac::ServiceAccessControlBinary& sac); void displaySac(const nn::hac::ServiceAccessControlBinary& sac);
void displayKernelCap(const nn::hac::KernelCapabilityBinary& kern); void displayKernelCap(const nn::hac::KernelCapabilityBinary& kern);
const char* getInstructionTypeStr(nn::hac::npdm::InstructionType type) const; const char* getInstructionTypeStr(nn::hac::meta::InstructionType type) const;
const char* getProcAddressSpaceTypeStr(nn::hac::npdm::ProcAddrSpaceType type) const; const char* getProcAddressSpaceTypeStr(nn::hac::meta::ProcAddrSpaceType type) const;
const char* getAcidFlagStr(nn::hac::aci::Flag flag) const; const char* getAcidFlagStr(nn::hac::aci::Flag flag) const;
const char* getMiscFlagStr(nn::hac::MiscFlagsHandler::Flags flag) const; const char* getMiscFlagStr(nn::hac::MiscFlagsHandler::Flags flag) const;
const char* getFsaRightStr(nn::hac::fac::FsAccessFlag flag) const; const char* getFsaRightStr(nn::hac::fac::FsAccessFlag flag) const;

View file

@ -12,7 +12,7 @@
#include "NcaProcess.h" #include "NcaProcess.h"
#include "PfsProcess.h" #include "PfsProcess.h"
#include "RomfsProcess.h" #include "RomfsProcess.h"
#include "NpdmProcess.h" #include "MetaProcess.h"
NcaProcess::NcaProcess() : NcaProcess::NcaProcess() :
@ -410,12 +410,12 @@ void NcaProcess::validateNcaSignatures()
{ {
const nn::hac::PfsHeader::sFile& file = exefs.getPfsHeader().getFileList().getElement(kNpdmExefsPath); const nn::hac::PfsHeader::sFile& file = exefs.getPfsHeader().getFileList().getElement(kNpdmExefsPath);
NpdmProcess 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));
npdm.setCliOutputMode(0); npdm.setCliOutputMode(0);
npdm.process(); npdm.process();
if (fnd::rsa::pss::rsaVerify(npdm.getNpdmBinary().getAcid().getNcaHeaderSignature2Key(), fnd::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_acid) != 0) if (fnd::rsa::pss::rsaVerify(npdm.getMetaBinary().getAcid().getNcaHeaderSignature2Key(), fnd::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_acid) != 0)
{ {
std::cout << "[WARNING] NCA Header ACID Signature: FAIL" << std::endl; std::cout << "[WARNING] NCA Header ACID Signature: FAIL" << std::endl;
} }

View file

@ -43,7 +43,7 @@ void NroProcess::setVerifyMode(bool verify)
mVerify = verify; mVerify = verify;
} }
void NroProcess::setInstructionType(nn::hac::npdm::InstructionType type) void NroProcess::setInstructionType(nn::hac::meta::InstructionType type)
{ {
mRoMeta.setInstructionType(type); mRoMeta.setInstructionType(type);
} }

View file

@ -4,7 +4,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/npdm.h> #include <nn/hac/meta.h>
#include <nn/hac/NroHeader.h> #include <nn/hac/NroHeader.h>
#include "AssetProcess.h" #include "AssetProcess.h"
@ -22,7 +22,7 @@ public:
void setCliOutputMode(CliOutputMode type); void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify); void setVerifyMode(bool verify);
void setInstructionType(nn::hac::npdm::InstructionType type); void setInstructionType(nn::hac::meta::InstructionType type);
void setListApi(bool listApi); void setListApi(bool listApi);
void setListSymbols(bool listSymbols); void setListSymbols(bool listSymbols);

View file

@ -38,7 +38,7 @@ void NsoProcess::setVerifyMode(bool verify)
mVerify = verify; mVerify = verify;
} }
void NsoProcess::setInstructionType(nn::hac::npdm::InstructionType type) void NsoProcess::setInstructionType(nn::hac::meta::InstructionType type)
{ {
mRoMeta.setInstructionType(type); mRoMeta.setInstructionType(type);
} }

View file

@ -4,7 +4,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/npdm.h> #include <nn/hac/meta.h>
#include <nn/hac/NsoHeader.h> #include <nn/hac/NsoHeader.h>
#include "common.h" #include "common.h"
@ -21,7 +21,7 @@ public:
void setCliOutputMode(CliOutputMode type); void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify); void setVerifyMode(bool verify);
void setInstructionType(nn::hac::npdm::InstructionType type); void setInstructionType(nn::hac::meta::InstructionType type);
void setListApi(bool listApi); void setListApi(bool listApi);
void setListSymbols(bool listSymbols); void setListSymbols(bool listSymbols);
@ -32,7 +32,7 @@ private:
fnd::SharedPtr<fnd::IFile> mFile; fnd::SharedPtr<fnd::IFile> mFile;
CliOutputMode mCliOutputMode; CliOutputMode mCliOutputMode;
bool mVerify; bool mVerify;
nn::hac::npdm::InstructionType mInstructionType; nn::hac::meta::InstructionType mInstructionType;
bool mListApi; bool mListApi;
bool mListSymbols; bool mListSymbols;

View file

@ -7,7 +7,7 @@
RoMetadataProcess::RoMetadataProcess() : RoMetadataProcess::RoMetadataProcess() :
mCliOutputMode(_BIT(OUTPUT_BASIC)), mCliOutputMode(_BIT(OUTPUT_BASIC)),
mInstructionType(nn::hac::npdm::INSTR_64BIT), mInstructionType(nn::hac::meta::INSTR_64BIT),
mListApi(false), mListApi(false),
mListSymbols(false), mListSymbols(false),
mApiInfo(), mApiInfo(),
@ -57,7 +57,7 @@ void RoMetadataProcess::setCliOutputMode(CliOutputMode type)
mCliOutputMode = type; mCliOutputMode = type;
} }
void RoMetadataProcess::setInstructionType(nn::hac::npdm::InstructionType type) void RoMetadataProcess::setInstructionType(nn::hac::meta::InstructionType type)
{ {
mInstructionType = type; mInstructionType = type;
} }
@ -126,7 +126,7 @@ void RoMetadataProcess::importApiList()
if (mDynSym.size > 0) if (mDynSym.size > 0)
{ {
mSymbolList.parseData(mRoBlob.data() + mDynSym.offset, mDynSym.size, mRoBlob.data() + mDynStr.offset, mDynStr.size, mInstructionType == nn::hac::npdm::INSTR_64BIT); mSymbolList.parseData(mRoBlob.data() + mDynSym.offset, mDynSym.size, mRoBlob.data() + mDynStr.offset, mDynStr.size, mInstructionType == nn::hac::meta::INSTR_64BIT);
} }
} }

View file

@ -4,7 +4,7 @@
#include <fnd/types.h> #include <fnd/types.h>
#include <fnd/Vec.h> #include <fnd/Vec.h>
#include <nn/hac/npdm.h> #include <nn/hac/meta.h>
#include "common.h" #include "common.h"
#include "SdkApiString.h" #include "SdkApiString.h"
@ -24,7 +24,7 @@ public:
void setCliOutputMode(CliOutputMode type); void setCliOutputMode(CliOutputMode type);
void setInstructionType(nn::hac::npdm::InstructionType type); void setInstructionType(nn::hac::meta::InstructionType type);
void setListApi(bool listApi); void setListApi(bool listApi);
void setListSymbols(bool listSymbols); void setListSymbols(bool listSymbols);
@ -37,7 +37,7 @@ private:
const std::string kModuleName = "RoMetadataProcess"; const std::string kModuleName = "RoMetadataProcess";
CliOutputMode mCliOutputMode; CliOutputMode mCliOutputMode;
nn::hac::npdm::InstructionType mInstructionType; nn::hac::meta::InstructionType mInstructionType;
bool mListApi; bool mListApi;
bool mListSymbols; bool mListSymbols;

View file

@ -18,7 +18,7 @@
#include <nn/hac/xci.h> #include <nn/hac/xci.h>
#include <nn/hac/pfs.h> #include <nn/hac/pfs.h>
#include <nn/hac/nca.h> #include <nn/hac/nca.h>
#include <nn/hac/npdm.h> #include <nn/hac/meta.h>
#include <nn/hac/romfs.h> #include <nn/hac/romfs.h>
#include <nn/hac/cnmt.h> #include <nn/hac/cnmt.h>
#include <nn/hac/nacp.h> #include <nn/hac/nacp.h>
@ -52,7 +52,7 @@ void UserSettings::showHelp()
printf("\n General Options:\n"); printf("\n General Options:\n");
printf(" -d, --dev Use devkit keyset.\n"); printf(" -d, --dev Use devkit keyset.\n");
printf(" -k, --keyset Specify keyset file.\n"); printf(" -k, --keyset Specify keyset file.\n");
printf(" -t, --type Specify input file type. [xci, pfs, romfs, nca, npdm, cnmt, nso, nro, nacp, aset, cert, tik]\n"); printf(" -t, --type Specify input file type. [xci, pfs, romfs, nca, meta, cnmt, nso, nro, nacp, aset, cert, tik]\n");
printf(" -y, --verify Verify file.\n"); printf(" -y, --verify Verify file.\n");
printf("\n Output Options:\n"); printf("\n Output Options:\n");
printf(" --showkeys Show keys generated.\n"); printf(" --showkeys Show keys generated.\n");
@ -133,7 +133,7 @@ bool UserSettings::isListSymbols() const
return mListSymbols; return mListSymbols;
} }
nn::hac::npdm::InstructionType UserSettings::getInstType() const nn::hac::meta::InstructionType UserSettings::getInstType() const
{ {
return mInstructionType; return mInstructionType;
} }
@ -548,7 +548,7 @@ void UserSettings::populateUserSettings(sCmdArgs& args)
if (args.inst_type.isSet) if (args.inst_type.isSet)
mInstructionType = getInstructionTypeFromString(*args.inst_type); mInstructionType = getInstructionTypeFromString(*args.inst_type);
else else
mInstructionType = nn::hac::npdm::INSTR_64BIT; // default 64bit mInstructionType = nn::hac::meta::INSTR_64BIT; // default 64bit
mListApi = args.list_api.isSet; mListApi = args.list_api.isSet;
mListSymbols = args.list_sym.isSet; mListSymbols = args.list_sym.isSet;
@ -602,8 +602,8 @@ FileType UserSettings::getFileTypeFromString(const std::string& type_str)
type = FILE_ROMFS; type = FILE_ROMFS;
else if (str == "nca") else if (str == "nca")
type = FILE_NCA; type = FILE_NCA;
else if (str == "npdm") else if (str == "meta")
type = FILE_NPDM; type = FILE_META;
else if (str == "cnmt") else if (str == "cnmt")
type = FILE_CNMT; type = FILE_CNMT;
else if (str == "nso") else if (str == "nso")
@ -657,8 +657,8 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path)
else if (_ASSERT_SIZE(sizeof(nn::hac::sRomfsHeader)) && _TYPE_PTR(nn::hac::sRomfsHeader)->header_size.get() == sizeof(nn::hac::sRomfsHeader) && _TYPE_PTR(nn::hac::sRomfsHeader)->sections[1].offset.get() == (_TYPE_PTR(nn::hac::sRomfsHeader)->sections[0].offset.get() + _TYPE_PTR(nn::hac::sRomfsHeader)->sections[0].size.get())) else if (_ASSERT_SIZE(sizeof(nn::hac::sRomfsHeader)) && _TYPE_PTR(nn::hac::sRomfsHeader)->header_size.get() == sizeof(nn::hac::sRomfsHeader) && _TYPE_PTR(nn::hac::sRomfsHeader)->sections[1].offset.get() == (_TYPE_PTR(nn::hac::sRomfsHeader)->sections[0].offset.get() + _TYPE_PTR(nn::hac::sRomfsHeader)->sections[0].size.get()))
file_type = FILE_ROMFS; file_type = FILE_ROMFS;
// test npdm // test npdm
else if (_ASSERT_SIZE(sizeof(nn::hac::sNpdmHeader)) && _TYPE_PTR(nn::hac::sNpdmHeader)->st_magic.get() == nn::hac::npdm::kNpdmStructMagic) else if (_ASSERT_SIZE(sizeof(nn::hac::sMetaHeader)) && _TYPE_PTR(nn::hac::sMetaHeader)->st_magic.get() == nn::hac::meta::kMetaStructMagic)
file_type = FILE_NPDM; file_type = FILE_META;
// test nca // test nca
else if (determineValidNcaFromSample(scratch)) else if (determineValidNcaFromSample(scratch))
file_type = FILE_NCA; file_type = FILE_NCA;
@ -832,16 +832,16 @@ bool UserSettings::determineValidEsTikFromSample(const fnd::Vec<byte_t>& sample)
return true; return true;
} }
nn::hac::npdm::InstructionType UserSettings::getInstructionTypeFromString(const std::string & type_str) nn::hac::meta::InstructionType UserSettings::getInstructionTypeFromString(const std::string & type_str)
{ {
std::string str = type_str; std::string str = type_str;
std::transform(str.begin(), str.end(), str.begin(), ::tolower); std::transform(str.begin(), str.end(), str.begin(), ::tolower);
nn::hac::npdm::InstructionType type; nn::hac::meta::InstructionType type;
if (str == "32bit") if (str == "32bit")
type = nn::hac::npdm::INSTR_32BIT; type = nn::hac::meta::INSTR_32BIT;
else if (str == "64bit") else if (str == "64bit")
type = nn::hac::npdm::INSTR_64BIT; type = nn::hac::meta::INSTR_64BIT;
else else
throw fnd::Exception(kModuleName, "Unsupported instruction type: " + str); throw fnd::Exception(kModuleName, "Unsupported instruction type: " + str);

View file

@ -6,7 +6,7 @@
#include <fnd/List.h> #include <fnd/List.h>
#include <nn/pki/SignedData.h> #include <nn/pki/SignedData.h>
#include <nn/pki/CertificateBody.h> #include <nn/pki/CertificateBody.h>
#include <nn/hac/npdm.h> #include <nn/hac/meta.h>
#include "common.h" #include "common.h"
#include "KeyConfiguration.h" #include "KeyConfiguration.h"
@ -29,7 +29,7 @@ public:
bool isListFs() const; bool isListFs() const;
bool isListApi() const; bool isListApi() const;
bool isListSymbols() const; bool isListSymbols() const;
nn::hac::npdm::InstructionType getInstType() const; nn::hac::meta::InstructionType getInstType() const;
// specialised paths // specialised paths
const sOptional<std::string>& getXciUpdatePath() const; const sOptional<std::string>& getXciUpdatePath() const;
@ -110,7 +110,7 @@ private:
bool mListApi; bool mListApi;
bool mListSymbols; bool mListSymbols;
nn::hac::npdm::InstructionType mInstructionType; nn::hac::meta::InstructionType mInstructionType;
void populateCmdArgs(const std::vector<std::string>& arg_list, sCmdArgs& cmd_args); void populateCmdArgs(const std::vector<std::string>& arg_list, sCmdArgs& cmd_args);
void populateKeyset(sCmdArgs& args); void populateKeyset(sCmdArgs& args);
@ -122,7 +122,7 @@ private:
bool determineValidNacpFromSample(const fnd::Vec<byte_t>& sample) const; bool determineValidNacpFromSample(const fnd::Vec<byte_t>& sample) const;
bool determineValidEsCertFromSample(const fnd::Vec<byte_t>& sample) const; bool determineValidEsCertFromSample(const fnd::Vec<byte_t>& sample) const;
bool determineValidEsTikFromSample(const fnd::Vec<byte_t>& sample) const; bool determineValidEsTikFromSample(const fnd::Vec<byte_t>& sample) const;
nn::hac::npdm::InstructionType getInstructionTypeFromString(const std::string& type_str); nn::hac::meta::InstructionType getInstructionTypeFromString(const std::string& type_str);
void getHomePath(std::string& path) const; void getHomePath(std::string& path) const;
void getSwitchPath(std::string& path) const; void getSwitchPath(std::string& path) const;

View file

@ -15,7 +15,7 @@ enum FileType
FILE_PARTITIONFS, FILE_PARTITIONFS,
FILE_ROMFS, FILE_ROMFS,
FILE_NCA, FILE_NCA,
FILE_NPDM, FILE_META,
FILE_CNMT, FILE_CNMT,
FILE_NSO, FILE_NSO,
FILE_NRO, FILE_NRO,

View file

@ -7,7 +7,7 @@
#include "PfsProcess.h" #include "PfsProcess.h"
#include "RomfsProcess.h" #include "RomfsProcess.h"
#include "NcaProcess.h" #include "NcaProcess.h"
#include "NpdmProcess.h" #include "MetaProcess.h"
#include "CnmtProcess.h" #include "CnmtProcess.h"
#include "NsoProcess.h" #include "NsoProcess.h"
#include "NroProcess.h" #include "NroProcess.h"
@ -110,9 +110,9 @@ int main(int argc, char** argv)
nca.process(); nca.process();
} }
else if (user_set.getFileType() == FILE_NPDM) else if (user_set.getFileType() == FILE_META)
{ {
NpdmProcess npdm; MetaProcess npdm;
npdm.setInputFile(inputFile); npdm.setInputFile(inputFile);
npdm.setKeyCfg(user_set.getKeyCfg()); npdm.setKeyCfg(user_set.getKeyCfg());