diff --git a/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.cpp b/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.cpp index aca18c8..98d136b 100644 --- a/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.cpp +++ b/branches/work/RW_Aging/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; @@ -252,6 +243,7 @@ extern "C" void nnMain(void) operationMessage, s_HwUtility.GetRegion(), s_HwUtility.GetSerialNumber(), + s_HwUtility.HasReadFriendCode(), s_HwUtility.GetAgingCounter() ); diff --git a/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.rsf b/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.rsf index 3b10ee6..2ab5f97 100644 --- a/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.rsf +++ b/branches/work/RW_Aging/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/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.cpp b/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.cpp index 9f2922f..c697a41 100644 --- a/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.cpp +++ b/branches/work/RW_Aging/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); // 情報出力 @@ -290,6 +290,7 @@ extern "C" void nnMain(void) operationMessage, s_HwUtility.GetRegion(), s_HwUtility.GetSerialNumber(), + s_HwUtility.HasReadFriendCode(), s_HwUtility.GetAgingCounter() ); @@ -347,7 +348,7 @@ extern "C" void nnMain(void) // 電源長押しで終了 if ( nn::applet::IsExpectedToCloseApplication()) { - FinalizeAll(manager); + FinalizeAll(); } } } diff --git a/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.rsf b/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.rsf index 981df7c..fdbf1fd 100644 --- a/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.rsf +++ b/branches/work/RW_Aging/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/branches/work/RW_Aging/sources/common/DrawSystemState.cpp b/branches/work/RW_Aging/sources/common/DrawSystemState.cpp index 30dcaef..746845a 100644 --- a/branches/work/RW_Aging/sources/common/DrawSystemState.cpp +++ b/branches/work/RW_Aging/sources/common/DrawSystemState.cpp @@ -39,6 +39,7 @@ std::string s_AdapterState; u8 s_Progress; ::std::vector* s_OperationMessage; u32 s_Counter; +bool s_ReadFriendCode; } @@ -70,9 +71,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), + 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()); @@ -111,6 +115,7 @@ void DrawSystemState ::std::vector& operationMessage, nn::cfg::CTR::CfgRegionCode region, u8* serialNo, + bool readFriendCode, u32 counter ) { @@ -129,6 +134,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; s_Counter = counter; @@ -170,7 +176,15 @@ void DrawSystemState // プログレスバー fontwidth = 8; fontheight = 14; + 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/branches/work/RW_Aging/sources/common/DrawSystemState.h b/branches/work/RW_Aging/sources/common/DrawSystemState.h index b10f242..53033ef 100644 --- a/branches/work/RW_Aging/sources/common/DrawSystemState.h +++ b/branches/work/RW_Aging/sources/common/DrawSystemState.h @@ -72,6 +72,7 @@ void DrawSystemState ::std::vector& operationMessage, nn::cfg::CTR::CfgRegionCode region, u8* s_SerialNo, + bool readFriendCode, u32 counter ); diff --git a/branches/work/RW_Aging/sources/common/HardwareStateManager.cpp b/branches/work/RW_Aging/sources/common/HardwareStateManager.cpp index a2bc4c0..1f60a79 100644 --- a/branches/work/RW_Aging/sources/common/HardwareStateManager.cpp +++ b/branches/work/RW_Aging/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/branches/work/RW_Aging/sources/common/HardwareStateManager.h b/branches/work/RW_Aging/sources/common/HardwareStateManager.h index 14b8e9b..a667e4a 100644 --- a/branches/work/RW_Aging/sources/common/HardwareStateManager.h +++ b/branches/work/RW_Aging/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/branches/work/RW_Aging/sources/common/Util.cpp b/branches/work/RW_Aging/sources/common/Util.cpp index 35b1b19..4122a0f 100644 --- a/branches/work/RW_Aging/sources/common/Util.cpp +++ b/branches/work/RW_Aging/sources/common/Util.cpp @@ -40,10 +40,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() @@ -51,11 +50,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); @@ -121,12 +140,6 @@ void Util::Initialize() 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); - // エージング回数の変更 SdMountManager::Mount(); const size_t BUF_SIZE = 1024; @@ -153,12 +166,22 @@ void Util::Initialize() } SdMountManager::Unmount(); + +} + +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終端されたシリアルナンバーを受け取る @@ -364,4 +387,9 @@ u32 Util::GetAgingCounter() return m_AgingCounter; } +bool Util::HasReadFriendCode() +{ + return m_HasReadFriendCode; +} + } diff --git a/branches/work/RW_Aging/sources/common/Util.h b/branches/work/RW_Aging/sources/common/Util.h index 2648b21..520ee62 100644 --- a/branches/work/RW_Aging/sources/common/Util.h +++ b/branches/work/RW_Aging/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,11 +105,16 @@ public: // バージョン情報を取得する void GetVersionData(common::VerDef* version); + // フレンドコードを取得済みかどうか + bool HasReadFriendCode(); // エージング回数を取得する u32 GetAgingCounter(); private: + void Initialize(); + void Finalize(); + NN_PADDING4; // フレンドコード u64 m_FriendCode; @@ -149,7 +157,10 @@ private: char8 m_MacAddress[nn::nwm::Mac::MAC_STRING_SIZE]; NN_PADDING3; - NN_PADDING4; + // FriendCodeを読んだかどうか + bool m_HasReadFriendCode; + NN_PADDING3; + // エージング回数 u32 m_AgingCounter; };