diff --git a/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp b/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp index 064683a..966196f 100644 --- a/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp +++ b/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp @@ -30,6 +30,9 @@ #include #include #include +#include +#include + #include "demo.h" #include @@ -45,6 +48,8 @@ #include "SDMountManager.h" #include "HeapManager.h" #include "PlayHistoryManager.h" +#include "common_Types.h" +#include "VersionDetect.h" // svnリビジョン埋め込み用 #include "version.h" @@ -205,6 +210,7 @@ extern "C" void nnMain(void) { s_CanReadIvs = true; } + common::HeapManager::GetHeap()->Free(addr); } } fis.Finalize(); @@ -249,9 +255,14 @@ extern "C" void nnMain(void) // ReadOnlySharedInfoの取得 const nn::os::ReadOnlySharedInfo& rosi = nn::os::GetReadOnlySharedInfo(); + // バージョンの取得 + common::VerDef mVerData; + common::GetSystemVersion(&mVerData, region); + // 情報出力 COMMON_LOGGER("CTR Console Backup %s Rev.%s\n", __DATE__, BACKUP_VERSION_NUM); - COMMON_LOGGER("System Ver. %d.%d (Rev.%d)\n", rosi.versionHi, rosi.versionLo, rosi.revision); + COMMON_LOGGER("System Ver. %d.%d.%d-%d\n", mVerData.cup.majorVersion, mVerData.cup.minorVersion, mVerData.cup.microVersion, + mVerData.nup.majorVersion); COMMON_LOGGER("System Region %s\n", nn::cfg::CTR::GetRegionCodeA3(region)); COMMON_LOGGER("Serial Number %s\n", s_SerialNo); COMMON_LOGGER("Device ID %X\n", deviceId); @@ -340,6 +351,7 @@ extern "C" void nnMain(void) flip, adapterState, BACKUP_VERSION_NUM, + &mVerData, batteryRemain, deviceId, friendCode, diff --git a/trunk/ConsoleDataMigration/ConsoleBackup/OMakefile b/trunk/ConsoleDataMigration/ConsoleBackup/OMakefile index c3bfd6a..39abc74 100644 --- a/trunk/ConsoleDataMigration/ConsoleBackup/OMakefile +++ b/trunk/ConsoleDataMigration/ConsoleBackup/OMakefile @@ -41,6 +41,7 @@ SOURCES[] = ../common/CommonLogger.cpp ../common/SdMountManager.cpp ../common/PlayHistoryManager.cpp + ../common/VersionDetect.cpp CTR_BANNER_SPEC = $(TARGET_PROGRAM).bsf diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp index c4a5e19..4af34b2 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp @@ -43,6 +43,7 @@ #include "CommonLogger.h" #include "SDMountManager.h" #include "HeapManager.h" +#include "VersionDetect.h" // svnリビジョン埋め込み用 #include "version.h" @@ -266,10 +267,14 @@ extern "C" void nnMain(void) // ReadOnlySharedInfoの取得 const nn::os::ReadOnlySharedInfo& rosi = nn::os::GetReadOnlySharedInfo(); + // バージョンの取得 + common::VerDef mVerData; + common::GetSystemVersion(&mVerData, region); // 情報出力 COMMON_LOGGER("CTR Console Restore %s Rev.%s\n", __DATE__, RESTORE_VERSION_NUM); - COMMON_LOGGER("System Ver. %d.%d (Rev.%d)\n", rosi.versionHi, rosi.versionLo, rosi.revision); + COMMON_LOGGER("System Ver. %d.%d.%d-%d\n", mVerData.cup.majorVersion, mVerData.cup.minorVersion, mVerData.cup.microVersion, + mVerData.nup.majorVersion); COMMON_LOGGER("System Region %s\n", nn::cfg::CTR::GetRegionCodeA3(region)); COMMON_LOGGER("Serial Number %s\n", s_SerialNo); COMMON_LOGGER("Device ID %X\n", deviceId); @@ -358,6 +363,7 @@ extern "C" void nnMain(void) flip, adapterState, RESTORE_VERSION_NUM, + &mVerData, batteryRemain, deviceId, friendCode, diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/OMakefile b/trunk/ConsoleDataMigration/ConsoleRestore/OMakefile index 2470142..ca7520a 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/OMakefile +++ b/trunk/ConsoleDataMigration/ConsoleRestore/OMakefile @@ -44,6 +44,7 @@ SOURCES[] = ../common/SdMountManager.cpp ../common/configLoader.cpp ../common/PlayHistoryManager.cpp + ../common/VersionDetect.cpp CTR_BANNER_SPEC = $(TARGET_PROGRAM).bsf diff --git a/trunk/ConsoleDataMigration/common/DrawSystemState.cpp b/trunk/ConsoleDataMigration/common/DrawSystemState.cpp index 8de410a..2f3162a 100644 --- a/trunk/ConsoleDataMigration/common/DrawSystemState.cpp +++ b/trunk/ConsoleDataMigration/common/DrawSystemState.cpp @@ -47,6 +47,7 @@ void DrawSystemState bool flip, std::string& adapterState, const char* toolVersion, + common::VerDef* mVerData, u8 batteryRemain, bit32 deviceId, u64 friendCode, @@ -88,9 +89,8 @@ void DrawSystemState fontSize += 2; spaceSize = fontSize + 2; renderSystem.SetFontSize(fontSize); - - renderSystem.DrawText(0, line++ * spaceSize, "System Ver. %d.%d (Rev.%d)", rosi.versionHi, rosi.versionLo, - rosi.revision); + renderSystem.DrawText(0, line++ * spaceSize, "System Ver. %d.%d.%d-%d", mVerData->cup.majorVersion, mVerData->cup.minorVersion, mVerData->cup.microVersion, + mVerData->nup.majorVersion); renderSystem.DrawText(0, line++ * spaceSize, "System Region %s", nn::cfg::CTR::GetRegionCodeA3(region)); renderSystem.DrawText(0, line++ * spaceSize, "Serial No. %s", s_SerialNo); renderSystem.DrawText(0, line++ * spaceSize, "Device ID %X", deviceId); diff --git a/trunk/ConsoleDataMigration/common/DrawSystemState.h b/trunk/ConsoleDataMigration/common/DrawSystemState.h index 3fd7ce0..0eb29cb 100644 --- a/trunk/ConsoleDataMigration/common/DrawSystemState.h +++ b/trunk/ConsoleDataMigration/common/DrawSystemState.h @@ -28,6 +28,8 @@ #include #include +#include "common_Types.h" + // 描画色の定義 #define WHITE_COLOR 1.f, 1.f, 1.f, 1.f #define GRAY_COLOR 0.5, 0.5, 0.5, 1.f @@ -50,6 +52,7 @@ void DrawSystemState bool flip, std::string& adapterState, const char* toolVersion, + common::VerDef* mVerData, u8 batteryRemain, bit32 deviceId, u64 friendCode, diff --git a/trunk/ConsoleDataMigration/common/VersionDetect.cpp b/trunk/ConsoleDataMigration/common/VersionDetect.cpp new file mode 100644 index 0000000..e29271e --- /dev/null +++ b/trunk/ConsoleDataMigration/common/VersionDetect.cpp @@ -0,0 +1,113 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: VersionDetect.cpp + + Copyright 2009 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + 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$ + *---------------------------------------------------------------------------*/ + +#include +#include +#include + +#include "VersionDetect.h" +#include "HeapManager.h" + +namespace common +{ + +void GetCupVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region) +{ + nn::Result result; + const size_t BUF_SIZE = 1024; + u8 buf[BUF_SIZE]; + // CUPバージョン + { + result = nn::fs::MountContent("cver:", nn::fs::MEDIA_TYPE_NAND, common::cCupVerId[region], 0, 1, 1, buf, + BUF_SIZE); + + nn::fs::FileInputStream fis; + + result = fis.TryInitialize(L"cver:/version.bin"); + if (result.IsSuccess()) + { + s64 fileSize = fis.GetSize(); + NN_LOG("version.bin size = %lld\n", fileSize); + s32 ret; + void* addr = NULL; + addr = common::HeapManager::GetHeap()->Allocate(fileSize); + if (addr != NULL) + { + result = fis.TryRead(&ret, addr, fileSize); + if (result.IsSuccess()) + { + nn::pl::CTR::CardUpdateVersion* ver_buf = reinterpret_cast (addr); + + std::memcpy(&mVerData->cup, ver_buf, sizeof(nn::pl::CTR::CardUpdateVersion)); + } + common::HeapManager::GetHeap()->Free(addr); + } + } + fis.Finalize(); + + nn::fs::Unmount("cver:"); + } + +} + +void GetNupVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region) +{ + nn::Result result; + const size_t BUF_SIZE = 1024; + u8 buf[BUF_SIZE]; + + // NUPバージョン + { + result = nn::fs::MountContent("nver:", nn::fs::MEDIA_TYPE_NAND, common::cCupVerId[region], 0, 1, 1, buf, + BUF_SIZE); + + nn::fs::FileInputStream fis; + + result = fis.TryInitialize(L"nver:/version.bin"); + if (result.IsSuccess()) + { + s64 fileSize = fis.GetSize(); + NN_LOG("version.bin size = %lld\n", fileSize); + s32 ret; + void* addr = NULL; + addr = common::HeapManager::GetHeap()->Allocate(fileSize); + if (addr != NULL) + { + result = fis.TryRead(&ret, addr, fileSize); + if (result.IsSuccess()) + { + nn::pl::CTR::NetworkUpdateVersion* ver_buf = + reinterpret_cast (addr); + + std::memcpy(&mVerData->cup, ver_buf, sizeof(nn::pl::CTR::NetworkUpdateVersion)); + } + common::HeapManager::GetHeap()->Free(addr); + } + } + + fis.Finalize(); + nn::fs::Unmount("nver:"); + } + +} + +void GetSystemVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region) +{ + GetNupVersion(mVerData, region); + GetCupVersion(mVerData, region); +} + +} + diff --git a/trunk/ConsoleDataMigration/common/VersionDetect.h b/trunk/ConsoleDataMigration/common/VersionDetect.h new file mode 100644 index 0000000..652ed09 --- /dev/null +++ b/trunk/ConsoleDataMigration/common/VersionDetect.h @@ -0,0 +1,30 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: VersionDetect.h + + Copyright 2009 Nintendo. All rights reserved. + + These coded instructions, statements, and computer programs contain + proprietary information of Nintendo of America Inc. and/or Nintendo + Company Ltd., and are protected by Federal copyright law. They may + 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$ + *---------------------------------------------------------------------------*/ + +#ifndef VERSIONDETECT_H_ +#define VERSIONDETECT_H_ + +#include +#include "common_Types.h" + +namespace common +{ + +void GetSystemVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region); + +} + + +#endif /* VERSIONDETECT_H_ */ diff --git a/trunk/ConsoleDataMigration/common/common_Types.h b/trunk/ConsoleDataMigration/common/common_Types.h index c66cce1..3190f25 100644 --- a/trunk/ConsoleDataMigration/common/common_Types.h +++ b/trunk/ConsoleDataMigration/common/common_Types.h @@ -19,6 +19,8 @@ #include #include #include +#include +#include namespace common { @@ -42,6 +44,25 @@ struct CfgCountryLanguage NN_PADDING1; }; +struct VerDef +{ + nn::pl::CTR::CardUpdateVersion cup; + nn::pl::CTR::NetworkUpdateVersion nup; +}; + +const nn::ProgramId cCupVerId[] = +{ + nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_JP, + nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_US, + nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_EU, +}; + +const nn::ProgramId cNupVerId[] = +{ + nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_JP, + nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_US, + nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_EU, +}; }