From 674f831ac99c93fc997ff94d21084dbbd793d870 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 4 Dec 2020 10:45:13 +0100 Subject: [PATCH] Store hashes for title.tmd with and without certs --- source/ApplicationState.cpp | 10 +++++----- source/InstallerService.cpp | 11 +++++++++-- source/InstallerService.h | 2 +- source/common/common.cpp | 6 +++--- source/common/common.h | 1 + 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/source/ApplicationState.cpp b/source/ApplicationState.cpp index a2a8717..cc424c0 100644 --- a/source/ApplicationState.cpp +++ b/source/ApplicationState.cpp @@ -268,12 +268,12 @@ ApplicationState::ApplicationState() { void ApplicationState::checkPatchPossible() { DEBUG_FUNCTION_LINE("Check patch possible"); - InstallerService::eResults result; + this->fstAlreadyPatched = (InstallerService::checkFSTAlreadyValid(this->appInfo->path, this->appInfo->fstHash) == InstallerService::SUCCESS); + this->rpxAlreadyPatched = (InstallerService::checkRPXAlreadyValid(this->appInfo->path, RPX_HASH) == InstallerService::SUCCESS); + this->cosAlreadyPatched = (InstallerService::checkCOSAlreadyValid(this->appInfo->path, this->appInfo->cosHash) == InstallerService::SUCCESS); + this->tmdValid = (InstallerService::checkTMDValid(this->appInfo->path, this->appInfo->tmdHash, this->appInfo->tmdWithCertHash) == InstallerService::SUCCESS); - this->fstAlreadyPatched = ((result = InstallerService::checkFSTAlreadyValid(this->appInfo->path, this->appInfo->fstHash)) == InstallerService::SUCCESS); - this->rpxAlreadyPatched = ((result = InstallerService::checkRPXAlreadyValid(this->appInfo->path, RPX_HASH)) == InstallerService::SUCCESS); - this->cosAlreadyPatched = ((result = InstallerService::checkCOSAlreadyValid(this->appInfo->path, this->appInfo->cosHash)) == InstallerService::SUCCESS); - this->tmdValid = ((result = InstallerService::checkTMDValid(this->appInfo->path, this->appInfo->tmdHash)) == InstallerService::SUCCESS); + InstallerService::eResults result; this->fstPatchPossible = ((result = InstallerService::checkFST(this->appInfo->path, this->appInfo->fstHash)) == InstallerService::SUCCESS); if (result != InstallerService::SUCCESS) { diff --git a/source/InstallerService.cpp b/source/InstallerService.cpp index 63691bb..e827c1d 100644 --- a/source/InstallerService.cpp +++ b/source/InstallerService.cpp @@ -721,9 +721,16 @@ InstallerService::eResults InstallerService::checkFSTAlreadyValid(const std::str return checkFileHash(filePath, hash); } -InstallerService::eResults InstallerService::checkTMDValid(const std::string &path, const std::string &hash) { +InstallerService::eResults InstallerService::checkTMDValid(const std::string &path, const std::string &hash, const std::string &tmdWithCertHash) { std::string filePath = path + "/code/title.tmd"; - return checkFileHash(filePath, hash); + + InstallerService::eResults result = checkFileHash(filePath, hash); + + if(result != SUCCESS){ + // In some cases the tmd seems to have cert appended + return checkFileHash(filePath, tmdWithCertHash); + } + return result; } InstallerService::eResults InstallerService::checkCOSAlreadyValid(const std::string &path, const std::string &hash) { diff --git a/source/InstallerService.h b/source/InstallerService.h index 612c572..30868c5 100644 --- a/source/InstallerService.h +++ b/source/InstallerService.h @@ -75,7 +75,7 @@ public: static eResults checkFSTAlreadyValid(const std::string &path, const std::string &hash); - static eResults checkTMDValid(const std::string &path, const std::string &hash); + static eResults checkTMDValid(const std::string &path, const std::string &hash, const std::string &tmdWithCertHash); static eResults checkCOSAlreadyValid(const std::string &path, const std::string &hash); diff --git a/source/common/common.cpp b/source/common/common.cpp index 3baa01c..c56266f 100644 --- a/source/common/common.cpp +++ b/source/common/common.cpp @@ -11,9 +11,9 @@ systemXMLInformation systemXMLHashInformation[] = { }; appInformation supportedApps[] = { - {0x000500101004E000L, "Health and Safety Information [JPN]", false, {'\0'}, "9D34DDD91604D781FDB0727AC75021833304964C", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "2CF358E1F51932D305911A6836ED37DB0F94ABE4"}, - {0x000500101004E100L, "Health and Safety Information [USA]", false, {'\0'}, "045734666A36C7EF0258A740855886EBDB20D59B", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "C53C219FB8F777F9AB8F430D6BE4BC034D5638BA"}, - {0x000500101004E200L, "Health and Safety Information [PAL]", false, {'\0'}, "130A76F8B36B36D43B88BBC74393D9AFD9CFD2A4", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "4A29A60E5FBDAF410B7C22ECAEBDDBF29D1A874E"}, + {0x000500101004E000L, "Health and Safety Information [JPN]", false, {'\0'}, "9D34DDD91604D781FDB0727AC75021833304964C", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "D5BABA20526524977009F7EDE25182D8E41CEFD8", "2CF358E1F51932D305911A6836ED37DB0F94ABE4"}, //v129 + {0x000500101004E100L, "Health and Safety Information [USA]", false, {'\0'}, "045734666A36C7EF0258A740855886EBDB20D59B", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "5249DA6B75FEFADEBFBB18ECC93CC109FA8AA630", "C53C219FB8F777F9AB8F430D6BE4BC034D5638BA"}, //v129 + {0x000500101004E200L, "Health and Safety Information [PAL]", false, {'\0'}, "130A76F8B36B36D43B88BBC74393D9AFD9CFD2A4", "F6EBF7BC8AE3AF3BB8A42E0CF3FDA051278AEB03", "87749A8D3EE8694225423953DCF04B01F8DA2F15", "4A29A60E5FBDAF410B7C22ECAEBDDBF29D1A874E"}, //v129 {0, nullptr, false, {'\0'}, {'\0'}, {'\0'}}, }; diff --git a/source/common/common.h b/source/common/common.h index 9a18234..6520ea5 100644 --- a/source/common/common.h +++ b/source/common/common.h @@ -34,6 +34,7 @@ typedef struct compatApps { char fstHash[41]; char cosHash[41]; char tmdHash[41]; + char tmdWithCertHash[41]; } appInformation; typedef struct _gList_t {