mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
SHAの計算に使用するバッファサイズを修正
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@523 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
814a2a199b
commit
3cfdcedcc0
@ -48,20 +48,60 @@ nn::Result HeapChecker::Check(std::wstring saveRoot, void* buf, size_t& bufSize)
|
||||
}
|
||||
|
||||
// NANDから読み込む
|
||||
nn::fs::FileInputStream file;
|
||||
result = file.TryInitialize(std::wstring(saveRoot + std::wstring(L"sysdata/00010026/00000000")).c_str());
|
||||
nn::fs::FileInputStream nandFile;
|
||||
result = nandFile.TryInitialize(std::wstring(saveRoot + std::wstring(L"sysdata/00010026/00000000")).c_str());
|
||||
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
|
||||
nn::fs::FileStream sdFile;
|
||||
result = sdFile.TryInitialize(HEAP_CHECKER_FILE,
|
||||
nn::fs::OPEN_MODE_READ | nn::fs::OPEN_MODE_WRITE | nn::fs::OPEN_MODE_CREATE);
|
||||
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
|
||||
|
||||
s32 readSize;
|
||||
result = file.TryRead(&readSize, buf, bufSize);
|
||||
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
|
||||
s32 readSize = 0;
|
||||
nn::crypto::Sha256Context writeContext;
|
||||
writeContext.Initialize();
|
||||
for(;;)
|
||||
{
|
||||
result = nandFile.TryRead(&readSize, buf, bufSize);
|
||||
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
|
||||
|
||||
result = sdReaderWriter.WriteBufWithCmac(HEAP_CHECKER_FILE, buf, bufSize - nn::crypto::SwAesCtrContext::AES_BLOCK_LENGTH);
|
||||
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
|
||||
if(readSize == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
size_t totalSize;
|
||||
result = sdReaderWriter.ReadBufWithCmac(HEAP_CHECKER_FILE, buf, bufSize, &totalSize);
|
||||
if(result <= nn::fs::ResultVerificationFailed())
|
||||
writeContext.Update(buf, readSize);
|
||||
|
||||
s32 writeSize;
|
||||
result = sdFile.TryWrite(&writeSize, buf, readSize, false);
|
||||
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
|
||||
|
||||
result = sdFile.TryFlush();
|
||||
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
|
||||
}
|
||||
|
||||
bit8 sha256WriteContext[nn::crypto::Sha256Context::HASH_SIZE];
|
||||
writeContext.GetHash(sha256WriteContext);
|
||||
|
||||
nn::crypto::Sha256Context readContext;
|
||||
readContext.Initialize();
|
||||
sdFile.SetPosition(0);
|
||||
for(;;)
|
||||
{
|
||||
result = sdFile.TryRead(&readSize, buf, bufSize);
|
||||
COMMON_LOGGER_RETURN_RESULT_IF_FAILED(result);
|
||||
|
||||
if(readSize == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
readContext.Update(buf, readSize);
|
||||
}
|
||||
|
||||
bit8 sha256ReadContext[nn::crypto::Sha256Context::HASH_SIZE];
|
||||
readContext.GetHash(sha256ReadContext);
|
||||
|
||||
if(std::memcmp(sha256WriteContext, sha256ReadContext, sizeof(sha256ReadContext)) != 0)
|
||||
{
|
||||
COMMON_LOGGER("HeapChecker Failure!! HeapSize: %d\n", bufSize);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user