From b365065a2d9048eb4a3263690769bcf0ec34322d Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Fri, 27 Jul 2018 19:53:20 -0700 Subject: [PATCH] Loader: Support loading FsStorageId_None content from SD. --- .../loader/source/ldr_content_management.cpp | 1 + .../loader/source/ldr_process_creation.cpp | 10 ++++--- .../loader/source/ldr_process_manager.cpp | 27 ++++++++++++------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/stratosphere/loader/source/ldr_content_management.cpp b/stratosphere/loader/source/ldr_content_management.cpp index 29487b327..4424441e1 100644 --- a/stratosphere/loader/source/ldr_content_management.cpp +++ b/stratosphere/loader/source/ldr_content_management.cpp @@ -44,6 +44,7 @@ Result ContentManagement::MountCode(u64 tid, FsStorageId sid) { fsdevMountDevice("code", g_CodeFileSystem); + fsldrExit(); return rc; } diff --git a/stratosphere/loader/source/ldr_process_creation.cpp b/stratosphere/loader/source/ldr_process_creation.cpp index 56ba05af2..b8f9c71c4 100644 --- a/stratosphere/loader/source/ldr_process_creation.cpp +++ b/stratosphere/loader/source/ldr_process_creation.cpp @@ -102,9 +102,11 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc } /* Mount the title's exefs. */ - rc = ContentManagement::MountCodeForTidSid(&target_process->tid_sid); - if (R_FAILED(rc)) { - return rc; + if (target_process->tid_sid.storage_id != FsStorageId_None) { + rc = ContentManagement::MountCodeForTidSid(&target_process->tid_sid); + if (R_FAILED(rc)) { + return rc; + } } /* Load the process's NPDM. */ @@ -191,7 +193,7 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc rc = 0; CREATE_PROCESS_END: - if (R_SUCCEEDED(rc)) { + if (R_SUCCEEDED(rc) && target_process->tid_sid.storage_id != FsStorageId_None) { rc = ContentManagement::UnmountCode(); } else { ContentManagement::UnmountCode(); diff --git a/stratosphere/loader/source/ldr_process_manager.cpp b/stratosphere/loader/source/ldr_process_manager.cpp index 2ea5bd03b..55511f56c 100644 --- a/stratosphere/loader/source/ldr_process_manager.cpp +++ b/stratosphere/loader/source/ldr_process_manager.cpp @@ -42,10 +42,13 @@ std::tuple ProcessManagerService::create_process(u64 flags, return {rc, MovedHandle{process_h}}; } - rc = ContentManagement::ResolveContentPathForTidSid(nca_path, &tid_sid); - if (R_FAILED(rc)) { - return {rc, MovedHandle{process_h}}; + if (tid_sid.storage_id != FsStorageId_None) { + rc = ContentManagement::ResolveContentPathForTidSid(nca_path, &tid_sid); + if (R_FAILED(rc)) { + return {rc, MovedHandle{process_h}}; + } } + launch_item = LaunchQueue::get_item(tid_sid.title_id); @@ -70,7 +73,7 @@ std::tuple ProcessManagerService::get_program_info(Registration::TidSid return {rc}; } - if (tid_sid.title_id != out_program_info.pointer->title_id) { + if (tid_sid.storage_id != FsStorageId_None && tid_sid.title_id != out_program_info.pointer->title_id) { rc = ContentManagement::ResolveContentPathForTidSid(nca_path, &tid_sid); if (R_FAILED(rc)) { return {rc}; @@ -109,17 +112,23 @@ Result ProcessManagerService::populate_program_info_buffer(ProcessManagerService NpdmUtils::NpdmInfo info; Result rc; - rc = ContentManagement::MountCodeForTidSid(tid_sid); - if (R_FAILED(rc)) { - return rc; + if (tid_sid->storage_id != FsStorageId_None) { + rc = ContentManagement::MountCodeForTidSid(tid_sid); + if (R_FAILED(rc)) { + return rc; + } } rc = NpdmUtils::LoadNpdm(tid_sid->title_id, &info); + + if (tid_sid->storage_id != FsStorageId_None) { + ContentManagement::UnmountCode(); + } + if (R_FAILED(rc)) { return rc; } - - ContentManagement::UnmountCode(); + out->main_thread_priority = info.header->main_thread_prio; out->default_cpu_id = info.header->default_cpuid;