16MB以上のヒープを使わないように

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
This commit is contained in:
N2614 2011-09-30 06:42:19 +00:00
parent 9c0c838ba7
commit 63808f423f
9 changed files with 68 additions and 0 deletions

View File

@ -14,9 +14,11 @@
*---------------------------------------------------------------------------*/
#include "common_Types.h"
#include "CommonLogger.h"
#include "HeapManager.h"
#include "SaveDataChecker.h"
#include <nn/drivers/aes/CTR/ARM946ES/driverAes_Types.h>
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)
{

View File

@ -155,6 +155,11 @@ nn::Result WriteTwlTitleList(std::vector<std::wstring>& 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<char*> (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();

View File

@ -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)

View File

@ -18,6 +18,7 @@
#include <nn/nim.h>
#include <nn/CTR/CTR_ProgramId.h>
#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<char*> (heap.GetAddr());

View File

@ -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_ */

View File

@ -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
{

View File

@ -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();

View File

@ -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();

View File

@ -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();