From 887c9f869eb4cbbbbe053a9859b2b711f056cf12 Mon Sep 17 00:00:00 2001 From: N2614 Date: Fri, 8 Jul 2011 04:24:47 +0000 Subject: [PATCH] =?UTF-8?q?Backup=E3=81=A7=E3=81=AF=E9=80=9A=E4=BF=A1?= =?UTF-8?q?=E7=B3=BB=E3=81=AE=E3=83=97=E3=83=AD=E3=82=BB=E3=82=B9=E3=82=92?= =?UTF-8?q?=E8=B5=B7=E5=8B=95=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= 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@371 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../sources/ConsoleBackup/ConsoleBackup.cpp | 22 +++------ .../sources/ConsoleBackup/ConsoleBackup.rsf | 12 +---- .../sources/ConsoleRestore/ConsoleRestore.cpp | 11 ++--- .../sources/ConsoleRestore/ConsoleRestore.rsf | 7 --- .../sources/common/DrawSystemState.cpp | 25 ++++++++--- .../sources/common/DrawSystemState.h | 3 +- .../sources/common/HardwareStateManager.cpp | 5 --- .../sources/common/HardwareStateManager.h | 2 - .../sources/common/Util.cpp | 45 +++++++++++++++---- .../sources/common/Util.h | 18 +++++++- 10 files changed, 88 insertions(+), 62 deletions(-) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp b/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp index 0a11eb1..7f2b917 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.cpp @@ -68,6 +68,10 @@ common::Util s_HwUtility; } // namespace +extern "C" void nninitSetupDaemons(void) +{ +} + namespace ConsoleBackup{ @@ -88,14 +92,6 @@ extern "C" void nnMain(void) result = nn::hid::Initialize(); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); - // ndmの初期化 - result = nn::ndm::Initialize(); - COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); - - // 全デーモンの自律動作をacの自動接続も含めて止める - result = nn::ndm::SuspendScheduler(); - COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); - // cfg の初期化 nn::cfg::CTR::init::Initialize(); nn::cfg::CTR::system::Initialize(); @@ -142,7 +138,7 @@ extern "C" void nnMain(void) nn::hid::PadStatus padStatus; // データの準備 - s_HwUtility.Initialize(); + s_HwUtility.InitializeForBackup(); common::HardwareStateManager manager(s_HwUtility); // 情報出力 @@ -156,11 +152,6 @@ extern "C" void nnMain(void) COMMON_LOGGER("Serial Number %s\n", s_HwUtility.GetSerialNumber()); COMMON_LOGGER("Device ID %llu\n", s_HwUtility.GetInfraDeviceId()); COMMON_LOGGER("MAC Address %s\n", s_HwUtility.GetMacAddress()); - COMMON_LOGGER("Friend Code %04u-%04u-%04u\n", - static_cast(s_HwUtility.GetFriendcode() / 100000000ULL % 10000ULL), - static_cast(s_HwUtility.GetFriendcode() / 10000ULL % 10000ULL), - static_cast(s_HwUtility.GetFriendcode() % 10000ULL) ); - bool flip = false; bool continueBackup = false; @@ -251,7 +242,8 @@ extern "C" void nnMain(void) s_HwUtility.GetMacAddress(), operationMessage, s_HwUtility.GetRegion(), - s_HwUtility.GetSerialNumber() + s_HwUtility.GetSerialNumber(), + s_HwUtility.HasReadFriendCode() ); renderSystem.SwapBuffers(); diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.rsf b/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.rsf index 3b10ee6..2ab5f97 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.rsf +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/ConsoleBackup.rsf @@ -13,20 +13,10 @@ SystemControlInfo: AppType : Application StackSize : 0x4000 Dependency : - - gpio - - pdn - - spi - - i2c - - mcu - - ptm - codec - - cfg - hid - gsp - - friends - - nim - - ac - - ndm + - nwm AccessControlInfo: Priority : 16 diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.cpp index 786eb73..6b4d2cc 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.cpp @@ -66,7 +66,7 @@ demo::RenderSystemDrawing s_RenderSystem; namespace ConsoleRestore{ -void FinalizeAll(common::HardwareStateManager& manager) +void FinalizeAll() { common::Logger::GetLoggerInstance()->Finalize(); // アンマウント @@ -74,7 +74,7 @@ void FinalizeAll(common::HardwareStateManager& manager) nn::fs::Unmount("sdmc:"); s_RenderSystem.Finalize(); - manager.Finalize(); + s_HwUtility.FinalizeForRestore(); nn::ps::Finalize(); nn::ptm::CTR::FinalizeForSystemMenu(); nn::cfg::CTR::system::Finalize(); @@ -160,7 +160,7 @@ extern "C" void nnMain(void) nn::hid::PadStatus padStatus; // データの準備 - s_HwUtility.Initialize(); + s_HwUtility.InitializeForRestore(); common::HardwareStateManager manager(s_HwUtility); // 情報出力 @@ -289,7 +289,8 @@ extern "C" void nnMain(void) s_HwUtility.GetMacAddress(), operationMessage, s_HwUtility.GetRegion(), - s_HwUtility.GetSerialNumber() + s_HwUtility.GetSerialNumber(), + s_HwUtility.HasReadFriendCode() ); if (GetRestoreMode() != RESTORE_MODE_RESTORE) @@ -346,7 +347,7 @@ extern "C" void nnMain(void) // 電源長押しで終了 if ( nn::applet::IsExpectedToCloseApplication()) { - FinalizeAll(manager); + FinalizeAll(); } } } diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.rsf b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.rsf index 981df7c..fdbf1fd 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.rsf +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/ConsoleRestore.rsf @@ -13,14 +13,7 @@ SystemControlInfo: AppType : Application StackSize : 0x4000 Dependency : - - gpio - - pdn - - spi - - i2c - - mcu - - ptm - codec - - cfg - hid - gsp - friends diff --git a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.cpp b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.cpp index d1457c4..68c8b3e 100644 --- a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.cpp +++ b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.cpp @@ -38,6 +38,7 @@ u8 s_BatteryRemain; std::string s_AdapterState; u8 s_Progress; ::std::vector* s_OperationMessage; +bool s_ReadFriendCode; } @@ -69,9 +70,12 @@ void SetTextWriterCore() GetTextWriter()->Printf("Serial No. %s\n", s_SerialNo); GetTextWriter()->Printf("Device ID %llu\n", s_DeviceId); GetTextWriter()->Printf("MAC Address %s\n", s_MacAddress); - GetTextWriter()->Printf("Friend Code %04u-%04u-%04u\n", static_cast (s_FriendCode - / 100000000ULL % 10000ULL), static_cast (s_FriendCode / 10000ULL % 10000ULL), - static_cast (s_FriendCode % 10000ULL)); + if (s_ReadFriendCode) + { + GetTextWriter()->Printf("Friend Code %04u-%04u-%04u\n", + static_cast(s_FriendCode / 100000000ULL % 10000ULL), static_cast (s_FriendCode / 10000ULL % 10000ULL), + static_cast (s_FriendCode % 10000ULL)); + } GetTextWriter()->Printf("Battery %d%%\n", s_BatteryRemain); GetTextWriter()->Printf("AC Adapter %s\n", s_AdapterState.c_str()); @@ -108,7 +112,9 @@ void DrawSystemState char8* macAddress, ::std::vector& operationMessage, nn::cfg::CTR::CfgRegionCode region, - u8* serialNo + u8* serialNo, + bool readFriendCode + ) { // パラメータ保存 @@ -126,6 +132,7 @@ void DrawSystemState std::memcpy(s_SerialNo, serialNo, sizeof(s_SerialNo)); s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN] = '\0'; s_OperationMessage = &operationMessage; + s_ReadFriendCode = readFriendCode; // デフォルトで上画面に描画するもの @@ -166,7 +173,15 @@ void DrawSystemState // プログレスバー fontwidth = 8; fontheight = 14; - line += 9; + if(readFriendCode) + { + line += 9; + } + else + { + line += 8; + } + const u8 offset = 19; const u8 diff = 4; renderSystem.SetColor(0.f, 0.2f, 0.f); diff --git a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h index 8acab14..448d086 100644 --- a/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h +++ b/trunk/ConsoleDataMigration/sources/common/DrawSystemState.h @@ -71,7 +71,8 @@ void DrawSystemState char8* macAddress, ::std::vector& operationMessage, nn::cfg::CTR::CfgRegionCode region, - u8* s_SerialNo + u8* s_SerialNo, + bool readFriendCode ); } diff --git a/trunk/ConsoleDataMigration/sources/common/HardwareStateManager.cpp b/trunk/ConsoleDataMigration/sources/common/HardwareStateManager.cpp index aa633ee..0f5fa76 100644 --- a/trunk/ConsoleDataMigration/sources/common/HardwareStateManager.cpp +++ b/trunk/ConsoleDataMigration/sources/common/HardwareStateManager.cpp @@ -28,11 +28,6 @@ HardwareStateManager::~HardwareStateManager() } -void HardwareStateManager::Finalize() -{ - m_pUtil->Finalize(); -} - bool HardwareStateManager::CanReadIvs() { return m_pUtil->CanReadIVS(); diff --git a/trunk/ConsoleDataMigration/sources/common/HardwareStateManager.h b/trunk/ConsoleDataMigration/sources/common/HardwareStateManager.h index 65b6525..1483dff 100644 --- a/trunk/ConsoleDataMigration/sources/common/HardwareStateManager.h +++ b/trunk/ConsoleDataMigration/sources/common/HardwareStateManager.h @@ -29,8 +29,6 @@ public: explicit HardwareStateManager(Util& hwUtility); virtual ~HardwareStateManager(); - void Finalize(); - bool CanReadIvs(); bool CanReadSerialNumber(); bool IsBatteryLower(); diff --git a/trunk/ConsoleDataMigration/sources/common/Util.cpp b/trunk/ConsoleDataMigration/sources/common/Util.cpp index ff4918c..bb52b06 100644 --- a/trunk/ConsoleDataMigration/sources/common/Util.cpp +++ b/trunk/ConsoleDataMigration/sources/common/Util.cpp @@ -38,10 +38,9 @@ namespace common { Util::Util() : - m_BatteryRemain(100), m_CanReadSerialNumber(false), m_CanReadIvs(false) + m_FriendCode(0), m_BatteryRemain(100), m_CanReadSerialNumber(false), m_CanReadIvs(false), m_HasReadFriendCode(false) { - } Util::~Util() @@ -49,11 +48,31 @@ Util::~Util() } -void Util::Initialize() +void Util::InitializeForBackup() { + Initialize(); +} + +void Util::InitializeForRestore() +{ + Initialize(); + // friendsの初期化 nn::Result result = nn::friends::detail::Initialize(); + // フレンドコードの取得 + nn::friends::CTR::FriendKey friendKey; + result = nn::friends::CTR::GetMyFriendKey(&friendKey); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); + m_FriendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey); + + m_HasReadFriendCode = true; +} + +void Util::Initialize() +{ + nn::Result result; + // mcuの初期化 nn::mcu::CTR::InitializeHwCheck(&m_McuSession); mp_Mcu = new nn::mcu::CTR::HwCheck(m_McuSession); @@ -118,18 +137,21 @@ void Util::Initialize() COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); mac.GetString(m_MacAddress); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); +} - // フレンドコードの取得 - nn::friends::CTR::FriendKey friendKey; - result = nn::friends::CTR::GetMyFriendKey(&friendKey); - COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); - m_FriendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey); +void Util::FinalizeForBackup() +{ + Finalize(); +} + +void Util::FinalizeForRestore() +{ + nn::friends::detail::Finalize(); } void Util::Finalize() { nn::mcu::CTR::FinalizeHwCheck(&m_McuSession); - nn::friends::detail::Finalize(); } // NULL終端されたシリアルナンバーを受け取る @@ -330,4 +352,9 @@ void Util::GetVersionData(common::VerDef* version) *version = m_VerData; } +bool Util::HasReadFriendCode() +{ + return m_HasReadFriendCode; +} + } diff --git a/trunk/ConsoleDataMigration/sources/common/Util.h b/trunk/ConsoleDataMigration/sources/common/Util.h index 17151c0..ebcf875 100644 --- a/trunk/ConsoleDataMigration/sources/common/Util.h +++ b/trunk/ConsoleDataMigration/sources/common/Util.h @@ -33,8 +33,11 @@ public: Util(); virtual ~Util(); - void Initialize(); - void Finalize(); + void InitializeForBackup(); + void InitializeForRestore(); + + void FinalizeForBackup(); + void FinalizeForRestore(); // シリアルナンバーにモジュラス10 ウェイト3・1(M10W31)でチェックデジットを付加する static void AddCheckDigit(char* serial); @@ -102,8 +105,13 @@ public: // バージョン情報を取得する void GetVersionData(common::VerDef* version); + // フレンドコードを取得済みかどうか + bool HasReadFriendCode(); private: + void Initialize(); + void Finalize(); + NN_PADDING4; // フレンドコード u64 m_FriendCode; @@ -145,6 +153,12 @@ private: // MACアドレス char8 m_MacAddress[nn::nwm::Mac::MAC_STRING_SIZE]; NN_PADDING3; + + // FriendCodeを読んだかどうか + bool m_HasReadFriendCode; + NN_PADDING3; + NN_PADDING4; + }; }