[nstool] Add NRO HB extention AssetHeader support.

This commit is contained in:
jakcron 2018-06-10 14:57:57 +08:00
parent b41434375c
commit 4ef93db423
2 changed files with 35 additions and 0 deletions

View file

@ -46,7 +46,12 @@ void CodeObjectProcess::process()
if (mObjType == OBJ_NSO) if (mObjType == OBJ_NSO)
displayNsoHeader(); displayNsoHeader();
else if (mObjType == OBJ_NRO) else if (mObjType == OBJ_NRO)
{
displayNroHeader(); displayNroHeader();
if (mIsHomebrewNro)
displayNroAssetHeader();
}
} }
displayRoMetaData(); displayRoMetaData();
} }
@ -139,6 +144,18 @@ void CodeObjectProcess::importHeader()
mFile->read(scratch.getBytes(), 0, scratch.getSize()); mFile->read(scratch.getBytes(), 0, scratch.getSize());
mNroHdr.importBinary(scratch.getBytes(), scratch.getSize()); mNroHdr.importBinary(scratch.getBytes(), scratch.getSize());
nx::sNroHeader* raw_hdr = (nx::sNroHeader*)scratch.getBytes();
if (((le_uint64_t*)raw_hdr->reserved_0)->get() == nx::nro::kNroHomebrewSig)
{
mIsHomebrewNro = true;
scratch.alloc(sizeof(nx::sNroAssetHeader));
mFile->read(scratch.getBytes(), mNroHdr.getNroSize(), scratch.getSize());
mNroAssetHdr.importBinary(scratch.getBytes(), scratch.getSize());
}
else
mIsHomebrewNro = false;
} }
} }
@ -393,6 +410,20 @@ void CodeObjectProcess::displayNroHeader()
#undef _HEXDUMP_L #undef _HEXDUMP_L
} }
void CodeObjectProcess::displayNroAssetHeader()
{
printf("[ASET Header]\n");
printf(" Icon:\n");
printf(" Offset: 0x%" PRIx64 "\n", mNroAssetHdr.getIconInfo().offset);
printf(" Size: 0x%" PRIx64 "\n", mNroAssetHdr.getIconInfo().size);
printf(" NACP:\n");
printf(" Offset: 0x%" PRIx64 "\n", mNroAssetHdr.getNacpInfo().offset);
printf(" Size: 0x%" PRIx64 "\n", mNroAssetHdr.getNacpInfo().size);
printf(" RomFS:\n");
printf(" Offset: 0x%" PRIx64 "\n", mNroAssetHdr.getRomfsInfo().offset);
printf(" Size: 0x%" PRIx64 "\n", mNroAssetHdr.getRomfsInfo().size);
}
void CodeObjectProcess::displayRoMetaData() void CodeObjectProcess::displayRoMetaData()
{ {
if (mApiList.size() > 0 && (mListApi || mCliOutputType > OUTPUT_NORMAL)) if (mApiList.size() > 0 && (mListApi || mCliOutputType > OUTPUT_NORMAL))

View file

@ -6,6 +6,7 @@
#include <nx/npdm.h> #include <nx/npdm.h>
#include <nx/NsoHeader.h> #include <nx/NsoHeader.h>
#include <nx/NroHeader.h> #include <nx/NroHeader.h>
#include <nx/NroAssetHeader.h>
#include "nstool.h" #include "nstool.h"
#include "SdkApiString.h" #include "SdkApiString.h"
@ -57,6 +58,8 @@ private:
nx::NsoHeader mNsoHdr; nx::NsoHeader mNsoHdr;
nx::NroHeader mNroHdr; nx::NroHeader mNroHdr;
bool mIsHomebrewNro;
nx::NroAssetHeader mNroAssetHdr;
fnd::MemoryBlob mTextBlob, mRoBlob, mDataBlob; fnd::MemoryBlob mTextBlob, mRoBlob, mDataBlob;
std::vector<SdkApiString> mApiList; std::vector<SdkApiString> mApiList;
DynamicSymbolParser mDynSymbolList; DynamicSymbolParser mDynSymbolList;
@ -66,6 +69,7 @@ private:
void importApiList(); void importApiList();
void displayNsoHeader(); void displayNsoHeader();
void displayNroHeader(); void displayNroHeader();
void displayNroAssetHeader();
void displayRoMetaData(); void displayRoMetaData();
const char* getApiTypeStr(SdkApiString::ApiType type) const; const char* getApiTypeStr(SdkApiString::ApiType type) const;