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@548 385bec56-5757-e545-9c3a-d8741f4650f1
238 lines
7.6 KiB
C++
238 lines
7.6 KiB
C++
/*---------------------------------------------------------------------------*
|
|
Project: Horizon
|
|
File: NandSavedataChecker.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 SAVEDATACHECKER_H_
|
|
#define SAVEDATACHECKER_H_
|
|
|
|
#include <string>
|
|
|
|
#include <nn.h>
|
|
#include <nn/fs/fs_ParametersForSystem.h>
|
|
|
|
namespace ConsoleBackup
|
|
{
|
|
|
|
struct SystemSaveDataCouple
|
|
{
|
|
std::string name;
|
|
nn::fs::SystemSaveDataId id;
|
|
};
|
|
|
|
const SystemSaveDataCouple SYSTEM_SAVEDATA_COUPLE_LIST[] =
|
|
{
|
|
{"fill_data", 0x00010000 },
|
|
{"cfg", 0x00010017 },
|
|
{"ptm", 0x00010022 },
|
|
{"cecd", 0x00010026 },
|
|
{"nim", 0x0001002C },
|
|
{"friends", 0x00010032 },
|
|
{"boss", 0x00010034 },
|
|
{"news", 0x00010035 },
|
|
|
|
{"ACTIVITY_LOG_JP", 0x00020202 },
|
|
{"ACTIVITY_LOG_US", 0x00020212 },
|
|
{"ACTIVITY_LOG_EU", 0x00020222 },
|
|
|
|
{"MII_MAKER_JP", 0x00020207 },
|
|
{"MII_MAKER_US", 0x00020217 },
|
|
{"MII_MAKER_EU", 0x00020227 },
|
|
|
|
{"PHOTO_JP", 0x00020204 },
|
|
{"PHOTO_US", 0x00020214 },
|
|
{"PHOTO_EU", 0x00020224 },
|
|
|
|
{"SOUND_JP", 0x00020205 },
|
|
{"SOUND_US", 0x00020215 },
|
|
{"SOUND_EU", 0x00020225 },
|
|
|
|
{"ESHOP_JP", 0x00020209 },
|
|
{"ESHOP_US", 0x00020219 },
|
|
{"ESHOP_EU", 0x00020229 },
|
|
|
|
{"ZONE_JP", 0x0002020b },
|
|
{"ZONE_US", 0x0002021b },
|
|
{"ZONE_EU", 0x0002022b },
|
|
|
|
{"MIGRATION_JP", 0x0002020a },
|
|
{"MIGRATION_US", 0x0002021a },
|
|
{"MIGRATION_EU", 0x0002022a },
|
|
|
|
{"DIARY_JP", 0x0002020c },
|
|
{"DIARY_US", 0x0002021c },
|
|
{"DIARY_EU", 0x0002022c },
|
|
|
|
{"MII_PLAZA_JP", 0x00020208 },
|
|
{"MII_PLAZA_US", 0x00020218 },
|
|
{"MII_PLAZA_EU", 0x00020228 },
|
|
|
|
{"ARGAMES_HAL_JP", 0x0002020d },
|
|
{"ARGAMES_HAL_US", 0x0002021d },
|
|
{"ARGAMES_HAL_EU", 0x0002022d },
|
|
|
|
{"ARGAMES_NCL_JP", 0x0002020e },
|
|
{"ARGAMES_NCL_US", 0x0002021e },
|
|
{"ARGAMES_NCL_EU", 0x0002022e },
|
|
|
|
{"MENU_JP", 0x00020081 },
|
|
{"MENU_US", 0x0002008f },
|
|
{"MENU_EU", 0x00020098 },
|
|
|
|
{"friend_JP", 0x0002008d },
|
|
{"friend_US", 0x00020096 },
|
|
{"friend_EU", 0x0002009f },
|
|
|
|
{"BROWSER_JP", 0x00020088 },
|
|
{"BROWSER_US", 0x0002009d },
|
|
{"BROWSER_EU", 0x00020094 },
|
|
|
|
{"ESPEC_JP", 0x00020086 },
|
|
{"ESPEC_US", 0x00020092 },
|
|
{"ESPEC_EU", 0x0002009b },
|
|
|
|
{"MEMO_JP", 0x00020087 },
|
|
{"MEMO_US", 0x00020093 },
|
|
{"MEMO_EU", 0x0002009c },
|
|
|
|
{"error", 0x000200c5 }
|
|
|
|
};
|
|
|
|
const char* const SYSTEM_SAVEDATA_ARCHIVE_NAME = "ssave:";
|
|
const char* const SHARED_EXT_SAVEDATA_ARCHIVE_NAME = "shext:";
|
|
|
|
const size_t SYSTEM_SAVE_DATA_NUM = sizeof(SYSTEM_SAVEDATA_COUPLE_LIST)/sizeof(SYSTEM_SAVEDATA_COUPLE_LIST[0]);
|
|
|
|
class SavedataCheckerBase
|
|
{
|
|
public:
|
|
SavedataCheckerBase() {}
|
|
SavedataCheckerBase(void* buf, size_t size);
|
|
~SavedataCheckerBase();
|
|
|
|
//! @brief セーブデータを調べて問題があるファイルを削除するインタフェース
|
|
//! @param[in] erase 問題があるファイルを削除するかどうか
|
|
virtual nn::Result CleanUp(bool erase) = 0;
|
|
//! @brief ファイルサイズをチェックするインタフェース
|
|
virtual nn::Result CalculateFileSize() = 0;
|
|
|
|
//! @return 事前に計算したサイズ
|
|
s64 GetCalculatedSize();
|
|
|
|
//! @return 読み取ったサイズ
|
|
s64 GetTotalReadSize();
|
|
|
|
//! @brief チェック時にエラーが起こったかどうか調べる
|
|
//! @return エラーが起こったかどうか
|
|
bool GetCheckErrorOccured();
|
|
|
|
protected:
|
|
//! @brief ファイルとディレクトリを再帰的にチェックする。エラーがあれば削除する
|
|
//! @param[out] metaDataCrashed メタデータが壊れていたかどうか。アーカイブごと削除するかどうかの判断に使用する
|
|
//! @param[out] modified ファイルかディレクトリを削除したかどうか。Commitするかどうかの判断に使用する
|
|
//! @param[in] baseName 削除するセーブデータの区別に表示するための名前
|
|
//! @param[in] currentDirectory チェックを開始するディレクトリ。スラッシュで終端すること
|
|
//! @param[in] erase ファイルかディレクトリを削除するかどうか
|
|
nn::Result CleanUpFilesRecursively(bool* metaDataCrashed, bool* modified, std::string baseName, std::wstring currentDirectory,
|
|
bool erase);
|
|
|
|
//! @brief ファイルサイズを取得する
|
|
//! @param[out] size ファイルサイズ
|
|
//! @param[in] currentDirectory チェックを開始するディレクトリ。スラッシュで終端すること。
|
|
nn::Result GetFileSize(std::wstring currentDirectory);
|
|
//! バッファ
|
|
void* m_Buf;
|
|
|
|
//! バッファサイズ
|
|
size_t m_Bufsize;
|
|
|
|
NN_PADDING4;
|
|
|
|
//! 事前読み取りサイズ
|
|
s64 m_CalculatedFileSize;
|
|
|
|
//! 累計読み取りサイズ
|
|
s64 m_TotalReadSize;
|
|
|
|
NN_PADDING3;
|
|
//! @brief チェック時にエラーが起こったかどうか
|
|
bool m_CheckErrorOccured;
|
|
NN_PADDING4;
|
|
|
|
private:
|
|
std::wstring GetFilePathWithoutArchive(std::wstring path);
|
|
bool IsForceDeleteFile(const char* name);
|
|
};
|
|
|
|
|
|
//! @brief システムセーブデータをチェックするためのクラス
|
|
class SystemSavedataChecker : public SavedataCheckerBase
|
|
{
|
|
public:
|
|
SystemSavedataChecker();
|
|
SystemSavedataChecker(void* buf, size_t size);
|
|
~SystemSavedataChecker();
|
|
|
|
//! @brief システムセーブデータを調べて問題があるファイルを削除する
|
|
//! @param[in] erase 問題があるファイルを削除するかどうか
|
|
virtual nn::Result CleanUp(bool erase);
|
|
|
|
//! @brief ファイルサイズをチェックする
|
|
virtual nn::Result CalculateFileSize();
|
|
};
|
|
|
|
//! @brief 共有拡張セーブデータをチェックするためのクラス
|
|
class SharedExtSavedataChecker : public SavedataCheckerBase
|
|
{
|
|
public:
|
|
SharedExtSavedataChecker();
|
|
SharedExtSavedataChecker(void* buf, size_t size);
|
|
~SharedExtSavedataChecker();
|
|
|
|
//! @brief 共有拡張セーブデータを調べて問題があるファイルを削除する
|
|
//! @param[in] erase 問題があるファイルを削除するかどうか
|
|
virtual nn::Result CleanUp(bool erase);
|
|
|
|
//! @brief ファイルサイズをチェックする
|
|
virtual nn::Result CalculateFileSize();
|
|
};
|
|
|
|
|
|
class NandSavedataChecker
|
|
{
|
|
public:
|
|
NandSavedataChecker();
|
|
NandSavedataChecker(void* buf, size_t size);
|
|
~NandSavedataChecker();
|
|
|
|
nn::Result CleanUp(bool erase);
|
|
|
|
s64 GetProgress();
|
|
|
|
bool GetCheckErrorOccured();
|
|
|
|
private:
|
|
SharedExtSavedataChecker* m_pSharedExtSaveChecker;
|
|
SystemSavedataChecker* m_pSysSaveChecker;
|
|
|
|
//! バッファ
|
|
void* m_Buf;
|
|
|
|
//! バッファサイズ
|
|
size_t m_Bufsize;
|
|
};
|
|
|
|
} /* namespace ConsoleBackup */
|
|
#endif /* SAVEDATACHECKER_H_ */
|