diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL.ncb b/build/tools/MasterEditorTWL/MasterEditorTWL.ncb index 3fa85b4f..809f9097 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 5f0cbd28..306bafb6 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 7960e606..a6eeed79 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/Form1.h b/build/tools/MasterEditorTWL/MasterEditorTWL/Form1.h index 5c9653be..e14da974 100644 --- a/build/tools/MasterEditorTWL/MasterEditorTWL/Form1.h +++ b/build/tools/MasterEditorTWL/MasterEditorTWL/Form1.h @@ -3187,12 +3187,25 @@ private: System::Windows::Forms::GroupBox^ gboxMakeMaster; // SRLのオープン System::Void loadSrl( System::String ^filename ) { - if( this->hSrl->readFromFile( filename ) != ECSrlResult::NOERROR ) + ECSrlResult result = this->hSrl->readFromFile( filename ); + if( result != ECSrlResult::NOERROR ) { - if( this->rSelectJ->Checked == true ) - this->errMsg( "リードに失敗しました。" ); - else - this->errMsg( "Reading the file failed." ); + switch( result ) + { + case ECSrlResult::ERROR_PLATFORM: + if( this->rSelectJ->Checked == true ) + this->errMsg( "本ツールはTWL対応ROM専用です。NTR専用ROMなどのTWL対応ROM以外を読み込むことはできません。" ); + else + this->errMsg( "This tool can only read TWL ROM. This can't read Other data e.g. NTR limited ROM." ); + break; + + default: + if( this->rSelectJ->Checked == true ) + this->errMsg( "リードに失敗しました。" ); + else + this->errMsg( "Reading the file failed." ); + break; + } return; // 前のファイルが正常である保証なしなので前のファイルも上書き保存できないようにする } this->tboxFile->Text = filename; @@ -3391,12 +3404,6 @@ private: System::Windows::Forms::GroupBox^ gboxMakeMaster; { this->tboxIsCodec->Text = gcnew System::String( "NTR" ); } - //this->cboxIsRegionJapan->Checked = *(this->hSrl->hIsRegionJapan); - //this->cboxIsRegionAmerica->Checked = *(this->hSrl->hIsRegionAmerica); - //this->cboxIsRegionEurope->Checked = *(this->hSrl->hIsRegionEurope); - //this->cboxIsRegionAustralia->Checked = *(this->hSrl->hIsRegionAustralia); - //this->cboxIsRegionChina->Checked = *(this->hSrl->hIsRegionChina); - //this->cboxIsRegionKorea->Checked = *(this->hSrl->hIsRegionKorea); this->cboxIsSD->Checked = *(this->hSrl->hIsSD); this->cboxIsNAND->Checked = *(this->hSrl->hIsNAND); if( *(this->hSrl->hIsGameCardNitro) == true ) diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL/keys.cpp b/build/tools/MasterEditorTWL/MasterEditorTWL/keys.cpp index 6d7d6c3c..1c2d2f5c 100644 --- a/build/tools/MasterEditorTWL/MasterEditorTWL/keys.cpp +++ b/build/tools/MasterEditorTWL/MasterEditorTWL/keys.cpp @@ -8,7 +8,7 @@ namespace MasterEditorTWL { // ユーザアプリ用 - // 開発アプリROMヘッダ署名用公開鍵 + // 開発機用ROMヘッダ署名公開鍵 const u8 g_devPubKey_DER[ 0xa2 ] = { 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xAC, 0x93, 0xBB, @@ -22,8 +22,7 @@ namespace MasterEditorTWL 0xC9, 0x6F, 0x31, 0x8D, 0x23, 0x57, 0x3D, 0xB6, 0x6C, 0xEE, 0xC2, 0x0D, 0x11, 0x02, 0x03, 0x01, 0x00, 0x01, }; - - // 開発アプリROMヘッダ署名用秘密鍵 + // 開発機用アプリROMヘッダ署名秘密鍵 const u8 g_devPrivKey_DER[ 0x263 ] = { 0x30, 0x82, 0x02, 0x5F, 0x02, 0x01, 0x00, 0x02, 0x81, 0x81, 0x00, 0xAC, 0x93, 0xBB, 0x3C, 0x15, 0x5C, 0x5F, 0x25, 0xB0, 0x4C, 0x37, 0xA4, 0x2D, 0x85, 0x29, 0x1D, 0x7A, 0x9D, 0x2D, 0xD5, 0x79, diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL/keys.h b/build/tools/MasterEditorTWL/MasterEditorTWL/keys.h index 9ede7f2d..59c91f47 100644 --- a/build/tools/MasterEditorTWL/MasterEditorTWL/keys.h +++ b/build/tools/MasterEditorTWL/MasterEditorTWL/keys.h @@ -6,9 +6,7 @@ namespace MasterEditorTWL { - - // 開発アプリROMヘッダ署名用秘密鍵 - + // 開発機用ROMヘッダ署名鍵 extern const u8 g_devPubKey_DER[ 0xa2 ]; extern const u8 g_devPrivKey_DER[ 0x263 ]; diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL/srl.cpp b/build/tools/MasterEditorTWL/MasterEditorTWL/srl.cpp index 6582106d..9a5523ed 100644 --- a/build/tools/MasterEditorTWL/MasterEditorTWL/srl.cpp +++ b/build/tools/MasterEditorTWL/MasterEditorTWL/srl.cpp @@ -286,19 +286,11 @@ ECSrlResult RCSrl::setRomInfo(void) } // カードリージョン - const u32 maskJapan = 0x00000001; - const u32 maskAmerica = 0x00000002; - const u32 maskEurope = 0x00000004; - const u32 maskAustralia = 0x00000008; - const u32 maskChina = 0x00000010; - const u32 maskKorea = 0x00000020; const u32 map = this->pRomHeader->s.card_region_bitmap; - this->hIsRegionJapan = gcnew System::Boolean( ((map & maskJapan) != 0)?true:false ); - this->hIsRegionAmerica = gcnew System::Boolean( ((map & maskAmerica) != 0)?true:false ); - this->hIsRegionEurope = gcnew System::Boolean( ((map & maskEurope) != 0)?true:false ); - this->hIsRegionAustralia = gcnew System::Boolean( ((map & maskAustralia) != 0)?true:false ); - //this->hIsRegionChina = gcnew System::Boolean( ((map & maskChina) != 0)?true:false ); - //this->hIsRegionKorea = gcnew System::Boolean( ((map & maskKorea) != 0)?true:false ); + this->hIsRegionJapan = gcnew System::Boolean( ((map & METWL_MASK_REGION_JAPAN) != 0)?true:false ); + this->hIsRegionAmerica = gcnew System::Boolean( ((map & METWL_MASK_REGION_AMERICA) != 0)?true:false ); + this->hIsRegionEurope = gcnew System::Boolean( ((map & METWL_MASK_REGION_EUROPE) != 0)?true:false ); + this->hIsRegionAustralia = gcnew System::Boolean( ((map & METWL_MASK_REGION_AUSTRALIA) != 0)?true:false ); return ECSrlResult::NOERROR; } // ECSrlResult RCSrl::setRomInfo(void) @@ -320,19 +312,19 @@ ECSrlResult RCSrl::setRomHeader(void) this->pRomHeader->s.exFlags.DSWirelessIcon = (*(this->hIsWirelessIcon) == true)?1:0; // レーティング - const u32 maskJapan = 0x00000001; - const u32 maskAmerica = 0x00000002; - const u32 maskEurope = 0x00000004; - const u32 maskAustralia = 0x00000008; - //const u32 maskChina = 0x00000010; - //const u32 maskKorea = 0x00000020; u32 map = 0; - if( *(this->hIsRegionJapan) == true ) { map |= maskJapan; } - if( *(this->hIsRegionAmerica) == true ) { map |= maskAmerica; } - if( *(this->hIsRegionEurope) == true ) { map |= maskEurope; } - if( *(this->hIsRegionAustralia) == true ){ map |= maskAustralia; } - //if( *(this->hIsRegionChina) == true ) { map |= maskChina; } - //if( *(this->hIsRegionKorea) == true ) { map |= maskKorea; } + if( *(this->hIsRegionJapan) == true ) { map |= METWL_MASK_REGION_JAPAN; } + if( *(this->hIsRegionAmerica) == true ) { map |= METWL_MASK_REGION_AMERICA; } + if( *(this->hIsRegionEurope) == true ) { map |= METWL_MASK_REGION_EUROPE; } + if( *(this->hIsRegionAustralia) == true ){ map |= METWL_MASK_REGION_AUSTRALIA; } +#if defined(METWL_VER_APPTYPE_SYSTEM) || defined(METWL_VER_APPTYPE_SECURE) || defined(METWL_VER_APPTYPE_LAUNCHER) + if( (*(this->hIsRegionJapan) == true ) && (*(this->hIsRegionAmerica) == true) + && (*(this->hIsRegionEurope) == true ) && (*(this->hIsRegionAustralia) == true) + ) + { + map |= METWL_MASK_REGION_ALL; // オールリージョンを許す + } +#endif this->pRomHeader->s.card_region_bitmap = map; // ペアレンタルコントロール @@ -835,7 +827,16 @@ ECSrlResult RCSrl::mrcTWL( FILE *fp ) { System::Int32 i; - // ROMヘッダのチェック + // ROMヘッダのチェック (NTR互換領域) + +#ifdef METWL_WHETHER_PLATFORM_CHECK + // プラットフォームのチェック + if( (this->pRomHeader->s.platform_code != PLATFORM_CODE_TWL_HYBLID) && + (this->pRomHeader->s.platform_code != PLATFORM_CODE_TWL_LIMITED) ) + { + return ECSrlResult::ERROR_PLATFORM; + } +#endif // 値チェック u32 romsize = 1 << (this->pRomHeader->s.rom_size); // ROM容量 @@ -845,6 +846,12 @@ ECSrlResult RCSrl::mrcTWL( FILE *fp ) "デバイス容量", 0x14, 0x14, "指定可能な容量ではありません。", "Device Capacity", "Invalid capacity.", false ) ); } + if( (this->pRomHeader->s.game_cmd_param & CARD_LATENCY_MASK) != CARD_1TROM_GAME_LATENCY ) + { + this->hErrorList->Add( gcnew RCMRCError( + "ROMコントロール情報", 0x60, 0x67, "TWLではマスクROMは用意されていません。ワンタイムPROM設定にしてください。", + "ROM Control Info.", "Mask ROM can be set. Please set One-time PROM.", false ) ); + } // 予約領域 for( i=0; i < 7; i++ ) @@ -856,6 +863,40 @@ ECSrlResult RCSrl::mrcTWL( FILE *fp ) "Reserved Area A", "Invalid data is included. Please set 0 into this area.", false ) ); } } + for( i=0; i < 39; i++ ) + { + if( this->pRomHeader->s.reserved_B[i] != 0 ) + { + this->hErrorList->Add( gcnew RCMRCError( + "予約領域B", 0x099, 0x0bf, "不正な値が含まれています。この領域をすべて0で埋めてください。", + "Reserved Area B", "Invalid data is included. Please set 0 into this area.", false ) ); + } + } + + // ROMヘッダのチェック (TWL専用領域) + + // 値チェック + u32 region = this->pRomHeader->s.card_region_bitmap; + if( (region != METWL_MASK_REGION_JAPAN) && + (region != METWL_MASK_REGION_AMERICA) && + (region != METWL_MASK_REGION_EUROPE) && + (region != (METWL_MASK_REGION_EUROPE | METWL_MASK_REGION_AUSTRALIA)) ) + { +#if defined(METWL_VER_APPTYPE_SYSTEM) || defined(METWL_VER_APPTYPE_SECURE) || defined(METWL_VER_APPTYPE_LAUNCHER) + if( region != METWL_MASK_REGION_ALL ) // オールリージョンを許す + { + this->hErrorList->Add( gcnew RCMRCError( + "カードリージョン", 0x1b0, 0x1b3, "仕向地の組み合わせが不正です。本ツールを用いて修正できます。", + "Card Region", "Illigal Region. This tool can modify this information.", true ) ); + } +#else + { + this->hErrorList->Add( gcnew RCMRCError( + "カードリージョン", 0x1b0, 0x1b3, "仕向地の組み合わせが不正です。本ツールを用いて修正できます。", + "Card Region", "Illigal Region. This tool can modify this information.", true ) ); + } +#endif + } // ROMヘッダ以外の領域のチェック diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL/srl.h b/build/tools/MasterEditorTWL/MasterEditorTWL/srl.h index 61a82b32..357b6515 100644 --- a/build/tools/MasterEditorTWL/MasterEditorTWL/srl.h +++ b/build/tools/MasterEditorTWL/MasterEditorTWL/srl.h @@ -6,11 +6,6 @@ #include #include -// 宣言 -#define METWL_ERRLIST_NORANGE 0 // エラーのアドレス範囲を指定しないことを表す特別な値 -#define METWL_ROMSIZE_MIN 256 // 最小のデバイス容量 256Mbit -#define METWL_ROMSIZE_MAX 4096 // 最大の.. 4Gbit - namespace MasterEditorTWL { // ------------------------------------------------------------------- @@ -36,6 +31,8 @@ namespace MasterEditorTWL ERROR_SIGN_CRC, // SDKバージョン取得でのエラー ERROR_SDK, + // プラットフォームがNTR専用 or 不正バイナリ + ERROR_PLATFORM, }; // ------------------------------------------------------------------- @@ -264,8 +261,6 @@ namespace MasterEditorTWL property System::Boolean ^hIsRegionAmerica; property System::Boolean ^hIsRegionEurope; property System::Boolean ^hIsRegionAustralia; - //property System::Boolean ^hRegionChina; - //property System::Boolean ^hRegionKorea; // SDKバージョンと使用ライブラリのリスト property System::Collections::Generic::List ^hSDKList; diff --git a/build/tools/MasterEditorTWL/MasterEditorTWL/stdafx.h b/build/tools/MasterEditorTWL/MasterEditorTWL/stdafx.h index 6c1fb4be..a82ab9e0 100644 --- a/build/tools/MasterEditorTWL/MasterEditorTWL/stdafx.h +++ b/build/tools/MasterEditorTWL/MasterEditorTWL/stdafx.h @@ -4,3 +4,23 @@ #pragma once // TODO: プログラムに必要な追加ヘッダーをここで参照してください。 + +// ビルドオプション +#define METWL_VER_APPTYPE_USER +//#define METWL_VER_APPTYPE_SYSTEM +//#define METWL_VER_APPTYPE_SECURE +//#define METWL_VER_APPTYPE_LAUNCHER + +//#define METWL_WHETHER_PLATFORM_CHECK // プラットフォームがTWL対応以外かどうかをチェックする + +// 宣言 +#define METWL_ERRLIST_NORANGE 0 // エラーのアドレス範囲を指定しないことを表す特別な値 +#define METWL_ROMSIZE_MIN 256 // 最小のデバイス容量 256Mbit +#define METWL_ROMSIZE_MAX 4096 // 最大の.. 4Gbit +#define METWL_MASK_REGION_JAPAN 0x00000001 +#define METWL_MASK_REGION_AMERICA 0x00000002 +#define METWL_MASK_REGION_EUROPE 0x00000004 +#define METWL_MASK_REGION_AUSTRALIA 0x00000008 +#define METWL_MASK_REGION_CHINA 0x00000010 +#define METWL_MASK_REGION_KOREA 0x00000020 +#define METWL_MASK_REGION_ALL 0xffffffff