mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
本体のバージョンを保存してチェックするように
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@657 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
31a12ef522
commit
c9d7c3b514
@ -14,6 +14,7 @@
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CfgChanger.h"
|
||||
#include <nn/cfg.h>
|
||||
#include <nn/cfg/CTR/cfg_ApiSys.h>
|
||||
#include <nn/cfg/CTR/detail/cfg_Keys.h>
|
||||
#include <nn/cfg/CTR/detail/cfg_DataStructures.h>
|
||||
@ -21,6 +22,7 @@
|
||||
#include <nn/cfg/CTR/cfg_ApiNor.h>
|
||||
#include <nn/ac/CTR/private/ac_InternalApi.h>
|
||||
#include <nn/ac/CTR/private/ac_NetworkSetting.h>
|
||||
#include "VersionDetect.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -78,6 +80,9 @@ NN_PADDING2;
|
||||
|
||||
// 時間
|
||||
nn::fnd::DateTime m_DateTime;
|
||||
|
||||
// バージョン情報
|
||||
VerDef m_Version;
|
||||
};
|
||||
|
||||
SaveData s_SaveData;
|
||||
@ -246,6 +251,11 @@ nn::Result CfgChanger::GetCfgData()
|
||||
NN_UTIL_RETURN_IF_FAILED(result);
|
||||
nn::cfg::nor::CTR::Finalize();
|
||||
|
||||
// バージョン情報
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
GetSystemVersion(&s_SaveData.m_Version, nn::cfg::CTR::GetRegion())
|
||||
);
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
@ -289,6 +299,15 @@ nn::Result CfgChanger::RestoreCfgDataFromBackup()
|
||||
|
||||
nn::cfg::CTR::system::Initialize();
|
||||
|
||||
// バージョン確認
|
||||
VerDef currentVersion;
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
GetSystemVersion(¤tVersion, nn::cfg::CTR::GetRegion())
|
||||
);
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
CheckSystemVersion(¤tVersion, &s_SaveData.m_Version)
|
||||
);
|
||||
|
||||
nn::fnd::DateTime now = nn::fnd::DateTime::GetNow();
|
||||
s64 usertimeOffset;
|
||||
result = nn::cfg::CTR::system::GetConfig(&usertimeOffset, sizeof(usertimeOffset), GET_CFG_KEY(NN_CFG_RTC, NN_CFG_RTC_USERTIME_OFFSET));
|
||||
@ -379,3 +398,18 @@ nn::Result CfgChanger::RestoreCfgDataFromBackup()
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
nn::Result CfgChanger::CheckSystemVersion(VerDef* currentVersion, VerDef* savedVersion)
|
||||
{
|
||||
if(currentVersion->cup.majorVersion == savedVersion->cup.majorVersion &&
|
||||
currentVersion->cup.minorVersion == savedVersion->cup.minorVersion &&
|
||||
currentVersion->cup.microVersion == savedVersion->cup.microVersion &&
|
||||
currentVersion->nup.majorVersion == savedVersion->nup.majorVersion)
|
||||
{
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
nn::MakePermanentResult(nn::Result::SUMMARY_INVALID_STATE, nn::Result::MODULE_APPLICATION, nn::Result::DESCRIPTION_OUT_OF_RANGE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#define CFGCHANGER_H_
|
||||
|
||||
#include <nn.h>
|
||||
#include "VersionDetect.h"
|
||||
|
||||
class CfgChanger
|
||||
{
|
||||
@ -44,6 +45,9 @@ private:
|
||||
// CFGのデータをバックアップメモリから書き込みます
|
||||
nn::Result RestoreCfgDataFromBackup();
|
||||
|
||||
// 本体のバージョンが一致しているか確認します
|
||||
nn::Result CheckSystemVersion(VerDef* currentVersion, VerDef* savedVersion);
|
||||
|
||||
static const size_t FILE_NUM = 1;
|
||||
static const size_t DIR_NUM = 1;
|
||||
static const bool DUPLICATE = true;
|
||||
|
||||
@ -32,6 +32,7 @@ SOURCES[] =
|
||||
HeapManager.cpp
|
||||
StateManager.cpp
|
||||
CfgChanger.cpp
|
||||
VersionDetect.cpp
|
||||
syokaikidou.cpp
|
||||
sysSharedExtSaveData.cpp
|
||||
sysUserInfoAccessor.cpp
|
||||
|
||||
143
trunk/SkipFirstLaunch/VersionDetect.cpp
Normal file
143
trunk/SkipFirstLaunch/VersionDetect.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
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 <nn.h>
|
||||
#include <nn/fs.h>
|
||||
#include <nn/fs/CTR/MPCore/fs_FileSystemBasePrivate.h>
|
||||
|
||||
#include "VersionDetect.h"
|
||||
#include "HeapManager.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
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,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_EU,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_CN,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_KR,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_TW,
|
||||
};
|
||||
|
||||
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,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_EU,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_CN,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_KR,
|
||||
nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_TW,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
nn::Result GetCupVersion(nn::pl::CTR::CardUpdateVersion* cup, nn::cfg::CTR::CfgRegionCode region)
|
||||
{
|
||||
const size_t BUF_SIZE = 1024;
|
||||
u8 buf[BUF_SIZE];
|
||||
// CUPバージョン
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
nn::fs::MountContent("cver:", nn::fs::MEDIA_TYPE_NAND, cCupVerId[region], 0, 1, 1, buf, BUF_SIZE)
|
||||
);
|
||||
|
||||
nn::fs::FileInputStream fis;
|
||||
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
fis.TryInitialize(L"cver:/version.bin")
|
||||
);
|
||||
s64 fileSize = fis.GetSize();
|
||||
NN_LOG("version.bin size = %lld\n", fileSize);
|
||||
s32 ret;
|
||||
void* addr = NULL;
|
||||
common::HeapManager heap(fileSize);
|
||||
addr = heap.GetAddr();
|
||||
if(!addr)
|
||||
{
|
||||
return nn::MakePermanentResult(nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_APPLICATION,
|
||||
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
fis.TryRead(&ret, addr, fileSize)
|
||||
);
|
||||
|
||||
nn::pl::CTR::CardUpdateVersion* ver_buf = reinterpret_cast<nn::pl::CTR::CardUpdateVersion*>(addr);
|
||||
std::memcpy(cup, ver_buf, sizeof(nn::pl::CTR::CardUpdateVersion));
|
||||
fis.Finalize();
|
||||
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
nn::fs::Unmount("cver:")
|
||||
);
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
nn::Result GetNupVersion(nn::pl::CTR::NetworkUpdateVersion* nup, nn::cfg::CTR::CfgRegionCode region)
|
||||
{
|
||||
const size_t BUF_SIZE = 1024;
|
||||
u8 buf[BUF_SIZE];
|
||||
|
||||
// NUPバージョン
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
nn::fs::MountContent("nver:", nn::fs::MEDIA_TYPE_NAND, cNupVerId[region], 0, 1, 1, buf, BUF_SIZE)
|
||||
);
|
||||
|
||||
nn::fs::FileInputStream fis;
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
fis.TryInitialize(L"nver:/version.bin")
|
||||
);
|
||||
|
||||
s64 fileSize = fis.GetSize();
|
||||
NN_LOG("version.bin size = %lld\n", fileSize);
|
||||
s32 ret;
|
||||
void* addr = NULL;
|
||||
common::HeapManager heap(fileSize);
|
||||
addr = heap.GetAddr();
|
||||
|
||||
if(!addr)
|
||||
{
|
||||
return nn::MakePermanentResult(nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_APPLICATION,
|
||||
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
fis.TryRead(&ret, addr, fileSize)
|
||||
);
|
||||
|
||||
nn::pl::CTR::NetworkUpdateVersion* ver_buf = reinterpret_cast<nn::pl::CTR::NetworkUpdateVersion*>(addr);
|
||||
std::memcpy(nup, ver_buf, sizeof(nn::pl::CTR::NetworkUpdateVersion));
|
||||
fis.Finalize();
|
||||
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
nn::fs::Unmount("nver:")
|
||||
);
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
|
||||
nn::Result GetSystemVersion(VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region)
|
||||
{
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
GetCupVersion(&mVerData->cup, region)
|
||||
);
|
||||
|
||||
NN_UTIL_RETURN_IF_FAILED(
|
||||
GetNupVersion(&mVerData->nup, region)
|
||||
);
|
||||
|
||||
|
||||
return nn::ResultSuccess();
|
||||
}
|
||||
36
trunk/SkipFirstLaunch/VersionDetect.h
Normal file
36
trunk/SkipFirstLaunch/VersionDetect.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
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 <nn.h>
|
||||
#include <nn/cfg/CTR/cfg_RegionCode.h>
|
||||
#include <nn/pl/CTR/pl_SharedDataTitleId.h>
|
||||
#include <nn/pl/CTR/pl_Version.h>
|
||||
|
||||
|
||||
struct VerDef
|
||||
{
|
||||
nn::pl::CTR::CardUpdateVersion cup;
|
||||
nn::pl::CTR::NetworkUpdateVersion nup;
|
||||
};
|
||||
|
||||
// リージョンコードに基づいてバージョン情報を取得する
|
||||
nn::Result GetSystemVersion(VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region);
|
||||
|
||||
|
||||
|
||||
#endif /* VERSIONDETECT_H_ */
|
||||
Loading…
Reference in New Issue
Block a user