diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL.ncb b/build/tools/MasterEditorTWL/MasterEditorTWL.ncb index 6af778b8..ecf5f183 100644 Binary files a/build/tools/MasterEditorTWL/MasterEditorTWL.ncb and b/build/tools/MasterEditorTWL/MasterEditorTWL.ncb differ diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL.suo b/build/tools/MasterEditorTWL/MasterEditorTWL.suo index 0b42579e..c33acaf5 100644 Binary files a/build/tools/MasterEditorTWL/MasterEditorTWL.suo and b/build/tools/MasterEditorTWL/MasterEditorTWL.suo differ diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL/Debug/BuildLog.htm b/build/tools/MasterEditorTWL/MasterEditorTWL/Debug/BuildLog.htm index 92fcd773..c47a85b5 100644 Binary files a/build/tools/MasterEditorTWL/MasterEditorTWL/Debug/BuildLog.htm and b/build/tools/MasterEditorTWL/MasterEditorTWL/Debug/BuildLog.htm differ diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL/Release/BuildLog.htm b/build/tools/MasterEditorTWL/MasterEditorTWL/Release/BuildLog.htm index ebd8ad1f..6bf07e65 100644 Binary files a/build/tools/MasterEditorTWL/MasterEditorTWL/Release/BuildLog.htm and b/build/tools/MasterEditorTWL/MasterEditorTWL/Release/BuildLog.htm differ diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL/srl.cpp b/build/tools/MasterEditorTWL/MasterEditorTWL/srl.cpp index efb2b489..dae559c7 100644 --- a/build/tools/MasterEditorTWL/MasterEditorTWL/srl.cpp +++ b/build/tools/MasterEditorTWL/MasterEditorTWL/srl.cpp @@ -77,6 +77,16 @@ ECSrlResult RCSrl::readFromFile( System::String ^filename ) } } +#ifdef METWL_WHETHER_SIGN_DECRYPT + // まず署名チェック + r = this->decryptRomHeader(); + if( r != ECSrlResult::NOERROR ) + { + (void)fclose(fp); + return r; + } +#endif //#ifdef METWL_WHETHER_SIGN_DECRYPT + // エラーリストをクリア this->hErrorList = gcnew System::Collections::Generic::List; this->hWarnList = gcnew System::Collections::Generic::List; @@ -88,16 +98,6 @@ ECSrlResult RCSrl::readFromFile( System::String ^filename ) // ROMヘッダの値をROM固有情報フィールドに反映させる (void)this->setRomInfo(); -#ifdef METWL_WHETHER_SIGN_DECRYPT - // ひととおり読んだあとに署名チェック - r = this->decryptRomHeader(); - if( r != ECSrlResult::NOERROR ) - { - (void)fclose(fp); - return r; - } -#endif //#ifdef METWL_WHETHER_SIGN_DECRYPT - // すべて設定したあとにMRC { ECSrlResult r; @@ -662,23 +662,25 @@ ECSrlResult RCSrl::decryptRomHeader(void) // (1) 公開鍵で復号した結果(ブロック)をローカル変数(original)に格納 // (2) ブロックから余分な部分を取り除いて引数(pDst)にコピー + ECAppType type = this->selectAppType(); + // 鍵を選ぶ #ifdef METWL_VER_APPTYPE_LAUNCHER - if( *this->hIsAppLauncher ) + if( type == ECAppType::LAUNCHER ) { publicKey = (u8*)g_devPubKey_DER_launcher; } else #endif //METWL_VER_APPTYPE_LAUNCHER #ifdef METWL_VER_APPTYPE_SECURE - if( *this->hIsAppSecure ) + if( type == ECAppType::SECURE ) { publicKey = (u8*)g_devPubKey_DER_secure; } else #endif //METWL_VER_APPTYPE_SECURE #ifdef METWL_VER_APPTYPE_SYSTEM - if( *this->hIsAppSystem ) + if( type == ECAppType::SYSTEM ) { publicKey = (u8*)g_devPubKey_DER_system; } @@ -715,6 +717,35 @@ ECSrlResult RCSrl::decryptRomHeader(void) return (ECSrlResult::NOERROR); } +// +// アプリ種別の判定 +// +ECAppType RCSrl::selectAppType(void) +{ + ECAppType type = ECAppType::ILLEGAL; + + u8 *idL = this->pRomHeader->s.titleID_Lo; + u32 idH = this->pRomHeader->s.titleID_Hi; + + if( (idL[3]=='H') && (idL[2]=='N') && (idL[1]=='A') ) // ランチャアプリかどうかはTitleID_Loの値で決定 + { + type = ECAppType::LAUNCHER; + } + else if( idH & TITLE_ID_HI_SECURE_FLAG_MASK ) // 各ビットは排他的とは限らないのでelse ifにはならない + { + type = ECAppType::SECURE; + } + else if( (idH & TITLE_ID_HI_APP_TYPE_MASK) == 1 ) + { + type = ECAppType::SYSTEM; + } + else if( (idH & TITLE_ID_HI_APP_TYPE_MASK) == 0 ) + { + type = ECAppType::USER; + } + return type; +} + // // DSダウンロード署名がSRLに格納されているか調べる // diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL/srl.h b/build/tools/MasterEditorTWL/MasterEditorTWL/srl.h index a3a44d3d..532f3fb7 100644 --- a/build/tools/MasterEditorTWL/MasterEditorTWL/srl.h +++ b/build/tools/MasterEditorTWL/MasterEditorTWL/srl.h @@ -38,6 +38,21 @@ namespace MasterEditorTWL ERROR_PLATFORM, }; + // ------------------------------------------------------------------- + // Type : enum class + // Name : ECAppType + // + // Description : RCSrlクラスのアプリ種別を宣言 + // ------------------------------------------------------------------- + enum class ECAppType + { + USER = 0, + SYSTEM, + SECURE, + LAUNCHER, + ILLEGAL, // 不定 + }; + // ------------------------------------------------------------------- // Type : ref class // Name : RCSDKVersion @@ -362,6 +377,7 @@ namespace MasterEditorTWL // @arg [in] 入力ファイルのFP (->SRL読み込み時に実行されるべき)] ECSrlResult searchSDKVersion( FILE *fp ); // SDKバージョンを取得する ECSrlResult searchLicenses( FILE *fp ); // 使用ライセンスを取得する + ECAppType selectAppType(void); // MRC(Master ROM Checker)機能 ECSrlResult mrc( FILE *fp );