citra-emu
/
citra-canary
Archived
1
0
Fork 0

loader/ncch: Use AM to get update title path

This commit is contained in:
shinyquagsire23 2017-10-05 16:23:03 -06:00
parent b9fc359e7e
commit a4af750759
1 changed files with 3 additions and 20 deletions

View File

@ -17,6 +17,7 @@
#include "core/file_sys/title_metadata.h"
#include "core/hle/kernel/process.h"
#include "core/hle/kernel/resource_limit.h"
#include "core/hle/service/am/am.h"
#include "core/hle/service/cfg/cfg.h"
#include "core/hle/service/fs/archive.h"
#include "core/loader/ncch.h"
@ -46,25 +47,6 @@ FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) {
return FileType::Error;
}
static std::string GetUpdateNCCHPath(u64_le program_id) {
u32 high = static_cast<u32>((program_id | UPDATE_MASK) >> 32);
u32 low = static_cast<u32>((program_id | UPDATE_MASK) & 0xFFFFFFFF);
// TODO(shinyquagsire23): Title database should be doing this path lookup
std::string content_path = Common::StringFromFormat(
"%sNintendo 3DS/%s/%s/title/%08x/%08x/content/", FileUtil::GetUserPath(D_SDMC_IDX).c_str(),
SYSTEM_ID, SDCARD_ID, high, low);
std::string tmd_path = content_path + "00000000.tmd";
u32 content_id = 0;
FileSys::TitleMetadata tmd(tmd_path);
if (tmd.Load() == ResultStatus::Success) {
content_id = tmd.GetBootContentID();
}
return Common::StringFromFormat("%s%08x.app", content_path.c_str(), content_id);
}
std::pair<boost::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode() {
if (!is_loaded) {
ResultStatus res = base_ncch.Load();
@ -176,7 +158,8 @@ ResultStatus AppLoader_NCCH::Load(Kernel::SharedPtr<Kernel::Process>& process) {
LOG_INFO(Loader, "Program ID: %s", program_id.c_str());
update_ncch.OpenFile(GetUpdateNCCHPath(ncch_program_id));
update_ncch.OpenFile(Service::AM::GetTitleContentPath(Service::FS::MediaType::SDMC,
ncch_program_id | UPDATE_MASK));
result = update_ncch.Load();
if (result == ResultStatus::Success) {
overlay_ncch = &update_ncch;