diff --git a/trunk/ConsoleDataMigration/documents/Readme.txt b/trunk/ConsoleDataMigration/documents/Readme.txt index 04be9b5..d7aba81 100644 --- a/trunk/ConsoleDataMigration/documents/Readme.txt +++ b/trunk/ConsoleDataMigration/documents/Readme.txt @@ -16,6 +16,9 @@ QR ビルド時の注意 ------------ +### 無線自動ON/OFF, SNAKE判定 +Backupのビルド用に、CTR_SDK-3_3 branch に Auto_WiFi_and_Snake_version.patch を適用すること。 + ### AES鍵の変更 リリース用ビルドでは開発機・量産機でAES鍵を変えるため、 diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Auto_WiFi_and_Snake_version.patch b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Auto_WiFi_and_Snake_version.patch new file mode 100644 index 0000000..a6cf52a --- /dev/null +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Auto_WiFi_and_Snake_version.patch @@ -0,0 +1,268 @@ +Index: include/nn/CTR/CTR_ProgramId.h +=================================================================== +--- include/nn/CTR/CTR_ProgramId.h (revision 56666) ++++ include/nn/CTR/CTR_ProgramId.h (working copy) +@@ -1,8 +1,8 @@ +-/*---------------------------------------------------------------------------* ++サソ/*---------------------------------------------------------------------------* + Project: Horizon + File: CTR_ProgramId.h + +- Copyright (C)2009-2011 Nintendo Co., Ltd. All rights reserved. ++ Copyright (C)2009-2013 Nintendo Co., Ltd. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo +@@ -18,6 +18,7 @@ + + + #include ++#include + #include + + +@@ -53,7 +54,9 @@ + PROGRAM_ID_CATEGORY_FLAG_CONTENTS = 3, // 繧ウ繝ウ繝繝ウ繝 + PROGRAM_ID_CATEGORY_FLAG_ADD_ON_CONTENTS = 4, // 霑ス蜉繧ウ繝ウ繝繝ウ繝 + PROGRAM_ID_CATEGORY_FLAG_RIGHTS_ONLY = 5, // 讓ゥ蛻ゥ縺ョ縺ソ ++ PROGRAM_ID_CATEGORY_FLAG_PATCH = 6, // 繝代ャ繝 + ++ PROGRAM_ID_CATEGORY_FLAG_TYPE_MASK = (7 << 0), // 遞ョ鬘 + PROGRAM_ID_CATEGORY_FLAG_CANNOT_EXECUTION = (1 << 3), // 螳溯。御ク榊庄 + PROGRAM_ID_CATEGORY_FLAG_SYSTEM = (1 << 4), // 繧キ繧ケ繝繝 + PROGRAM_ID_CATEGORY_FLAG_REQUIRE_BATCH_UPDATE = (1 << 5), // 荳諡ャ繧「繝繝励ョ繝シ繝医′蠢隕 +@@ -120,11 +123,13 @@ + | PROGRAM_ID_CATEGORY_FLAG_CANNOT_EXECUTION + | PROGRAM_ID_CATEGORY_FLAG_NOT_REQUIRE_RIGHT_FOR_MOUNT ), + +- + // 讓ゥ蛻ゥ縺ョ縺ソ + PROGRAM_ID_CATEGORY_RIGHTS_ONLY = ( PROGRAM_ID_CATEGORY_FLAG_RIGHTS_ONLY + | PROGRAM_ID_CATEGORY_FLAG_CANNOT_EXECUTION ), + ++ // 繝代ャ繝 ++ PROGRAM_ID_CATEGORY_PATCH = ( PROGRAM_ID_CATEGORY_FLAG_PATCH ++ | PROGRAM_ID_CATEGORY_FLAG_CANNOT_EXECUTION ), + + PROGRAM_ID_CATEGORY_MAX_BITS = (1u << 15) + }; +@@ -133,6 +138,7 @@ + enum ProgramIdPlatform + { + PROGRAM_ID_PLATFORM_CTR, ++ PROGRAM_ID_PLATFORM_SNAKE = 2, + + PROGRAM_ID_PLATFORM_MAX_BITS = (1 << 3) + }; +@@ -148,7 +154,10 @@ + const int PROGRAM_ID_UNIQUE_ID_SHIFT = 8; + const int PROGRAM_ID_VARIATION_SHIFT = 0; + ++ const size_t PROGRAM_ID_PLATFORM_SIZE = 4; + ++ const bit64 PROGRAM_ID_PLATFORM_MASK = ((1ull << PROGRAM_ID_PLATFORM_SIZE) - 1) << PROGRAM_ID_PLATFORM_SHIFT; ++ + /* ------------------------------------------------------------------------ + ProgramId 菴懈宣未謨ー + ------------------------------------------------------------------------ */ +@@ -219,7 +228,6 @@ + } + + +- + /* ------------------------------------------------------------------------ + 螳壽焚螳夂セゥ縺ョ莉」繧上j + ------------------------------------------------------------------------ */ +@@ -251,6 +259,11 @@ + return 0x0004800000000000ull | (pgid & 0x00007FFFFFFFFFFFull); + } + ++ inline ProgramId ReplacePlatform(ProgramId pgid, ProgramIdPlatform platform) ++ { ++ return (pgid & ~PROGRAM_ID_PLATFORM_MASK) | (platform << PROGRAM_ID_PLATFORM_SHIFT); ++ } ++ + /* ------------------------------------------------------------------------ + 繧ォ繝繧エ繝ェ蛻、蛻・髢「謨ー + ------------------------------------------------------------------------ */ +@@ -259,12 +272,17 @@ + return (static_cast(pgid >> 32) & 0xFFFFC000) == 0x00040000; + } + +- // bit 1-2 ++ // bit 0-2 + inline bool IsContents(ProgramId pgid) + { +- return IsCtr(pgid) && ((GetCategoryOf(pgid) & 0x3) == PROGRAM_ID_CATEGORY_FLAG_CONTENTS); ++ return IsCtr(pgid) && ((GetCategoryOf(pgid) & PROGRAM_ID_CATEGORY_FLAG_TYPE_MASK) == PROGRAM_ID_CATEGORY_FLAG_CONTENTS); + } + ++ inline bool IsNormalApplication(ProgramId pgid) ++ { ++ return IsCtr(pgid) && ((GetCategoryOf(pgid) & PROGRAM_ID_CATEGORY_FLAG_TYPE_MASK) == PROGRAM_ID_CATEGORY_FLAG_NORMAL); ++ } ++ + // bit 4 + inline bool IsSystem(ProgramId pgid) + { +@@ -313,6 +331,11 @@ + | category == PROGRAM_ID_CATEGORY_APPLET ); + } + ++ inline bool IsExecutable(ProgramId pgid) ++ { ++ return (GetCategoryOf(pgid) & PROGRAM_ID_CATEGORY_FLAG_CANNOT_EXECUTION) == 0; ++ } ++ + inline bool IsCtrOrTwlSystem(ProgramId pgid) + { + return IsSystem(pgid) || IsTwlSystemApp(pgid); +@@ -333,6 +356,21 @@ + return IsCtr(pgid) && GetCategoryOf(pgid) == PROGRAM_ID_CATEGORY_RIGHTS_ONLY; + } + ++ inline bool IsPatch(ProgramId pgid) ++ { ++ return IsCtr(pgid) && GetCategoryOf(pgid) == PROGRAM_ID_CATEGORY_PATCH; ++ } ++ ++ inline bool HasInternalUniqueId(ProgramId pgid) ++ { ++ bit32 uid = GetUniqueIdOf(pgid); ++ return (uid < 0x00300) ++ || ((0xF8000 <= uid) && (uid < 0xFF000)) ++ || (0xFF400 <= uid); ++ } ++ ++ ++ + /* ------------------------------------------------------------------------ + 繧ウ繧「繝舌シ繧ク繝ァ繝ウ + ------------------------------------------------------------------------ */ +@@ -382,6 +420,30 @@ + // 螂謨ー縺ョ繝舌Μ繧ィ繝シ繧キ繝ァ繝ウ縺ッ髢狗匱逕ィ繧キ繧ケ繝繝縺ョ繝。繧ク繝」繝シ繝舌シ繧ク繝ァ繝ウ + return IsSystem(pgid) && (GetVariationOf(pgid) % 2) != 0; + } ++ ++ ++ ++ /* ------------------------------------------------------------------------ ++ 螟画鋤髢「謨ー ++ ------------------------------------------------------------------------ */ ++ inline ProgramId GetPatchTargetProgramId(ProgramId patchId) ++ { ++ NN_EQUAL_TASSERT_(GetCategoryOf(patchId), PROGRAM_ID_CATEGORY_PATCH); ++ ++ return MakeProgramId( ++ PROGRAM_ID_CATEGORY_APPLICATION, ++ GetUniqueIdOf(patchId), ++ GetVariationOf(patchId) ); ++ } ++ inline ProgramId GetPatchProgramIdOf(ProgramId appId) ++ { ++ NN_EQUAL_TASSERT_(GetCategoryOf(appId), PROGRAM_ID_CATEGORY_APPLICATION); ++ ++ return MakeProgramId( ++ PROGRAM_ID_CATEGORY_PATCH, ++ GetUniqueIdOf(appId), ++ GetVariationOf(appId) ); ++ } + }} + + +Index: include/nn/pl/CTR/pl_Version.h +=================================================================== +--- include/nn/pl/CTR/pl_Version.h (revision 56666) ++++ include/nn/pl/CTR/pl_Version.h (working copy) +@@ -2,7 +2,7 @@ + Project: Horizon + File: pl_Version.h + +- Copyright (C)2009-2011 Nintendo Co., Ltd. All rights reserved. ++ Copyright (C)2009-2013 Nintendo Co., Ltd. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo +@@ -10,7 +10,7 @@ + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + +- $Rev:$ ++ $Rev$ + *---------------------------------------------------------------------------*/ + + #ifndef NN_PL_CTR_PL_VERSION_H_ +@@ -35,12 +35,14 @@ + */ + struct CardUpdateVersion + { +- u8 microVersion; // 繝槭う繧ッ繝ュ繝舌シ繧ク繝ァ繝ウシ磯撼陦ィ遉コシ +- u8 minorVersion; // 繝槭う繝翫シ繝舌シ繧ク繝ァ繝ウ +- u8 majorVersion; // 繝。繧ク繝」繝シ繝舌シ繧ク繝ァ繝ウ ++ u8 microVersion; // 繝槭う繧ッ繝ュ繝舌シ繧ク繝ァ繝ウシ磯撼陦ィ遉コシ ++ u8 minorVersion; // 繝槭う繝翫シ繝舌シ繧ク繝ァ繝ウ ++ u8 majorVersion; // 繝。繧ク繝」繝シ繝舌シ繧ク繝ァ繝ウ + u8 reserved1; +- char region; // J:譌・譛ャ縲ゞ:蛹礼アウ縲・:谺ァ蟾槭サ雎ェ蟾槭≫ヲ +- u8 reserved2[3]; ++ char region; // J:譌・譛ャ縲ゞ:蛹礼アウ縲・:谺ァ蟾槭サ雎ェ蟾槭≫ヲ ++ u8 snakeMicroVersion; // snake逕ィ 繝槭う繧ッ繝ュ繝舌シ繧ク繝ァ繝ウシ磯撼陦ィ遉コシ ++ u8 snakeMinorVersion; // snake逕ィ 繝槭う繝翫シ繝舌シ繧ク繝ァ繝ウ ++ u8 snakeMajorVersion; // snake逕ィ 繝。繧ク繝」繝シ繝舌シ繧ク繝ァ繝ウ + }; + + /*! +Index: sources/libraries/nwm/CTR/nwm_ExtAPI.cpp +=================================================================== +--- sources/libraries/nwm/CTR/nwm_ExtAPI.cpp (revision 56666) ++++ sources/libraries/nwm/CTR/nwm_ExtAPI.cpp (working copy) +@@ -10,7 +10,7 @@ + not be disclosed to third parties or copied or duplicated in any form, + in whole or in part, without the prior written consent of Nintendo. + +- $Rev:$ ++ $Rev$ + *---------------------------------------------------------------------------*/ + + #include +@@ -123,15 +123,19 @@ + + nn::cfg::Initialize(); + ++#if 0 + // 繝繝舌ャ繧ー繝「繝シ繝峨ヵ繝ゥ繧ー縺梧怏蜉ケ縺ェ蝣エ蜷医ョ縺ソ縲∵桃菴懊r陦後≧縲 + if( nn::cfg::IsDebugMode() == true ) + { ++#endif + result = detail::Ext::PseudoToggleWifiButton(false); ++#if 0 + } + else + { + result = ResultNotAuthorized(); + } ++#endif + nn::cfg::Finalize(); + + return result; +@@ -143,15 +147,20 @@ + + nn::cfg::Initialize(); + ++#if 0 + // 繝繝舌ャ繧ー繝「繝シ繝峨ヵ繝ゥ繧ー縺梧怏蜉ケ縺ェ蝣エ蜷医ョ縺ソ縲∵桃菴懊r陦後≧縲 + if( nn::cfg::IsDebugMode() == true ) + { ++#endif + result = detail::Ext::PseudoToggleWifiButton(true); ++#if 0 + } + else + { + result = ResultNotAuthorized(); + } ++#endif ++ + nn::cfg::Finalize(); + + return result; diff --git a/trunk/ConsoleDataMigration/sources/common/Util.cpp b/trunk/ConsoleDataMigration/sources/common/Util.cpp index 25dc06e..01911bc 100644 --- a/trunk/ConsoleDataMigration/sources/common/Util.cpp +++ b/trunk/ConsoleDataMigration/sources/common/Util.cpp @@ -328,17 +328,38 @@ bit32 Util::GetDeviceId() u8 Util::GetCupMajorVersion() { - return m_VerData.cup.majorVersion; + if(m_VerData.isSnake) + { + return m_VerData.cup.snakeMajorVersion; + } + else + { + return m_VerData.cup.majorVersion; + } } u8 Util::GetCupMinorVersion() { - return m_VerData.cup.minorVersion; + if(m_VerData.isSnake) + { + return m_VerData.cup.snakeMinorVersion; + } + else + { + return m_VerData.cup.minorVersion; + } } u8 Util::GetCupMicroVersion() { - return m_VerData.cup.microVersion; + if(m_VerData.isSnake) + { + return m_VerData.cup.snakeMicroVersion; + } + else + { + return m_VerData.cup.microVersion; + } } u8 Util::GetNupVersion() diff --git a/trunk/ConsoleDataMigration/sources/common/VersionDetect.cpp b/trunk/ConsoleDataMigration/sources/common/VersionDetect.cpp index 052bc94..07f862e 100644 --- a/trunk/ConsoleDataMigration/sources/common/VersionDetect.cpp +++ b/trunk/ConsoleDataMigration/sources/common/VersionDetect.cpp @@ -66,7 +66,7 @@ void GetCupVersion(nn::pl::CTR::CardUpdateVersion* cup, nn::cfg::CTR::CfgRegionC } -void GetNupVersion(nn::pl::CTR::NetworkUpdateVersion* nup, nn::cfg::CTR::CfgRegionCode region) +void GetNupVersion(nn::pl::CTR::NetworkUpdateVersion* nup, bool* isSnake, nn::cfg::CTR::CfgRegionCode region) { nn::Result result; const size_t BUF_SIZE = 1024; @@ -74,9 +74,20 @@ void GetNupVersion(nn::pl::CTR::NetworkUpdateVersion* nup, nn::cfg::CTR::CfgRegi // NUP繝舌シ繧ク繝ァ繝ウ { - result = nn::fs::MountContent("nver:", nn::fs::MEDIA_TYPE_NAND, common::cNupVerId[region], 0, 1, 1, buf, - BUF_SIZE); - COMMON_LOGGER_RESULT_IF_FAILED(result); + nn::ProgramId snakeProgramId = nn::CTR::ReplacePlatform(common::cNupVerId[region], + nn::CTR::PROGRAM_ID_PLATFORM_SNAKE); + result = nn::fs::MountContent("nver:", nn::fs::MEDIA_TYPE_NAND, snakeProgramId, 0, 1, 1, buf, BUF_SIZE); + if (result.IsFailure()) + { + *isSnake = false; + result = nn::fs::MountContent("nver:", nn::fs::MEDIA_TYPE_NAND, common::cNupVerId[region], 0, 1, 1, buf, + BUF_SIZE); + COMMON_LOGGER_RESULT_IF_FAILED(result); + } + else + { + *isSnake = true; + } nn::fs::FileInputStream fis; @@ -113,7 +124,7 @@ void GetNupVersion(nn::pl::CTR::NetworkUpdateVersion* nup, nn::cfg::CTR::CfgRegi void GetSystemVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region) { GetCupVersion(&mVerData->cup, region); - GetNupVersion(&mVerData->nup, region); + GetNupVersion(&mVerData->nup, &mVerData->isSnake, region); } } diff --git a/trunk/ConsoleDataMigration/sources/common/common_Types.h b/trunk/ConsoleDataMigration/sources/common/common_Types.h index 6fb0b6d..06da230 100644 --- a/trunk/ConsoleDataMigration/sources/common/common_Types.h +++ b/trunk/ConsoleDataMigration/sources/common/common_Types.h @@ -62,6 +62,9 @@ struct VerDef { nn::pl::CTR::CardUpdateVersion cup; nn::pl::CTR::NetworkUpdateVersion nup; + bool isSnake; + NN_PADDING3; + NN_PADDING4; }; // TODO:繝ェ繝シ繧ク繝ァ繝ウ霑ス蜉譎ゅ↓遽蝗イ螟悶い繧ッ繧サ繧ケ縺ォ縺ェ繧峨↑縺繧医≧豕ィ諢