mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-23 10:52:13 +00:00
Loader: Add support for exefs redirection to code nsp on SD.
This commit is contained in:
parent
44e2412ae6
commit
3a2520a3b7
4 changed files with 34 additions and 5 deletions
|
@ -20,6 +20,10 @@ Result ContentManagement::MountCode(u64 tid, FsStorageId sid) {
|
||||||
TryMountSdCard();
|
TryMountSdCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (kernelAbove200() && g_has_initialized_fs_dev && R_SUCCEEDED(MountCodeNspOnSd(tid))) {
|
||||||
|
return 0x0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (R_FAILED(rc = ResolveContentPath(path, tid, sid))) {
|
if (R_FAILED(rc = ResolveContentPath(path, tid, sid))) {
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -53,6 +57,18 @@ Result ContentManagement::UnmountCode() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result ContentManagement::MountCodeNspOnSd(u64 tid) {
|
||||||
|
char path[FS_MAX_PATH+1] = {0};
|
||||||
|
snprintf(path, FS_MAX_PATH, "sdmc:/atmosphere/titles/%016lx/exefs.nsp", tid);
|
||||||
|
Result rc = fsOpenFileSystemWithId(&g_CodeFileSystem, 0, FsFileSystemType_ApplicationPackage, path);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
fsdevMountDevice("code", g_CodeFileSystem);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
Result ContentManagement::MountCodeForTidSid(Registration::TidSid *tid_sid) {
|
Result ContentManagement::MountCodeForTidSid(Registration::TidSid *tid_sid) {
|
||||||
return MountCode(tid_sid->title_id, tid_sid->storage_id);
|
return MountCode(tid_sid->title_id, tid_sid->storage_id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
class ContentManagement {
|
class ContentManagement {
|
||||||
public:
|
public:
|
||||||
static Result MountCode(u64 tid, FsStorageId sid);
|
static Result MountCode(u64 tid, FsStorageId sid);
|
||||||
|
static Result MountCodeNspOnSd(u64 tid);
|
||||||
static Result UnmountCode();
|
static Result UnmountCode();
|
||||||
static Result MountCodeForTidSid(Registration::TidSid *tid_sid);
|
static Result MountCodeForTidSid(Registration::TidSid *tid_sid);
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc
|
||||||
Registration::Process *target_process;
|
Registration::Process *target_process;
|
||||||
Handle process_h = 0;
|
Handle process_h = 0;
|
||||||
u64 process_id = 0;
|
u64 process_id = 0;
|
||||||
|
bool mounted_code = false;
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
/* Get the process from the registration queue. */
|
/* Get the process from the registration queue. */
|
||||||
|
@ -107,6 +108,11 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
mounted_code = true;
|
||||||
|
} else {
|
||||||
|
if (R_SUCCEEDED(ContentManagement::MountCodeNspOnSd(target_process->tid_sid.title_id))) {
|
||||||
|
mounted_code = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load the process's NPDM. */
|
/* Load the process's NPDM. */
|
||||||
|
@ -193,11 +199,13 @@ Result ProcessCreation::CreateProcess(Handle *out_process_h, u64 index, char *nc
|
||||||
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
CREATE_PROCESS_END:
|
CREATE_PROCESS_END:
|
||||||
|
if (mounted_code) {
|
||||||
if (R_SUCCEEDED(rc) && target_process->tid_sid.storage_id != FsStorageId_None) {
|
if (R_SUCCEEDED(rc) && target_process->tid_sid.storage_id != FsStorageId_None) {
|
||||||
rc = ContentManagement::UnmountCode();
|
rc = ContentManagement::UnmountCode();
|
||||||
} else {
|
} else {
|
||||||
ContentManagement::UnmountCode();
|
ContentManagement::UnmountCode();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
*out_process_h = process_h;
|
*out_process_h = process_h;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -111,17 +111,21 @@ std::tuple<Result> ProcessManagerService::unregister_title(u64 index) {
|
||||||
Result ProcessManagerService::populate_program_info_buffer(ProcessManagerService::ProgramInfo *out, Registration::TidSid *tid_sid) {
|
Result ProcessManagerService::populate_program_info_buffer(ProcessManagerService::ProgramInfo *out, Registration::TidSid *tid_sid) {
|
||||||
NpdmUtils::NpdmInfo info;
|
NpdmUtils::NpdmInfo info;
|
||||||
Result rc;
|
Result rc;
|
||||||
|
bool mounted_code = false;
|
||||||
|
|
||||||
if (tid_sid->storage_id != FsStorageId_None) {
|
if (tid_sid->storage_id != FsStorageId_None) {
|
||||||
rc = ContentManagement::MountCodeForTidSid(tid_sid);
|
rc = ContentManagement::MountCodeForTidSid(tid_sid);
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
mounted_code = true;
|
||||||
|
} else if (R_SUCCEEDED(ContentManagement::MountCodeNspOnSd(tid_sid->title_id))) {
|
||||||
|
mounted_code = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = NpdmUtils::LoadNpdm(tid_sid->title_id, &info);
|
rc = NpdmUtils::LoadNpdm(tid_sid->title_id, &info);
|
||||||
|
|
||||||
if (tid_sid->storage_id != FsStorageId_None) {
|
if (mounted_code) {
|
||||||
ContentManagement::UnmountCode();
|
ContentManagement::UnmountCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue