TWLタイトルリストを読み出してProgramId一覧を取得するように

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@233 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
N2614 2011-04-27 06:47:01 +00:00
parent a357d5bf7e
commit 32350f630b
4 changed files with 118 additions and 24 deletions

View File

@ -18,10 +18,12 @@
#include <nn/nim.h>
#include <nn/CTR/CTR_ProgramId.h>
#include "FileName.h"
#include "CommonLogger.h"
#include "HeapManager.h"
#include "TitleDownloader.h"
#include "Shop.h"
#include "SdReaderWriter.h"
namespace
@ -193,37 +195,44 @@ void TitleDownloader::Start()
nn::Result TitleDownloader::ListUp()
{
// TODO: ファイルリストを読み出してリスト生成
const u32 AM_TICKET_MAX = 7168;
COMMON_LOGGER("Export TwlTitle List.\n");
s32 personalizedTicketNum;
nn::Result result;
size_t heapSize = common::HeapManager::GetHeap()->GetAllocatableSize();
char* titleListBuf = reinterpret_cast<char*> (common::HeapManager::GetHeap()->Allocate(heapSize));
nn::am::TicketInfo *ticketInfoBuffer =
reinterpret_cast<nn::am::TicketInfo*> (common::HeapManager::GetHeap()->Allocate(
sizeof(nn::am::TicketInfo) * AM_TICKET_MAX));
if(ticketInfoBuffer == NULL)
size_t readSize = 0;
if (titleListBuf != NULL)
{
common::SdReaderWriter sdReader;
m_Result = sdReader.ReadBufWithCmac(common::TWL_TITLELIST_PATHNAME, titleListBuf, heapSize, &readSize);
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(m_Result);
u32 listHead = 0;
for (u32 i = 0; i < readSize; i++)
{
if (titleListBuf[i] == '\n')
{
char ProgramIdStr[32];
char *error;
std::memcpy(ProgramIdStr, &titleListBuf[listHead], i - listHead);
m_ProgramIdList[m_TwlTiteNum] = std::strtoull(ProgramIdStr, &error, 16);
m_TwlTiteNum++;
NN_LOG("%016llx\n", m_ProgramIdList[m_TwlTiteNum - 1]);
listHead = i + 1;
}
}
common::HeapManager::GetHeap()->Free(titleListBuf);
}
else
{
COMMON_LOGGER("Failed Allocate Heap!!\n");
m_Result = nn::Result(nn::Result::LEVEL_FATAL, nn::Result::SUMMARY_OUT_OF_RESOURCE, nn::Result::MODULE_COMMON,
nn::Result::DESCRIPTION_OUT_OF_MEMORY);
return m_Result;
}
m_Result=nn::am::GetPersonalizedTicketInfoList(&personalizedTicketNum, ticketInfoBuffer, AM_TICKET_MAX); // 全部
COMMON_LOGGER_RESULT_IF_FAILED_WITH_LINE(m_Result);
for (u32 i = 0; i < personalizedTicketNum; i++)
{
if (nn::CTR::IsTwlApp(ticketInfoBuffer[i].titleId))
{
m_ProgramIdList[m_TwlTiteNum] = ticketInfoBuffer[i].titleId;
m_TwlTiteNum++;
NN_LOG("%016llx\n", m_ProgramIdList[m_TwlTiteNum - 1]);
}
}
return m_Result;
}
}

View File

@ -0,0 +1,20 @@
#!/usr/bin/env omake
#----------------------------------------------------------------------------
# Project: Horizon
# File: OMakefile
#
# Copyright (C)2009 Nintendo Co., Ltd. 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$
#----------------------------------------------------------------------------
if $(IsTestBuild)
.SUBDIRS: TitleDownloader
DefineDefaultRules()

View File

@ -0,0 +1,65 @@
#!/usr/bin/env omake
#----------------------------------------------------------------------------
# Project: Horizon
# File: OMakefile
#
# Copyright (C)2009 Nintendo Co., Ltd. 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$
#----------------------------------------------------------------------------
SUPPORTED_TARGETS = CTR-*.Process.MPCore.*
include $(makePlatformDefsPath tests)
SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include)
INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \
../../../common \
../../../ConsoleRestore \
TEST_COMMON_SOURCES[] =
../../../ConsoleRestore/TitleDownloader.cpp
../../../ConsoleRestore/Shop.cpp
../../../common/Util.cpp
../../../common/HeapManager.cpp
../../../common/SdLogger.cpp
../../../common/LogConsole.cpp
../../../common/CommonLogger.cpp
../../../common/SdMountManager.cpp
../../../common/PlayHistoryManager.cpp
../../../common/VersionDetect.cpp
../../../common/HardwareStateManager.cpp
../../../common/FileTransfer.cpp
../../../common/SdReaderWriter.cpp
SOURCES_TEST[] = test_TitleDownloader.cpp
ROMFS_ROOT = ../../../common/romfiles
TEST_ENVIRONMENT_PROCESSLIST = true
TEST_ENVIRONMENT_EMUMEM = true
LIBS += libnn_test \
libnn_mcu \
libnn_ps \
libnn_am \
lib_demo \
libnn_nim \
ROM_SPEC_FILE = ../../../ConsoleRestore/ConsoleRestore.rsf
DESCRIPTOR = $(HORIZON_ROOT)/resources/specfiles/_private/RepairTool.desc
include $(makePlatformDefsPath build.tests)
tests: $(TEST_TARGETS)

View File

@ -15,6 +15,6 @@
#----------------------------------------------------------------------------
if $(IsTestBuild)
.SUBDIRS: common ConsoleBackup
.SUBDIRS: common ConsoleBackup ConsoleRestore
DefineDefaultRules()