summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/archive_ncch.cpp15
-rw-r--r--src/core/loader/ncch.cpp17
2 files changed, 27 insertions, 5 deletions
diff --git a/src/core/file_sys/archive_ncch.cpp b/src/core/file_sys/archive_ncch.cpp
index 19e1eb981..e8c5be983 100644
--- a/src/core/file_sys/archive_ncch.cpp
+++ b/src/core/file_sys/archive_ncch.cpp
@@ -14,6 +14,7 @@
14#include "core/file_sys/errors.h" 14#include "core/file_sys/errors.h"
15#include "core/file_sys/ivfc_archive.h" 15#include "core/file_sys/ivfc_archive.h"
16#include "core/file_sys/ncch_container.h" 16#include "core/file_sys/ncch_container.h"
17#include "core/file_sys/title_metadata.h"
17#include "core/hle/service/fs/archive.h" 18#include "core/hle/service/fs/archive.h"
18#include "core/loader/loader.h" 19#include "core/loader/loader.h"
19 20
@@ -27,8 +28,18 @@ static std::string GetNCCHContainerPath(const std::string& nand_directory) {
27} 28}
28 29
29static std::string GetNCCHPath(const std::string& mount_point, u32 high, u32 low) { 30static std::string GetNCCHPath(const std::string& mount_point, u32 high, u32 low) {
30 return Common::StringFromFormat("%s%08x/%08x/content/00000000.app", mount_point.c_str(), high, 31 u32 content_id = 0;
31 low); 32
33 // TODO(shinyquagsire23): Title database should be doing this path lookup
34 std::string content_path =
35 Common::StringFromFormat("%s%08x/%08x/content/", mount_point.c_str(), high, low);
36 std::string tmd_path = content_path + "00000000.tmd";
37 TitleMetadata tmd(tmd_path);
38 if (tmd.Load() == Loader::ResultStatus::Success) {
39 content_id = tmd.GetBootContentID();
40 }
41
42 return Common::StringFromFormat("%s%08x.app", content_path.c_str(), content_id);
32} 43}
33 44
34ArchiveFactory_NCCH::ArchiveFactory_NCCH(const std::string& nand_directory) 45ArchiveFactory_NCCH::ArchiveFactory_NCCH(const std::string& nand_directory)
diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp
index 66bc5823d..52686e364 100644
--- a/src/core/loader/ncch.cpp
+++ b/src/core/loader/ncch.cpp
@@ -14,6 +14,7 @@
14#include "core/core.h" 14#include "core/core.h"
15#include "core/file_sys/archive_selfncch.h" 15#include "core/file_sys/archive_selfncch.h"
16#include "core/file_sys/ncch_container.h" 16#include "core/file_sys/ncch_container.h"
17#include "core/file_sys/title_metadata.h"
17#include "core/hle/kernel/process.h" 18#include "core/hle/kernel/process.h"
18#include "core/hle/kernel/resource_limit.h" 19#include "core/hle/kernel/resource_limit.h"
19#include "core/hle/service/cfg/cfg.h" 20#include "core/hle/service/cfg/cfg.h"
@@ -49,9 +50,19 @@ static std::string GetUpdateNCCHPath(u64_le program_id) {
49 u32 high = static_cast<u32>((program_id | UPDATE_MASK) >> 32); 50 u32 high = static_cast<u32>((program_id | UPDATE_MASK) >> 32);
50 u32 low = static_cast<u32>((program_id | UPDATE_MASK) & 0xFFFFFFFF); 51 u32 low = static_cast<u32>((program_id | UPDATE_MASK) & 0xFFFFFFFF);
51 52
52 return Common::StringFromFormat("%sNintendo 3DS/%s/%s/title/%08x/%08x/content/00000000.app", 53 // TODO(shinyquagsire23): Title database should be doing this path lookup
53 FileUtil::GetUserPath(D_SDMC_IDX).c_str(), SYSTEM_ID, SDCARD_ID, 54 std::string content_path = Common::StringFromFormat(
54 high, low); 55 "%sNintendo 3DS/%s/%s/title/%08x/%08x/content/", FileUtil::GetUserPath(D_SDMC_IDX).c_str(),
56 SYSTEM_ID, SDCARD_ID, high, low);
57 std::string tmd_path = content_path + "00000000.tmd";
58
59 u32 content_id = 0;
60 FileSys::TitleMetadata tmd(tmd_path);
61 if (tmd.Load() == ResultStatus::Success) {
62 content_id = tmd.GetBootContentID();
63 }
64
65 return Common::StringFromFormat("%s%08x.app", content_path.c_str(), content_id);
55} 66}
56 67
57std::pair<boost::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode() { 68std::pair<boost::optional<u32>, ResultStatus> AppLoader_NCCH::LoadKernelSystemMode() {