diff --git a/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.cpp b/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.cpp index 0a11eb1..aca18c8 100644 --- a/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.cpp +++ b/branches/work/RW_Aging/sources/ConsoleBackup/ConsoleBackup.cpp @@ -251,7 +251,8 @@ extern "C" void nnMain(void) s_HwUtility.GetMacAddress(), operationMessage, s_HwUtility.GetRegion(), - s_HwUtility.GetSerialNumber() + s_HwUtility.GetSerialNumber(), + s_HwUtility.GetAgingCounter() ); renderSystem.SwapBuffers(); diff --git a/branches/work/RW_Aging/sources/ConsoleBackup/Exporter.cpp b/branches/work/RW_Aging/sources/ConsoleBackup/Exporter.cpp index 861aed3..d542e8a 100644 --- a/branches/work/RW_Aging/sources/ConsoleBackup/Exporter.cpp +++ b/branches/work/RW_Aging/sources/ConsoleBackup/Exporter.cpp @@ -118,7 +118,9 @@ nn::Result DeleteTrash(std::wstring currentDirectory) else { if (std::wcscmp(entryIndex->entryName, common::AP_SETTING_FILENAME) != 0 - && std::wcscmp(entryIndex->entryName, common::LOG_FILENAME) != 0) + && std::wcscmp(entryIndex->entryName, common::LOG_FILENAME) != 0 + && std::wcscmp(entryIndex->entryName, common::AGING_COUNTER_FILENAME) != 0 + ) { NN_LOG("Try Delete %ls%ls\n", currentDirectory.c_str(), entryIndex->entryName); result = nn::fs::TryDeleteFile( diff --git a/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.cpp b/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.cpp index 786eb73..9f2922f 100644 --- a/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.cpp +++ b/branches/work/RW_Aging/sources/ConsoleRestore/ConsoleRestore.cpp @@ -289,7 +289,8 @@ extern "C" void nnMain(void) s_HwUtility.GetMacAddress(), operationMessage, s_HwUtility.GetRegion(), - s_HwUtility.GetSerialNumber() + s_HwUtility.GetSerialNumber(), + s_HwUtility.GetAgingCounter() ); if (GetRestoreMode() != RESTORE_MODE_RESTORE) diff --git a/branches/work/RW_Aging/sources/common/DrawSystemState.cpp b/branches/work/RW_Aging/sources/common/DrawSystemState.cpp index d1457c4..30dcaef 100644 --- a/branches/work/RW_Aging/sources/common/DrawSystemState.cpp +++ b/branches/work/RW_Aging/sources/common/DrawSystemState.cpp @@ -38,6 +38,7 @@ u8 s_BatteryRemain; std::string s_AdapterState; u8 s_Progress; ::std::vector* s_OperationMessage; +u32 s_Counter; } @@ -76,6 +77,7 @@ void SetTextWriterCore() GetTextWriter()->Printf("Battery %d%%\n", s_BatteryRemain); GetTextWriter()->Printf("AC Adapter %s\n", s_AdapterState.c_str()); GetTextWriter()->Printf("Progress %02d%%\n", s_Progress); + GetTextWriter()->Printf("Counter %d\n", s_Counter); GetTextWriter()->Print("\n"); ::std::vector::iterator it; @@ -108,7 +110,8 @@ void DrawSystemState char8* macAddress, ::std::vector& operationMessage, nn::cfg::CTR::CfgRegionCode region, - u8* serialNo + u8* serialNo, + u32 counter ) { // パラメータ保存 @@ -126,6 +129,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_Counter = counter; // デフォルトで上画面に描画するもの diff --git a/branches/work/RW_Aging/sources/common/DrawSystemState.h b/branches/work/RW_Aging/sources/common/DrawSystemState.h index 8acab14..b10f242 100644 --- a/branches/work/RW_Aging/sources/common/DrawSystemState.h +++ b/branches/work/RW_Aging/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, + u32 counter ); } diff --git a/branches/work/RW_Aging/sources/common/FileName.h b/branches/work/RW_Aging/sources/common/FileName.h index 0d45e9c..c9c808a 100644 --- a/branches/work/RW_Aging/sources/common/FileName.h +++ b/branches/work/RW_Aging/sources/common/FileName.h @@ -65,6 +65,10 @@ const wchar_t* const FILE_LIST_PATHNAME = L"sdmc:/CTR_Console_Repair/FileList.tx const wchar_t* const TWL_TITLELIST_PATHNAME = L"sdmc:/CTR_Console_Repair/TwlTitleList.txt"; const wchar_t* const SD_NINTENDO_3DS_ROOT_PATH = L"sdmc:/Nintendo 3DS/"; +const wchar_t* const AGING_COUNTER_PATHNAME = L"sdmc:/CTR_Console_Repair/counter.bin"; +const wchar_t* const AGING_COUNTER_FILENAME = L"counter.bin"; + + enum TWL_PATH_INDEX { TWL_PHOTO = 0, diff --git a/branches/work/RW_Aging/sources/common/HardwareStateManager.cpp b/branches/work/RW_Aging/sources/common/HardwareStateManager.cpp index aa633ee..a2bc4c0 100644 --- a/branches/work/RW_Aging/sources/common/HardwareStateManager.cpp +++ b/branches/work/RW_Aging/sources/common/HardwareStateManager.cpp @@ -78,4 +78,9 @@ void HardwareStateManager::GetVersionData(common::VerDef* version) return m_pUtil->GetVersionData(version); } +u32 HardwareStateManager::GetAgingCounter() +{ + return m_pUtil->GetAgingCounter(); +} + } diff --git a/branches/work/RW_Aging/sources/common/HardwareStateManager.h b/branches/work/RW_Aging/sources/common/HardwareStateManager.h index 65b6525..14b8e9b 100644 --- a/branches/work/RW_Aging/sources/common/HardwareStateManager.h +++ b/branches/work/RW_Aging/sources/common/HardwareStateManager.h @@ -40,6 +40,7 @@ public: nn::Handle GetMcuHandle(); void GetSerialNumber(u8** serial, size_t* size); void GetVersionData(common::VerDef* version); + u32 GetAgingCounter(); private: NN_PADDING4; diff --git a/branches/work/RW_Aging/sources/common/Util.cpp b/branches/work/RW_Aging/sources/common/Util.cpp index ff4918c..eb455b8 100644 --- a/branches/work/RW_Aging/sources/common/Util.cpp +++ b/branches/work/RW_Aging/sources/common/Util.cpp @@ -32,6 +32,8 @@ #include "FileName.h" #include "CommonLogger.h" #include "HeapManager.h" +#include "SdMountManager.h" +#include "SdReaderWriter.h" namespace common @@ -124,6 +126,36 @@ void Util::Initialize() result = nn::friends::CTR::GetMyFriendKey(&friendKey); COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); m_FriendCode = nn::friends::CTR::FriendKeyToFriendCode(friendKey); + + // エージング回数の変更 + SdMountManager::Mount(); + size_t bufSize = GetAllocatableSize(); + common::HeapManager heap(bufSize); + void* buf = heap.GetAddr(); + if (buf != NULL) + { + common::SdReaderWriter sdReaderWriter; + + size_t readSize; + result = sdReaderWriter.ReadBufWithCmac(common::AGING_COUNTER_PATHNAME, buf, bufSize, &readSize); + if(result.IsSuccess()) + { + // SDから読み出し成功 + std::memcpy(&m_AgingCounter, buf, readSize); + m_AgingCounter++; + result = sdReaderWriter.WriteBufWithCmac(common::AGING_COUNTER_PATHNAME, &m_AgingCounter, sizeof(m_AgingCounter)); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); + } + else + { + // 初期値 + m_AgingCounter = 1; + result = sdReaderWriter.WriteBufWithCmac(common::AGING_COUNTER_PATHNAME, &m_AgingCounter, sizeof(m_AgingCounter)); + COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result); + } + } + + SdMountManager::Unmount(); } void Util::Finalize() @@ -330,4 +362,9 @@ void Util::GetVersionData(common::VerDef* version) *version = m_VerData; } +u32 Util::GetAgingCounter() +{ + return m_AgingCounter; +} + } diff --git a/branches/work/RW_Aging/sources/common/Util.h b/branches/work/RW_Aging/sources/common/Util.h index 17151c0..2648b21 100644 --- a/branches/work/RW_Aging/sources/common/Util.h +++ b/branches/work/RW_Aging/sources/common/Util.h @@ -102,6 +102,9 @@ public: // バージョン情報を取得する void GetVersionData(common::VerDef* version); + // エージング回数を取得する + u32 GetAgingCounter(); + private: NN_PADDING4; @@ -145,6 +148,10 @@ private: // MACアドレス char8 m_MacAddress[nn::nwm::Mac::MAC_STRING_SIZE]; NN_PADDING3; + + NN_PADDING4; + // エージング回数 + u32 m_AgingCounter; }; }