From 63808f423fd5688697ff8c6b8c3a09b9b1cb68f1 Mon Sep 17 00:00:00 2001 From: N2614 Date: Fri, 30 Sep 2011 06:42:19 +0000 Subject: [PATCH] =?UTF-8?q?16MB=E4=BB=A5=E4=B8=8A=E3=81=AE=E3=83=92?= =?UTF-8?q?=E3=83=BC=E3=83=97=E3=82=92=E4=BD=BF=E3=82=8F=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@437 385bec56-5757-e545-9c3a-d8741f4650f1 --- .../sources/ConsoleBackup/Checker.cpp | 6 +++++ .../sources/ConsoleBackup/Exporter.cpp | 17 +++++++++++++ .../sources/ConsoleRestore/Importer.cpp | 24 +++++++++++++++++++ .../ConsoleRestore/TitleDownloader.cpp | 5 ++++ .../sources/common/FileTransfer.h | 2 ++ .../sources/common/common_Types.h | 2 ++ .../sources/tools/CmacAdder/main.cpp | 4 ++++ .../tools/ExportedDataVerifier/main.cpp | 4 ++++ .../sources/tools/FatDataEncrypter/main.cpp | 4 ++++ 9 files changed, 68 insertions(+) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Checker.cpp b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Checker.cpp index b28a0ff..41fd670 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Checker.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Checker.cpp @@ -14,9 +14,11 @@ *---------------------------------------------------------------------------*/ +#include "common_Types.h" #include "CommonLogger.h" #include "HeapManager.h" #include "SaveDataChecker.h" +#include namespace ConsoleBackup { @@ -48,6 +50,10 @@ s32 GetCheckSaveDataProgress() void CheckSaveDataThreadFunc() { size_t bufSize = common::GetAllocatableSize(); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager heap(bufSize); if (heap.GetAddr() != NULL) { diff --git a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.cpp b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.cpp index 451a2a8..b7e6470 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleBackup/Exporter.cpp @@ -155,6 +155,11 @@ nn::Result WriteTwlTitleList(std::vector& programIdList) COMMON_LOGGER("Export TwlTitle List.\n"); size_t heapSize = common::GetAllocatableSize(); + if(heapSize > common::FILE_COPY_HEAP_SIZE) + { + heapSize = common::FILE_COPY_HEAP_SIZE; + } + common::HeapManager manager(heapSize); char* titleListBuf = reinterpret_cast (manager.GetAddr()); @@ -486,6 +491,10 @@ void WriteTwlData(enum common::TWL_PATH_INDEX path) size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE * 2); NN_LOG("AllocatableSize = %d\n", bufSize); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager writeHeap(bufSize, AES_BLOCK_SIZE * 2); void* buf = writeHeap.GetAddr(); @@ -609,6 +618,10 @@ void WriteTwlSaveData() size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE * 2); NN_LOG("AllocatableSize = %d\n", bufSize); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager writeHeap(bufSize, AES_BLOCK_SIZE * 2); void* buf = writeHeap.GetAddr(); @@ -756,6 +769,10 @@ void ExportThreadFunc() size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE * 2); NN_LOG("AllocatableSize = %d\n", bufSize); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager writeHeap(bufSize, AES_BLOCK_SIZE * 2); void* buf = writeHeap.GetAddr(); diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp index 4f7c6a7..30e1659 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/Importer.cpp @@ -708,6 +708,10 @@ void ImportThreadFunc() size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE * 2); NN_LOG("AllocatableSize = %d\n", bufSize); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager heap(bufSize, AES_BLOCK_SIZE * 2); void* buf = heap.GetAddr(); @@ -759,6 +763,10 @@ nn::Result ImportNorData() size_t bufSize = common::GetAllocatableSize() / 2; NN_LOG("AllocatableSize = %d\n", bufSize); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager heap(bufSize); void* buf = heap.GetAddr(); @@ -841,6 +849,10 @@ nn::Result ReadVersionData() size_t bufSize = common::GetAllocatableSize() / 2; NN_LOG("AllocatableSize = %d\n", bufSize); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager heap(bufSize); void* buf = heap.GetAddr(); @@ -1483,6 +1495,10 @@ void ImportTwlData(enum common::TWL_PATH_INDEX path, s64 fileSize) size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE * 2); NN_LOG("AllocatableSize = %d\n", bufSize); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } // ファイルサイズ設定 common::InitializeTransferProgress(fileSize); @@ -1524,6 +1540,10 @@ void ImportTwlTitleSaveData(s64 fileSize) size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE * 2); NN_LOG("AllocatableSize = %d\n", bufSize); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } // ファイルサイズ設定 common::InitializeTransferProgress(fileSize); @@ -1655,6 +1675,10 @@ nn::Result ImportCalData(common::CfgCalData *data) common::SdMountManager::Mount(); size_t bufSize = common::GetAllocatableSize() / 2; + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager heap(bufSize); void* buf = heap.GetAddr(); if (buf != NULL) diff --git a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp index 469fae3..2960c36 100644 --- a/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp +++ b/trunk/ConsoleDataMigration/sources/ConsoleRestore/TitleDownloader.cpp @@ -18,6 +18,7 @@ #include #include +#include "common_Types.h" #include "FileName.h" #include "CommonLogger.h" #include "HeapManager.h" @@ -220,6 +221,10 @@ nn::Result TitleDownloader::ListUp() COMMON_LOGGER("Read TwlTitle List.\n"); size_t heapSize = common::GetAllocatableSize(); + if(heapSize > common::FILE_COPY_HEAP_SIZE) + { + heapSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager heap(heapSize); char* titleListBuf = reinterpret_cast (heap.GetAddr()); diff --git a/trunk/ConsoleDataMigration/sources/common/FileTransfer.h b/trunk/ConsoleDataMigration/sources/common/FileTransfer.h index e55f3bf..02042c2 100644 --- a/trunk/ConsoleDataMigration/sources/common/FileTransfer.h +++ b/trunk/ConsoleDataMigration/sources/common/FileTransfer.h @@ -57,6 +57,8 @@ void InitializeTransferProgress(u64 totalSize); // 内部のバッファを使用するためスレッドアンセーフ const char* GetCharStr(const wchar_t* path); +void AddPkcsPadding(u8* paddingSize, void* buf, size_t bufSize, s32* readSize); + } #endif /* FILETRANSFER_H_ */ diff --git a/trunk/ConsoleDataMigration/sources/common/common_Types.h b/trunk/ConsoleDataMigration/sources/common/common_Types.h index fd76dad..581b718 100644 --- a/trunk/ConsoleDataMigration/sources/common/common_Types.h +++ b/trunk/ConsoleDataMigration/sources/common/common_Types.h @@ -39,6 +39,8 @@ const u32 TWL_WIFI_SETTING_SIZE = 0x600; // TWL Wifi 設定のサ const u64 INFRA_DEVICE_ID_OFFSET = 0x400000000; +const size_t FILE_COPY_HEAP_SIZE = 16 * 1024 * 1024; + // NOR領域のみにある設定データ用構造体 struct NtrNorData { diff --git a/trunk/ConsoleDataMigration/sources/tools/CmacAdder/main.cpp b/trunk/ConsoleDataMigration/sources/tools/CmacAdder/main.cpp index 7193676..c8c1f4c 100644 --- a/trunk/ConsoleDataMigration/sources/tools/CmacAdder/main.cpp +++ b/trunk/ConsoleDataMigration/sources/tools/CmacAdder/main.cpp @@ -180,6 +180,10 @@ void AddCmacThreadFunc() result = common::SdMountManager::Mount(); size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE * 2); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager heap(bufSize, AES_BLOCK_SIZE * 2); void* buf = heap.GetAddr(); diff --git a/trunk/ConsoleDataMigration/sources/tools/ExportedDataVerifier/main.cpp b/trunk/ConsoleDataMigration/sources/tools/ExportedDataVerifier/main.cpp index 322b839..f2748da 100644 --- a/trunk/ConsoleDataMigration/sources/tools/ExportedDataVerifier/main.cpp +++ b/trunk/ConsoleDataMigration/sources/tools/ExportedDataVerifier/main.cpp @@ -385,6 +385,10 @@ void VerifyThreadFunc() result = common::SdMountManager::Mount(); size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE * 2); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager heap(bufSize, AES_BLOCK_SIZE * 2); void* buf = heap.GetAddr(); diff --git a/trunk/ConsoleDataMigration/sources/tools/FatDataEncrypter/main.cpp b/trunk/ConsoleDataMigration/sources/tools/FatDataEncrypter/main.cpp index b3e83c9..f09c8e1 100644 --- a/trunk/ConsoleDataMigration/sources/tools/FatDataEncrypter/main.cpp +++ b/trunk/ConsoleDataMigration/sources/tools/FatDataEncrypter/main.cpp @@ -306,6 +306,10 @@ void EncryptThreadFunc() result = common::SdMountManager::Mount(); size_t bufSize = common::GetAllocatableSize(AES_BLOCK_SIZE * 2); + if(bufSize > common::FILE_COPY_HEAP_SIZE) + { + bufSize = common::FILE_COPY_HEAP_SIZE; + } common::HeapManager heap(bufSize, AES_BLOCK_SIZE * 2); void* buf = heap.GetAddr();