mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
SNAKE用のnup_versionがマウントできたかどうかでSNAKE判定するように。
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@813 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
dbba8b9c24
commit
bcf6adf349
@ -16,6 +16,9 @@ QR
|
||||
|
||||
ビルド時の注意
|
||||
------------
|
||||
### 無線自動ON/OFF, SNAKE判定
|
||||
Backupのビルド用に、CTR_SDK-3_3 branch に Auto_WiFi_and_Snake_version.patch を適用すること。
|
||||
|
||||
### AES鍵の変更
|
||||
リリース用ビルドでは開発機・量産機でAES鍵を変えるため、
|
||||
|
||||
|
||||
@ -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 <nn/types.h>
|
||||
+#include <nn/assert.h>
|
||||
#include <nn/math/math_Utility.h>
|
||||
|
||||
|
||||
@@ -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 @@
|
||||
}
|
||||
|
||||
|
||||
-
|
||||
/* ------------------------------------------------------------------------
|
||||
定数定義の代わり
|
||||
------------------------------------------------------------------------ */
|
||||
@@ -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<bit32>(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:日本、U:北米、E:欧州・豪州、…
|
||||
- u8 reserved2[3];
|
||||
+ char region; // J:日本、U:北米、E:欧州・豪州、…
|
||||
+ 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 <nn/srv.h>
|
||||
@@ -123,15 +123,19 @@
|
||||
|
||||
nn::cfg::Initialize();
|
||||
|
||||
+#if 0
|
||||
// デバッグモードフラグが有効な場合のみ、操作を行う。
|
||||
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
|
||||
// デバッグモードフラグが有効な場合のみ、操作を行う。
|
||||
if( nn::cfg::IsDebugMode() == true )
|
||||
{
|
||||
+#endif
|
||||
result = detail::Ext::PseudoToggleWifiButton(true);
|
||||
+#if 0
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ResultNotAuthorized();
|
||||
}
|
||||
+#endif
|
||||
+
|
||||
nn::cfg::Finalize();
|
||||
|
||||
return result;
|
||||
@ -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()
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -62,6 +62,9 @@ struct VerDef
|
||||
{
|
||||
nn::pl::CTR::CardUpdateVersion cup;
|
||||
nn::pl::CTR::NetworkUpdateVersion nup;
|
||||
bool isSnake;
|
||||
NN_PADDING3;
|
||||
NN_PADDING4;
|
||||
};
|
||||
|
||||
// TODO:リージョン追加時に範囲外アクセスにならないよう注意
|
||||
|
||||
Loading…
Reference in New Issue
Block a user