From 5af7558a1b83c044da49b2bf47fbf934784e804b Mon Sep 17 00:00:00 2001 From: jakcron Date: Mon, 5 Nov 2018 14:54:30 +0800 Subject: [PATCH] [nstool] Add definitons and code for recognising INI/KIP files. --- programs/nstool/source/UserSettings.cpp | 16 ++++++++++++++-- programs/nstool/source/common.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/programs/nstool/source/UserSettings.cpp b/programs/nstool/source/UserSettings.cpp index 186eb33..e1e2675 100644 --- a/programs/nstool/source/UserSettings.cpp +++ b/programs/nstool/source/UserSettings.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -52,7 +54,7 @@ void UserSettings::showHelp() printf("\n General Options:\n"); printf(" -d, --dev Use devkit keyset.\n"); printf(" -k, --keyset Specify keyset file.\n"); - printf(" -t, --type Specify input file type. [xci, pfs, romfs, nca, meta, cnmt, nso, nro, nacp, aset, cert, tik]\n"); + printf(" -t, --type Specify input file type. [xci, pfs, romfs, nca, meta, cnmt, nso, nro, ini, kip, nacp, aset, cert, tik]\n"); printf(" -y, --verify Verify file.\n"); printf("\n Output Options:\n"); printf(" --showkeys Show keys generated.\n"); @@ -610,6 +612,10 @@ FileType UserSettings::getFileTypeFromString(const std::string& type_str) type = FILE_NSO; else if (str == "nro") type = FILE_NRO; + else if (str == "ini") + type = FILE_INI; + else if (str == "kip") + type = FILE_KIP; else if (str == "nacp") type = FILE_NACP; else if (str == "cert") @@ -665,9 +671,15 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path) // test nso else if (_ASSERT_SIZE(sizeof(nn::hac::sNsoHeader)) && _TYPE_PTR(nn::hac::sNsoHeader)->st_magic.get() == nn::hac::nso::kNsoStructMagic) file_type = FILE_NSO; - // test nso + // test nro else if (_ASSERT_SIZE(sizeof(nn::hac::sNroHeader)) && _TYPE_PTR(nn::hac::sNroHeader)->st_magic.get() == nn::hac::nro::kNroStructMagic) file_type = FILE_NRO; + // test ini + else if (_ASSERT_SIZE(sizeof(nn::hac::sIniHeader)) && _TYPE_PTR(nn::hac::sIniHeader)->st_magic.get() == nn::hac::ini::kIniStructMagic) + file_type = FILE_INI; + // test kip + else if (_ASSERT_SIZE(sizeof(nn::hac::sKipHeader)) && _TYPE_PTR(nn::hac::sKipHeader)->st_magic.get() == nn::hac::kip::kKipStructMagic) + file_type = FILE_KIP; // test pki certificate else if (determineValidEsCertFromSample(scratch)) file_type = FILE_PKI_CERT; diff --git a/programs/nstool/source/common.h b/programs/nstool/source/common.h index 7b34922..d8f637e 100644 --- a/programs/nstool/source/common.h +++ b/programs/nstool/source/common.h @@ -20,6 +20,8 @@ enum FileType FILE_NSO, FILE_NRO, FILE_NACP, + FILE_INI, + FILE_KIP, FILE_PKI_CERT, FILE_ES_TIK, FILE_HB_ASSET,