mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
ファイルサイズもテキストで出力するように
ReadBufWithCmacで読みこんだバッファのCMACは0クリアするように ファイル一覧を取得できるように git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@154 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
da1f86929b
commit
fc0324adb4
@ -84,6 +84,13 @@ nn::Result ImportNorData();
|
|||||||
// SDカードに保存してあるバージョン情報
|
// SDカードに保存してあるバージョン情報
|
||||||
common::VerDef s_SDVersionData;
|
common::VerDef s_SDVersionData;
|
||||||
|
|
||||||
|
struct ImportDataEntry
|
||||||
|
{
|
||||||
|
std::string fileName;
|
||||||
|
NN_PADDING3;
|
||||||
|
bool isDirectory;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckedNetworkSetting s_CurrentNetowrkSetting1;
|
CheckedNetworkSetting s_CurrentNetowrkSetting1;
|
||||||
@ -1518,6 +1525,91 @@ nn::Result InitializeHardwareDependentSetting()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nn::Result ReadFileList(s64* totalFileSize, std::vector<ImportDataEntry>* fileList)
|
||||||
|
{
|
||||||
|
nn::Result result = nn::ResultSuccess();
|
||||||
|
|
||||||
|
COMMON_LOGGER("Read File List\n");
|
||||||
|
|
||||||
|
size_t readSize;
|
||||||
|
common::SdReaderWriter sdReader;
|
||||||
|
s64 fileSize;
|
||||||
|
{
|
||||||
|
nn::fs::FileInputStream file;
|
||||||
|
|
||||||
|
// サイズ取得のため一時的に開く
|
||||||
|
result = file.TryInitialize(common::FILE_LIST_PATHNAME);
|
||||||
|
NN_UTIL_RETURN_IF_FAILED(result);
|
||||||
|
|
||||||
|
result = file.TryGetSize(&fileSize);
|
||||||
|
if (result.IsFailure())
|
||||||
|
{
|
||||||
|
file.Finalize();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
file.Finalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void* buf = common::HeapManager::GetHeap()->Allocate(fileSize);
|
||||||
|
if(buf != NULL)
|
||||||
|
{
|
||||||
|
result = sdReader.ReadBufWithCmac(common::FILE_LIST_PATHNAME, buf, fileSize, &readSize);
|
||||||
|
if(result.IsSuccess())
|
||||||
|
{
|
||||||
|
// ファイル一覧
|
||||||
|
const char comma[] = ",";
|
||||||
|
const char newLine[] = "\n";
|
||||||
|
char *token = NULL;
|
||||||
|
token = std::strtok(reinterpret_cast<char*>(buf), comma);
|
||||||
|
bool parseFileName = false;
|
||||||
|
ImportDataEntry entry;
|
||||||
|
|
||||||
|
entry.fileName = std::string(token);
|
||||||
|
while( token != NULL)
|
||||||
|
{
|
||||||
|
if(parseFileName)
|
||||||
|
{
|
||||||
|
token = std::strtok(NULL, comma);
|
||||||
|
if(token != NULL)
|
||||||
|
{
|
||||||
|
entry.fileName = std::string(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
token = std::strtok(NULL, newLine);
|
||||||
|
if(token != NULL)
|
||||||
|
{
|
||||||
|
s64 size = std::atoll(token);
|
||||||
|
if(size != -1)
|
||||||
|
{
|
||||||
|
*totalFileSize += size;
|
||||||
|
entry.isDirectory = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entry.isDirectory = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
fileList->push_back(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parseFileName = !parseFileName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
common::HeapManager::GetHeap()->Free(buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
|
||||||
|
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
nn::Result ImportData()
|
nn::Result ImportData()
|
||||||
{
|
{
|
||||||
static nn::Result result = nn::ResultSuccess();
|
static nn::Result result = nn::ResultSuccess();
|
||||||
@ -1529,6 +1621,12 @@ nn::Result ImportData()
|
|||||||
// NANDのごみを削除する
|
// NANDのごみを削除する
|
||||||
Cleanup();
|
Cleanup();
|
||||||
|
|
||||||
|
// ファイル一覧を読み込む
|
||||||
|
s64 totalFileSize = 0;
|
||||||
|
std::vector<ImportDataEntry> fileList;
|
||||||
|
result = ReadFileList(&totalFileSize, &fileList);
|
||||||
|
NN_UTIL_RETURN_IF_FAILED(result);
|
||||||
|
|
||||||
// SDカードのIVSファイルを書き込む
|
// SDカードのIVSファイルを書き込む
|
||||||
result = ImportIvs();
|
result = ImportIvs();
|
||||||
NN_UTIL_RETURN_IF_FAILED(result);
|
NN_UTIL_RETURN_IF_FAILED(result);
|
||||||
|
|||||||
@ -170,7 +170,7 @@ bool CopyDirectory(const wchar_t * from_path, const wchar_t * to_path, void* buf
|
|||||||
target_to << L"/";
|
target_to << L"/";
|
||||||
if(encode)
|
if(encode)
|
||||||
{
|
{
|
||||||
AddPathNameAndUpdateContext(list, target_to.str().c_str(), 0, listContext);
|
AddPathNameAndUpdateContext(list, target_to.str().c_str(), -1, listContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -644,8 +644,11 @@ void AddPathNameAndUpdateContext(nn::fs::FileOutputStream* file, const wchar_t *
|
|||||||
context->Update(&comma, sizeof(comma));
|
context->Update(&comma, sizeof(comma));
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||||
|
|
||||||
result = file->TryWrite(&writeSize, &fileSize, sizeof(fileSize), true);
|
char sizeStr[10];
|
||||||
context->Update(&fileSize, sizeof(fileSize));
|
std::memset(sizeStr, 0, sizeof(sizeStr));
|
||||||
|
s32 sizeStrSize = std::snprintf(sizeStr, sizeof(sizeStr), "%lld", fileSize);
|
||||||
|
result = file->TryWrite(&writeSize, sizeStr, sizeStrSize, true);
|
||||||
|
context->Update(sizeStr, sizeStrSize);
|
||||||
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(result);
|
||||||
|
|
||||||
char newLine = '\n';
|
char newLine = '\n';
|
||||||
|
|||||||
@ -225,6 +225,9 @@ nn::Result SdReaderWriter::ReadBufWithCmac(const wchar_t* path, void* buf, size_
|
|||||||
return nn::fs::ResultVerificationFailed();
|
return nn::fs::ResultVerificationFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CMACを0埋め
|
||||||
|
std::memset(reinterpret_cast<bit8*>(buf) + *totalSize, 0, sizeof(cmac));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user