シリアルナンバーではなくデバイスIDの比較で同一本体かどうか調べるように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@110 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-03-11 05:44:47 +00:00
parent fc01f614bb
commit 0d64a3599e
9 changed files with 56 additions and 24 deletions

View File

@ -72,6 +72,9 @@ u8 batteryRemain = 100;
// シリアルナンバー
u8 s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
// デバイスID
bit32 s_DeviceId;
// シリアルナンバーが読めるかどうか
bool s_CanReadSerialNumber = false;
@ -124,6 +127,11 @@ void GetIvs(void** ivs, size_t* size)
*size = s_SizeofIvs;
}
bit32 GetDeviceId()
{
return s_DeviceId;
}
void GetVersionData(common::VerDef* version)
{
*version = s_VerData;
@ -261,13 +269,12 @@ extern "C" void nnMain(void)
hwInfo.AddCheckDigit(reinterpret_cast<char*>(s_SerialNo));
// デバイスIDの取得
bit32 deviceId;
result = nn::ps::CTR::GetDeviceId(&deviceId);
result = nn::ps::CTR::GetDeviceId(&s_DeviceId);
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
bit64 infraDeviceId;
result = nn::nim::CTR::InitializeForShop();
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::nim::CTR::Shop::GetInfraDeviceId(deviceId, &infraDeviceId);
result = nn::nim::CTR::Shop::GetInfraDeviceId(s_DeviceId, &infraDeviceId);
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::nim::CTR::FinalizeForShop();
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);

View File

@ -30,6 +30,7 @@ void GetSerialNumber(u8** serial, size_t* size);
void GetIvs(void** ivs, size_t* size);
nn::Handle GetMcuHandle();
void GetVersionData(common::VerDef* version);
bit32 GetDeviceId();
const u32 CONSOLE_WIDTH = 38;
const u32 CONSOLE_HEIGHT = 24;

View File

@ -212,6 +212,15 @@ void WriteSerialNumber()
s_SdWriter.WriteBuf(common::SERIAL_PATHNAME, serial, size);
}
void WriteDeviceId()
{
COMMON_LOGGER("Export Device ID.\n");
bit32 deviceId = GetDeviceId();
s_SdWriter.WriteBuf(common::DEVICE_ID_PATHNAME, &deviceId, sizeof(deviceId));
}
void WriteIvs()
{
COMMON_LOGGER("Export IVS.\n");
@ -523,6 +532,9 @@ void ExportData()
// シリアルナンバーをSDカードに書き込む
WriteSerialNumber();
// デバイスIDをSDカードに書き込む
WriteDeviceId();
// 完全性検証SEEDをSDカードに書き込む
WriteIvs();

View File

@ -68,6 +68,9 @@ u8 batteryRemain = 100;
// シリアルナンバー
u8 s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN];
// デバイスID
bit32 s_DeviceId;
// シリアルナンバーが読めるかどうか
bool s_CanReadSerialNumber = false;
@ -118,6 +121,11 @@ void GetIvs(void** ivs, size_t* size)
*size = s_SizeofIvs;
}
bit32 GetDeviceId()
{
return s_DeviceId;
}
void GetVersionData(common::VerDef* version)
{
*version = s_VerData;
@ -271,13 +279,12 @@ extern "C" void nnMain(void)
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
// デバイスIDの取得
bit32 deviceId;
result = nn::ps::CTR::GetDeviceId(&deviceId);
result = nn::ps::CTR::GetDeviceId(&s_DeviceId);
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
bit64 infraDeviceId;
result = nn::nim::CTR::InitializeForShop();
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::nim::CTR::Shop::GetInfraDeviceId(deviceId, &infraDeviceId);
result = nn::nim::CTR::Shop::GetInfraDeviceId(s_DeviceId, &infraDeviceId);
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
result = nn::nim::CTR::FinalizeForShop();
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);

View File

@ -30,6 +30,7 @@ void GetSerialNumber(u8** serial, size_t* size);
void GetIvs(void** ivs, size_t* size);
nn::Handle GetMcuHandle();
void GetVersionData(common::VerDef* version);
bit32 GetDeviceId();
void FinalizeAll();

View File

@ -325,8 +325,8 @@ void ControlState(::std::vector<std::string>& operationMessage, bool& nextStep,
{
COMMON_LOGGER("Initialize Console\n");
// SDカードのシリアルナンバーと本体のシリアルナンバーは異なるか?
if (EqualsSerialFileandSerial())
// SDカードのデバイスIDと本体のデバイスIDは異なるか?
if (EqualsDeviceIdFileandDeviceId())
{
// 同一本体に書き戻そうとしたファイルを作る
COMMON_LOGGER("Restore to the same console. Initialize.\n");

View File

@ -67,7 +67,7 @@ TimeZone s_TimeZone;
const size_t NTP_SERVER_NAME_LENGTH = 256;
char s_NtpServerName[NTP_SERVER_NAME_LENGTH];
bool s_CheckedEqualsSerialFileandSerial = false;
bool s_CheckedEqualsDeviceIdFileandDeviceId = false;
bool s_CheckedEqualsRegionDataandRegion = false;
bool s_ReadSerialNumber = false;
@ -222,30 +222,33 @@ u8* ReadSerialNumber()
return s_SerialNo;
}
bool EqualsSerialFileandSerial()
bool EqualsDeviceIdFileandDeviceId()
{
nn::Result result;
u8* serial;
size_t serialSize;
static bool retval = false;
if(s_CheckedEqualsSerialFileandSerial)
if(s_CheckedEqualsDeviceIdFileandDeviceId)
{
return retval;
}
COMMON_LOGGER("Check Serial Number\n");
COMMON_LOGGER("Check Device Id\n");
GetSerialNumber(&serial, &serialSize);
ReadSerialNumber();
if(std::memcmp(s_SerialNo, serial, nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN) == 0)
bit32 sdDeviceId;
common::SdReaderWriter sdReader;
size_t totalSize;
result = sdReader.ReadBuf(common::DEVICE_ID_PATHNAME, &sdDeviceId, sizeof(sdDeviceId), &totalSize);
s_CheckedEqualsDeviceIdFileandDeviceId = true;
if(result.IsSuccess())
{
retval = true;
retval = (GetDeviceId() == sdDeviceId);
return retval;
}
else
{
retval = false;
return retval;
}
s_CheckedEqualsSerialFileandSerial = true;
return retval;
}
bool EqualsRegionDataandRegion()
@ -1304,7 +1307,7 @@ void ImportTwlSoundData()
void ClearFileReadResult()
{
s_CheckedEqualsSerialFileandSerial = false;
s_CheckedEqualsDeviceIdFileandDeviceId = false;
s_CheckedEqualsRegionDataandRegion = false;
s_ReadSerialNumber = false;
}

View File

@ -23,7 +23,7 @@
namespace ConsoleRestore
{
bool EqualsSerialFileandSerial();
bool EqualsDeviceIdFileandDeviceId();
bool EqualsRegionDataandRegion();
u8* ReadSerialNumber();

View File

@ -55,6 +55,7 @@ const wchar_t* const PLAYHISTORY_COUNT_PATHNAME = L"sdmc:/CTR_Console_Repair/pla
const wchar_t* const CFG_CALIBRATION_PATHNAME = L"sdmc:/CTR_Console_Repair/cfgCalibration.bin";
const wchar_t* const VERSION_DATA_PATHNAME = L"sdmc:/CTR_Console_Repair/version.bin";
const wchar_t* const REGION_DATA_PATHNAME = L"sdmc:/CTR_Console_Repair/Region.bin";
const wchar_t* const DEVICE_ID_PATHNAME = L"sdmc:/CTR_Console_Repair/deviceId.bin";
enum TWL_PATH_INDEX
{