From 26e053cf0b268792bf09c2db079a1206eeb2c83c Mon Sep 17 00:00:00 2001 From: N2614 Date: Wed, 26 Oct 2011 08:23:44 +0000 Subject: [PATCH] =?UTF-8?q?1.5CUP=E6=B8=88=E3=81=BF=E6=9C=AC=E4=BD=93?= =?UTF-8?q?=E3=81=AE=E5=A0=B4=E5=90=88=20or=20IVS=E5=8F=96=E5=BE=97?= =?UTF-8?q?=E3=83=A2=E3=83=BC=E3=83=89=E3=81=AE=E5=A0=B4=E5=90=88=E3=80=81?= =?UTF-8?q?=E7=A7=BB=E8=A1=8C=E5=85=88=E3=81=8C1.5CUP=E7=8A=B6=E6=85=8B?= =?UTF-8?q?=E3=81=A7=E3=81=AA=E3=81=91=E3=82=8C=E3=81=B0=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@463 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../sources/ConsoleRestore/Controller.cpp | 79 +++++++++++++++++++ .../sources/ConsoleRestore/Importer.cpp | 6 ++ .../sources/ConsoleRestore/Importer.h | 4 + .../sources/common/common_Types.h | 3 + 4 files changed, 92 insertions(+) diff --git a/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Controller.cpp b/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Controller.cpp index 62b0d87..f6ee81d 100644 --- a/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Controller.cpp +++ b/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Controller.cpp @@ -88,6 +88,11 @@ bool s_ShopOperationExecuted[SHOP_OPERATION_NUM_MAX]; // ショップ処理を何回リトライしたか u32 s_ShopOperationRetryCount[SHOP_OPERATION_NUM_MAX]; +// SDカード上のバージョン情報を読んだかどうか +bool s_ReadSdVersionData = false; +// CUPが必要かどうか +bool s_NeedsCup = true; + void PutAliveMessage(::std::vector& operationMessage, const char* str); bool CheckAndReadAPSetting(::std::vector& operationMessage); @@ -101,6 +106,22 @@ bool HasValidRtcData() return !s_CheckSdOnlyMode && !s_NupOnlyMode && !s_GetIvsOnlyMode; } +bool IsLowerthan1_5(common::HardwareStateManager& manager) +{ + common::VerDef version; + manager.GetVersionData(&version); + if (version.cup.majorVersion < common::CUP_MAJOR_VER_1_5_CUP + || version.cup.minorVersion < common::CUP_MINOR_VER_1_5_CUP) + { + return true; + } + else + { + return false; + } +} + + typedef enum RestoreState { STARTUP, // 初期値 @@ -157,6 +178,7 @@ void CheckSdInserted(common::HardwareStateManager& manager, ::std::vector& message, bool& goNextStep); void CheckSdWritable(common::HardwareStateManager& manager, ::std::vector& message, bool& goNextStep); void CheckApSetting(common::HardwareStateManager& manager, ::std::vector& message, bool& goNextStep); +bool CheckNeedsCup(common::HardwareStateManager& manager, ::std::vector& message, bool& goNextStep); void CheckNupExecuted(common::HardwareStateManager& manager, ::std::vector& message, bool& goNextStep); void CheckDownloadIvs(common::HardwareStateManager& manager, ::std::vector& message, bool& goNextStep); void CheckAccountDeleted(common::HardwareStateManager& manager, ::std::vector& message, bool& goNextStep); @@ -226,6 +248,14 @@ void CheckApSetting(common::HardwareStateManager& manager, ::std::vector& message, bool& goNextStep) +{ + NN_UNUSED_VAR(message); + NN_UNUSED_VAR(goNextStep); + + if (s_GetIvsOnlyMode) + { + if (IsLowerthan1_5(manager)) + { + COMMON_LOGGER("New Version Required.\n"); + s_RestoreState = FAIL; + s_NeedsCup = true; + return s_NeedsCup; + } + else + { + s_NeedsCup = false; + return s_NeedsCup; + } + } + + if(s_ReadSdVersionData) + { + return s_NeedsCup; + } + + nn::Result result = ReadVersionData(); + s_ReadSdVersionData = true; + if(result.IsFailure()) + { + s_RestoreState = FAIL; + s_NeedsCup = true; + return s_NeedsCup; + } + else + { + if(Is1_5CUPExecuted() && IsLowerthan1_5(manager)) + { + COMMON_LOGGER("New Version Required.\n"); + s_RestoreState = FAIL; + s_NeedsCup = true; + return s_NeedsCup; + } + + s_NeedsCup = false; + return s_NeedsCup; + } +} + // NUP済みかどうかチェック void CheckNupExecuted(common::HardwareStateManager& manager, ::std::vector& message, bool& goNextStep) { diff --git a/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Importer.cpp b/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Importer.cpp index 30e1659..f41baa3 100644 --- a/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Importer.cpp +++ b/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Importer.cpp @@ -1880,6 +1880,12 @@ bool IsImportSucceeded() return s_IsImportSucceeded; } +bool Is1_5CUPExecuted() +{ + return s_SDVersionData.cup.majorVersion == common::CUP_MAJOR_VER_1_5_CUP && + s_SDVersionData.cup.minorVersion == common::CUP_MINOR_VER_1_5_CUP; +} + nn::Result ImportData() { static nn::Result result = nn::ResultSuccess(); diff --git a/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Importer.h b/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Importer.h index e2c49b1..808f0b5 100644 --- a/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Importer.h +++ b/branches/1stNUP_1_5_CUP/sources/ConsoleRestore/Importer.h @@ -160,6 +160,10 @@ bool ImportIvsData(); // 書き込みが成功したかどうか bool IsImportSucceeded(); +// 1.5CUP限定 +// 1.5CUP済み本体かどうか +bool Is1_5CUPExecuted(); + } #endif /* IMPORTER_H_ */ diff --git a/branches/1stNUP_1_5_CUP/sources/common/common_Types.h b/branches/1stNUP_1_5_CUP/sources/common/common_Types.h index 581b718..d07873d 100644 --- a/branches/1stNUP_1_5_CUP/sources/common/common_Types.h +++ b/branches/1stNUP_1_5_CUP/sources/common/common_Types.h @@ -41,6 +41,9 @@ const u64 INFRA_DEVICE_ID_OFFSET = 0x400000000; const size_t FILE_COPY_HEAP_SIZE = 16 * 1024 * 1024; +const u8 CUP_MAJOR_VER_1_5_CUP = 2; +const u8 CUP_MINOR_VER_1_5_CUP = 2; + // NOR領域のみにある設定データ用構造体 struct NtrNorData {